|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths-ignore: |
| 7 | + - '**.md' |
| 8 | + - 'docs/**' |
| 9 | + - '.gitignore' |
| 10 | + pull_request: |
| 11 | + branches: [main] |
| 12 | + paths-ignore: |
| 13 | + - '**.md' |
| 14 | + - 'docs/**' |
| 15 | + - '.gitignore' |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + |
| 24 | +defaults: |
| 25 | + run: |
| 26 | + shell: bash |
| 27 | + |
| 28 | +jobs: |
| 29 | + conventional-commits: |
| 30 | + name: Conventional Commits Check |
| 31 | + runs-on: ubuntu-latest |
| 32 | + timeout-minutes: 5 |
| 33 | + steps: |
| 34 | + - name: Conventional Commits |
| 35 | + uses: webiny/action-conventional-commits@7f91b1595ca1951cdb671ddc9f07a49081ec5b69 # v1.4.2 |
| 36 | + with: |
| 37 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + allowed-commit-types: "feat,fix,cicd,chore,patch,release,test,docs,refactor,ci,dev,perf,build,revert" |
| 39 | + |
| 40 | + lint: |
| 41 | + name: Lint |
| 42 | + runs-on: ubuntu-latest |
| 43 | + needs: conventional-commits |
| 44 | + timeout-minutes: 10 |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 47 | + with: |
| 48 | + fetch-depth: 1 |
| 49 | + persist-credentials: false |
| 50 | + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 |
| 51 | + with: |
| 52 | + go-version-file: go.mod |
| 53 | + cache: true |
| 54 | + - name: go vet |
| 55 | + run: go vet ./... |
| 56 | + - name: golangci-lint |
| 57 | + uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 |
| 58 | + with: |
| 59 | + version: v2.12.2 |
| 60 | + args: --timeout=5m |
| 61 | + skip-cache: true |
| 62 | + skip-save-cache: true |
| 63 | + env: |
| 64 | + GOPROXY: https://proxy.golang.org,direct |
| 65 | + |
| 66 | + test: |
| 67 | + name: Test |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: lint |
| 70 | + timeout-minutes: 10 |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 73 | + with: |
| 74 | + fetch-depth: 1 |
| 75 | + persist-credentials: false |
| 76 | + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 |
| 77 | + with: |
| 78 | + go-version-file: go.mod |
| 79 | + cache: true |
| 80 | + # The race detector requires cgo, so it is enabled here even though the |
| 81 | + # library itself needs none. The integration-build job below pins |
| 82 | + # CGO_ENABLED=0 to prove no cgo dependency creeps into the build. |
| 83 | + - name: Run tests |
| 84 | + env: |
| 85 | + CGO_ENABLED: '1' |
| 86 | + run: go test -race -cover -v ./... |
| 87 | + |
| 88 | + # Integration tests need a gVisor-capable host, which hosted runners are not. |
| 89 | + # Compiling them on every PR is what stops them rotting between the rare runs |
| 90 | + # on a self-hosted box — a test that no longer builds is a test nobody runs. |
| 91 | + integration-build: |
| 92 | + name: Integration Tests (compile only) |
| 93 | + runs-on: ubuntu-latest |
| 94 | + needs: lint |
| 95 | + timeout-minutes: 10 |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 98 | + with: |
| 99 | + fetch-depth: 1 |
| 100 | + persist-credentials: false |
| 101 | + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 |
| 102 | + with: |
| 103 | + go-version-file: go.mod |
| 104 | + cache: true |
| 105 | + - name: Compile integration tests |
| 106 | + env: |
| 107 | + CGO_ENABLED: '0' |
| 108 | + run: go build -tags integration ./... && go vet -tags integration ./... |
0 commit comments