Skip to content

use test matrix to test different go versions #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 58 additions & 49 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,59 +28,68 @@ jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
goversion: ["1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21"]
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Checkout code
uses: actions/checkout@v3
- name: Run tests
run: make test
- name: Convert coverage to lcov
uses: jandelgado/[email protected]
with:
infile: coverage.out
outfile: coverage.lcov
- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: coverage.lcov
- name: Install Go
if: success()
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- name: Checkout code
uses: actions/checkout@v3
- name: Run tests
run: |
go version
make test

build:
inttest:
runs-on: ubuntu-latest
needs: [lint, test]
strategy:
matrix:
buildversion: ["1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21"]
testversion: ["1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21"]
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Checkout code
uses: actions/checkout@v3
- name: build
run: |
export GO111MODULE=on
make build
- name: upload artifacts
uses: actions/upload-artifact@master
with:
name: bin
path: bin/
- name: Install Go
if: success()
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.buildversion }}
- name: Checkout code
uses: actions/checkout@v3
- name: Build binary for inttest
run: |
go version
GO111MODULE=on make build-linux
- name: Install Go
if: success()
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.testversion }}
- name: Integration test
run: |
go version
make inttest

inttest:
name: End-to-end integration test
needs: build
build:
runs-on: ubuntu-latest
needs: [lint, test, inttest]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download binaries from build stage
uses: actions/download-artifact@v1
with:
name: bin
- name: Run test
run: |
chmod 755 bin/*
make inttest
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: build
run: |
go version
make build-linux
make build-windows
make build-darwin
- name: upload artifacts
uses: actions/upload-artifact@master
with:
name: bin
path: bin/
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
# makefile for gcov2lcov
.PHONY: build test inttest clean
.PHONY: phony

build:
all: build-linux

phony:

build-linux: phony
GOOS=linux GOARCH=amd64 go build -o bin/gcov2lcov-linux-amd64 .

build-windows: phony
GOOS=windows GOARCH=amd64 go build -o bin/gcov2lcov-win-amd64 .

build-darwin: phony
GOOS=darwin GOARCH=amd64 go build -o bin/gcov2lcov-darwin-amd64 .

test:
test: phony
go test ./... -coverprofile coverage.out
go tool cover -func coverage.out

inttest:
inttest: phony
./bin/gcov2lcov-linux-amd64 -infile testdata/coverage.out -outfile coverage.lcov
diff -y testdata/coverage_expected.lcov coverage.lcov

clean:
clean: phony
rm -f bin/*