Skip to content

Commit 6039b88

Browse files
authored
Simplify PR comment processing, skip obsolete Go versions (#28)
1 parent 8578a13 commit 6039b88

File tree

5 files changed

+15
-32
lines changed

5 files changed

+15
-32
lines changed

templates/github/workflows/bench.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,11 @@ jobs:
7777
BENCH_COUNT=5 make bench
7878
OUTPUT=$(make bench-stat-diff)
7979
echo "${OUTPUT}"
80-
OUTPUT="${OUTPUT//'%'/'%25'}"
81-
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
82-
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
80+
OUTPUT="${OUTPUT//$'\n'/%0A}"
8381
echo "::set-output name=diff::$OUTPUT"
8482
OUTPUT=$(make bench-stat)
8583
echo "${OUTPUT}"
86-
OUTPUT="${OUTPUT//'%'/'%25'}"
87-
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
88-
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
84+
OUTPUT="${OUTPUT//$'\n'/%0A}"
8985
echo "::set-output name=result::$OUTPUT"
9086
- name: Comment Benchmark Result
9187
continue-on-error: true

templates/github/workflows/cloc.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ jobs:
2121
curl -sLO https://github.com/vearutop/sccdiff/releases/download/v1.0.1/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
2222
OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
2323
echo "${OUTPUT}"
24-
OUTPUT="${OUTPUT//'%'/'%25'}"
25-
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
26-
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
24+
OUTPUT="${OUTPUT//$'\n'/%0A}"
2725
echo "::set-output name=diff::$OUTPUT"
2826
2927
- name: Comment Code Lines

templates/github/workflows/gorelease.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,15 @@ jobs:
2929
test -e ~/go/bin/gorelease || go install golang.org/x/exp/cmd/gorelease@latest
3030
OUTPUT=$(gorelease || exit 0)
3131
echo "${OUTPUT}"
32-
OUTPUT="${OUTPUT//'%'/'%25'}"
33-
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
34-
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
32+
OUTPUT="${OUTPUT//$'\n'/%0A}"
3533
echo "::set-output name=report::$OUTPUT"
3634
- name: Comment Report
3735
continue-on-error: true
3836
uses: marocchino/sticky-pull-request-comment@v2
3937
with:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4138
header: gorelease
4239
message: |
43-
### API Changes
40+
### Go API Changes
4441
4542
<pre>
4643
${{ steps.gorelease.outputs.report }}

templates/github/workflows/test-integration.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ env:
1212
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
1313
jobs:
1414
test:
15-
strategy:
16-
matrix:
17-
go-version: [ 1.17.x ]
1815
runs-on: ubuntu-latest
1916
steps:
2017
- name: Install Go
2118
uses: actions/setup-go@v2
2219
with:
23-
go-version: ${{ matrix.go-version }}
20+
go-version: 1.17.x
2421
- name: Checkout code
2522
uses: actions/checkout@v2
2623
- name: Go cache
@@ -36,23 +33,23 @@ jobs:
3633
restore-keys: |
3734
${{ runner.os }}-go-cache
3835
- name: Restore base test coverage
39-
if: matrix.go-version == '1.17.x'
36+
id: base-coverage
4037
uses: actions/cache@v2
4138
with:
4239
path: |
4340
integration-base.txt
4441
# Use base sha for PR or new commit hash for master/main push in test result key.
4542
key: ${{ runner.os }}-integration-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
4643
- name: Checkout base code
47-
if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
44+
if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
4845
uses: actions/checkout@v2
4946
with:
5047
ref: ${{ github.event.pull_request.base.sha }}
5148
path: __base
5249
- name: Docker Compose
5350
run: (test -f ${{ env.DOCKER_COMPOSE_FILE }} && docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} up -d && docker ps && docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} logs) || echo "::warning ::Missing ${{ env.DOCKER_COMPOSE_FILE }} file"
5451
- name: Run test for base code
55-
if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
52+
if: env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
5653
run: |
5754
cd __base
5855
make | grep test-integration && (make test-integration && go tool cover -func=./integration.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > ../integration-base.txt) || echo "No test-integration in base"
@@ -63,9 +60,7 @@ jobs:
6360
go tool cover -func=./integration.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > integration.txt
6461
OUTPUT=$(test -e integration-base.txt && (diff integration-base.txt integration.txt || exit 0) || cat integration.txt)
6562
echo "${OUTPUT}"
66-
OUTPUT="${OUTPUT//'%'/'%25'}"
67-
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
68-
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
63+
OUTPUT="${OUTPUT//$'\n'/%0A}"
6964
TOTAL=$(grep 'total:' integration.txt)
7065
echo "${TOTAL}"
7166
echo "::set-output name=diff::$OUTPUT"
@@ -75,7 +70,6 @@ jobs:
7570
run: cp integration.txt integration-base.txt
7671
- name: Comment Test Coverage
7772
continue-on-error: true
78-
if: matrix.go-version == '1.17.x'
7973
uses: marocchino/sticky-pull-request-comment@v2
8074
with:
8175
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -91,7 +85,6 @@ jobs:
9185
</details>
9286
9387
- name: Upload code coverage
94-
if: matrix.go-version == '1.17.x'
9588
uses: codecov/codecov-action@v1
9689
with:
9790
file: ./integration.coverprofile

templates/github/workflows/test-unit.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
test:
1414
strategy:
1515
matrix:
16-
go-version: [ 1.13.x, 1.14.x, 1.15.x, 1.16.x, 1.17.x ]
16+
go-version: [ 1.16.x, 1.17.x ]
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Install Go
@@ -35,6 +35,7 @@ jobs:
3535
restore-keys: |
3636
${{ runner.os }}-go-cache
3737
- name: Restore base test coverage
38+
id: base-coverage
3839
if: matrix.go-version == '1.17.x'
3940
uses: actions/cache@v2
4041
with:
@@ -43,13 +44,13 @@ jobs:
4344
# Use base sha for PR or new commit hash for master/main push in test result key.
4445
key: ${{ runner.os }}-unit-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
4546
- name: Checkout base code
46-
if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
47+
if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
4748
uses: actions/checkout@v2
4849
with:
4950
ref: ${{ github.event.pull_request.base.sha }}
5051
path: __base
5152
- name: Run test for base code
52-
if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
53+
if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
5354
run: |
5455
cd __base
5556
make | grep test-unit && (make test-unit && go tool cover -func=./unit.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > ../unit-base.txt) || echo "No test-unit in base"
@@ -60,9 +61,7 @@ jobs:
6061
go tool cover -func=./unit.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > unit.txt
6162
OUTPUT=$(test -e unit-base.txt && (diff unit-base.txt unit.txt || exit 0) || cat unit.txt)
6263
echo "${OUTPUT}"
63-
OUTPUT="${OUTPUT//'%'/'%25'}"
64-
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
65-
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
64+
OUTPUT="${OUTPUT//$'\n'/%0A}"
6665
TOTAL=$(grep 'total:' unit.txt)
6766
echo "${TOTAL}"
6867
echo "::set-output name=diff::$OUTPUT"

0 commit comments

Comments
 (0)