Skip to content

Commit c50dfd6

Browse files
committed
test: improve workflows
Simplifies workflows and make use of a codecov upload token to ensure reliable pushing of coverage files to codecov.
1 parent 5df974b commit c50dfd6

File tree

4 files changed

+29
-69
lines changed

4 files changed

+29
-69
lines changed

.github/actions/go-test/action.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/test-and-release.yml renamed to .github/workflows/release.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test & release
1+
name: release
22

33
on:
44
push:
@@ -10,17 +10,7 @@ permissions:
1010
packages: write
1111

1212
jobs:
13-
test:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Check out repository
17-
uses: actions/[email protected]
18-
19-
- name: go test
20-
uses: ./.github/actions/go-test
21-
2213
release:
23-
needs: test
2414
runs-on: ubuntu-latest
2515
steps:
2616
- name: Checkout

.github/workflows/test-and-tag.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: test & tag
22

33
on:
4+
pull_request:
45
push:
5-
branches:
6-
- main
6+
tags-ignore:
7+
- "v*"
78

89
jobs:
910
test:
@@ -12,12 +13,35 @@ jobs:
1213
- name: Check out repository
1314
uses: actions/[email protected]
1415

15-
- name: go test
16-
uses: ./.github/actions/go-test
16+
- name: Set up go
17+
uses: actions/[email protected]
18+
with:
19+
# renovate: go-version
20+
go-version: 1.18.4
21+
22+
- name: Run go tests
23+
run: |
24+
go test ./... -race -covermode=atomic -coverprofile=coverage.out
25+
26+
- name: Upload coverage to Codecov
27+
uses: codecov/codecov-action@v3
28+
with:
29+
token: ${{ secrets.CODECOV_TOKEN }}
30+
files: coverage.out
31+
32+
# This builds the binary and starts it. If it does not exit within 3 seconds, consider it
33+
# successful
34+
#
35+
# With this, we prevent regressions like in 9c9e365c6ada93d94e90eae85704f14b8afaa4c9.
36+
- name: Verify binary works
37+
run: |
38+
make build
39+
API_URL=https://example.com/api timeout 3 ./backend || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
1740
1841
tag:
1942
runs-on: ubuntu-latest
2043
needs: test
44+
if: ${{ github.ref == 'refs/heads/main' }}
2145
container: ghcr.io/caarlos0/svu
2246
steps:
2347
- name: Checkout

.github/workflows/test.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)