fix test #334
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This GitHub action runs your tests for each commit push and/or PR. Optionally | |
# you can turn it on using a cron schedule for regular testing. | |
# | |
name: CI | |
permissions: read-all | |
on: | |
pull_request: | |
branches: | |
- main | |
- feature/convert-resource-object | |
paths-ignore: | |
- 'README.md' | |
push: | |
paths-ignore: | |
- 'README.md' | |
branches: | |
- main | |
- feature/convert-resource-object | |
# Ensures only 1 action runs per PR and previous is canceled on new trigger | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
id: go | |
- name: go env | |
run: echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- name: Get dependencies | |
run: | | |
go mod download | |
- name: Build | |
run: | | |
make build | |
generate: | |
name: Test docs up-to-date | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v3 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: make docs | |
- name: git diff | |
run: | | |
git diff --compact-summary --exit-code || \ | |
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1) | |
tests-unit: | |
name: Unit Tests | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
id: go | |
- name: go env | |
run: echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- name: Get dependencies | |
run: | | |
go mod download | |
- name: Check formatting | |
timeout-minutes: 10 | |
run: | | |
make fmtcheck | |
- name: Run golangci-lint | |
timeout-minutes: 10 | |
run: | | |
make lint | |
- name: Run gosec | |
run: | | |
make sec | |
- name: Tests | |
timeout-minutes: 10 | |
run: | | |
make test | |
- name: Send coverage | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: "./test_results/coverage.out" | |
flag-name: tests | |
parallel: true | |
tests-acceptance: | |
name: Matrix Acceptance Tests | |
needs: build | |
runs-on: ubuntu-latest | |
if: "!github.event.pull_request.head.repo.fork" | |
timeout-minutes: 15 | |
strategy: | |
fail-fast: false | |
matrix: | |
terraform: | |
- '1.3.*' | |
- 'latest' | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
id: go | |
- uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: ${{ matrix.terraform }} | |
terraform_wrapper: false | |
- name: go env | |
run: echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- name: Get dependencies | |
run: | | |
go mod download | |
- name: Acceptance tests | |
timeout-minutes: 10 | |
env: | |
TWINGATE_URL: ${{ secrets.TWINGATE_URL }} | |
TWINGATE_NETWORK: ${{ secrets.TWINGATE_NETWORK }} | |
TWINGATE_API_TOKEN: ${{ secrets.TWINGATE_API_TOKEN }} | |
TEST_UNIQUE_VALUE: ${{ github.run_id }}-${{ github.run_number }}-${{ matrix.terraform }} | |
run: | | |
make testacc | |
- name: Send coverage | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: "./test_results/coverage.out" | |
flag-name: tests-acc-${{ matrix.terraform }} | |
parallel: true | |
cleanup: | |
name: Cleanup | |
if: "!github.event.pull_request.head.repo.fork" | |
needs: tests-acceptance | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
id: go | |
- name: go env | |
run: echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- name: Get dependencies | |
run: | | |
go mod download | |
- name: Run sweepers | |
timeout-minutes: 10 | |
env: | |
TWINGATE_URL: ${{ secrets.TWINGATE_URL }} | |
TWINGATE_NETWORK: ${{ secrets.TWINGATE_NETWORK }} | |
TWINGATE_API_TOKEN: ${{ secrets.TWINGATE_API_TOKEN }} | |
TEST_UNIQUE_VALUE: ${{ github.run_id }}-${{ github.run_number }} | |
run: | | |
make sweep | |
# notifies that all test jobs are finished. | |
finish: | |
name: "CI Finished" | |
needs: [tests-unit, tests-acceptance, cleanup] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: shogo82148/actions-goveralls@v1 | |
with: | |
parallel-finished: true |