Skip to content

Commit 5b3ae59

Browse files
authored
use test matrix to test different go versions (#14)
1 parent 4fcd32a commit 5b3ae59

File tree

2 files changed

+71
-55
lines changed

2 files changed

+71
-55
lines changed

.github/workflows/test_and_build.yml

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,59 +28,68 @@ jobs:
2828
2929
test:
3030
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
goversion: ["1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21"]
3134
steps:
32-
- name: Install Go
33-
if: success()
34-
uses: actions/setup-go@v4
35-
with:
36-
go-version: 1.20.x
37-
- name: Checkout code
38-
uses: actions/checkout@v3
39-
- name: Run tests
40-
run: make test
41-
- name: Convert coverage to lcov
42-
uses: jandelgado/[email protected]
43-
with:
44-
infile: coverage.out
45-
outfile: coverage.lcov
46-
- name: Coveralls
47-
uses: coverallsapp/[email protected]
48-
with:
49-
github-token: ${{ secrets.github_token }}
50-
path-to-lcov: coverage.lcov
35+
- name: Install Go
36+
if: success()
37+
uses: actions/setup-go@v4
38+
with:
39+
go-version: ${{ matrix.goversion }}
40+
- name: Checkout code
41+
uses: actions/checkout@v3
42+
- name: Run tests
43+
run: |
44+
go version
45+
make test
5146
52-
build:
47+
inttest:
5348
runs-on: ubuntu-latest
54-
needs: [lint, test]
49+
strategy:
50+
matrix:
51+
buildversion: ["1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21"]
52+
testversion: ["1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21"]
5553
steps:
56-
- name: Install Go
57-
uses: actions/setup-go@v4
58-
with:
59-
go-version: 1.20.x
60-
- name: Checkout code
61-
uses: actions/checkout@v3
62-
- name: build
63-
run: |
64-
export GO111MODULE=on
65-
make build
66-
- name: upload artifacts
67-
uses: actions/upload-artifact@master
68-
with:
69-
name: bin
70-
path: bin/
54+
- name: Install Go
55+
if: success()
56+
uses: actions/setup-go@v4
57+
with:
58+
go-version: ${{ matrix.buildversion }}
59+
- name: Checkout code
60+
uses: actions/checkout@v3
61+
- name: Build binary for inttest
62+
run: |
63+
go version
64+
GO111MODULE=on make build-linux
65+
- name: Install Go
66+
if: success()
67+
uses: actions/setup-go@v4
68+
with:
69+
go-version: ${{ matrix.testversion }}
70+
- name: Integration test
71+
run: |
72+
go version
73+
make inttest
7174
72-
inttest:
73-
name: End-to-end integration test
74-
needs: build
75+
build:
7576
runs-on: ubuntu-latest
77+
needs: [lint, test, inttest]
7678
steps:
77-
- name: Checkout code
78-
uses: actions/checkout@v2
79-
- name: Download binaries from build stage
80-
uses: actions/download-artifact@v1
81-
with:
82-
name: bin
83-
- name: Run test
84-
run: |
85-
chmod 755 bin/*
86-
make inttest
79+
- name: Checkout code
80+
uses: actions/checkout@v3
81+
- name: Install Go
82+
uses: actions/setup-go@v4
83+
with:
84+
go-version: 1.21
85+
- name: build
86+
run: |
87+
go version
88+
make build-linux
89+
make build-windows
90+
make build-darwin
91+
- name: upload artifacts
92+
uses: actions/upload-artifact@master
93+
with:
94+
name: bin
95+
path: bin/

Makefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
# makefile for gcov2lcov
2-
.PHONY: build test inttest clean
2+
.PHONY: phony
33

4-
build:
4+
all: build-linux
5+
6+
phony:
7+
8+
build-linux: phony
59
GOOS=linux GOARCH=amd64 go build -o bin/gcov2lcov-linux-amd64 .
10+
11+
build-windows: phony
612
GOOS=windows GOARCH=amd64 go build -o bin/gcov2lcov-win-amd64 .
13+
14+
build-darwin: phony
715
GOOS=darwin GOARCH=amd64 go build -o bin/gcov2lcov-darwin-amd64 .
816

9-
test:
17+
test: phony
1018
go test ./... -coverprofile coverage.out
1119
go tool cover -func coverage.out
1220

13-
inttest:
21+
inttest: phony
1422
./bin/gcov2lcov-linux-amd64 -infile testdata/coverage.out -outfile coverage.lcov
1523
diff -y testdata/coverage_expected.lcov coverage.lcov
1624

17-
clean:
25+
clean: phony
1826
rm -f bin/*
1927

20-

0 commit comments

Comments
 (0)