2020-07-18 22:06:45 +02:00
|
|
|
#Continuous integration action
|
2020-07-26 22:30:14 +02:00
|
|
|
# largely inspired by https://brunopaz.dev/blog/building-a-basic-ci-cd-pipeline-for-a-golang-application-using-github-actions
|
|
|
|
name: Build & Test
|
2020-07-18 21:27:57 +02:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- '*'
|
2020-07-26 22:30:14 +02:00
|
|
|
|
2020-07-18 21:27:57 +02:00
|
|
|
jobs:
|
2020-07-26 22:30:14 +02:00
|
|
|
lint:
|
|
|
|
name: Lint
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Set up Go
|
2023-03-16 15:13:44 +01:00
|
|
|
uses: actions/setup-go@v4
|
2020-07-26 22:30:14 +02:00
|
|
|
with:
|
2023-02-08 22:07:33 +01:00
|
|
|
go-version: '^1.19.5'
|
2020-07-26 22:30:14 +02:00
|
|
|
|
|
|
|
- name: Check out code
|
2023-11-14 10:57:25 +01:00
|
|
|
uses: actions/checkout@v4
|
2020-07-26 22:30:14 +02:00
|
|
|
|
2023-02-10 17:45:10 +01:00
|
|
|
- name: Lint Go Code with golangci-lint
|
|
|
|
uses: golangci/golangci-lint-action@v3
|
|
|
|
|
2020-08-11 16:36:40 +02:00
|
|
|
- name: Vet Go Code
|
|
|
|
run: |
|
|
|
|
make vet
|
2020-07-26 22:30:14 +02:00
|
|
|
|
|
|
|
test:
|
|
|
|
name: Test
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Set up Go
|
2023-03-16 15:13:44 +01:00
|
|
|
uses: actions/setup-go@v4
|
2020-07-26 22:30:14 +02:00
|
|
|
with:
|
2023-02-08 22:07:33 +01:00
|
|
|
go-version: '^1.19.5'
|
2020-07-26 22:30:14 +02:00
|
|
|
|
|
|
|
- name: Check out code
|
2023-11-14 10:57:25 +01:00
|
|
|
uses: actions/checkout@v4
|
2020-07-26 22:30:14 +02:00
|
|
|
|
|
|
|
- name: Run Unit tests.
|
|
|
|
run: |
|
2020-08-11 16:36:40 +02:00
|
|
|
make test-coverage
|
2020-07-26 22:30:14 +02:00
|
|
|
|
|
|
|
- name: Upload Coverage report to CodeCov
|
2023-05-16 16:04:44 +02:00
|
|
|
uses: codecov/codecov-action@v3.1.4
|
2020-07-26 22:30:14 +02:00
|
|
|
with:
|
|
|
|
token: ${{secrets.CODECOV_TOKEN}}
|
|
|
|
file: ./coverage.txt
|
|
|
|
|
|
|
|
|
2020-07-18 21:27:57 +02:00
|
|
|
build:
|
2020-07-26 22:30:14 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Build and Integration tests
|
|
|
|
needs: [lint, test]
|
2020-07-18 21:27:57 +02:00
|
|
|
steps:
|
2023-11-14 10:57:25 +01:00
|
|
|
- uses: actions/checkout@v4
|
2023-03-16 15:13:44 +01:00
|
|
|
- uses: actions/setup-go@v4
|
2020-07-18 21:27:57 +02:00
|
|
|
with:
|
2023-02-08 22:07:33 +01:00
|
|
|
go-version: '^1.19.5'
|
2020-07-18 21:27:57 +02:00
|
|
|
- run: go mod download
|
2020-07-26 22:30:14 +02:00
|
|
|
- name: Validates GO releaser config
|
2023-11-14 11:00:12 +01:00
|
|
|
uses: goreleaser/goreleaser-action@v5
|
2020-07-26 22:30:14 +02:00
|
|
|
with:
|
2023-02-08 22:07:33 +01:00
|
|
|
distribution: goreleaser
|
2020-07-26 22:30:14 +02:00
|
|
|
args: check
|
2020-07-18 21:27:57 +02:00
|
|
|
- name: Run GoReleaser
|
2023-11-14 11:00:12 +01:00
|
|
|
uses: goreleaser/goreleaser-action@v5
|
2020-07-18 21:27:57 +02:00
|
|
|
with:
|
2023-02-08 22:07:33 +01:00
|
|
|
distribution: goreleaser
|
|
|
|
args: release --snapshot --skip-publish --clean
|
2020-08-12 18:10:23 +02:00
|
|
|
- name: Setup BATS
|
|
|
|
run: test/install-bats.sh
|
|
|
|
- name: Run End-To_end testing with the docker container
|
|
|
|
run: test/bats/bin/bats test/bats-scripts
|
2020-07-26 22:30:14 +02:00
|
|
|
|