|
1 | | -name: Build project |
2 | | -on: [ push, pull_request ] |
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main, master] |
| 5 | + pull_request: |
| 6 | + branches: [main, master] |
| 7 | + merge_group: |
| 8 | + types: [checks_requested] |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + run_integration: |
| 12 | + description: 'Run integration tests' |
| 13 | + type: boolean |
| 14 | + default: true |
| 15 | + spec: |
| 16 | + description: 'Specific spec to test (e.g., 3.0/misc/stripe.com.yml)' |
| 17 | + type: string |
| 18 | + required: false |
| 19 | + max_concurrency: |
| 20 | + description: 'Max concurrency for integration tests' |
| 21 | + type: number |
| 22 | + default: 50 |
| 23 | + |
3 | 24 | jobs: |
4 | | - build: |
5 | | - name: Build |
| 25 | + build-ci: |
| 26 | + name: Build CI |
6 | 27 | runs-on: ubuntu-latest |
7 | | - strategy: |
8 | | - fail-fast: false |
9 | | - # perform matrix testing to give us an earlier insight into issues with different versions of supported major versions of Go |
10 | | - matrix: |
11 | | - version: |
12 | | - - "1.21" |
13 | | - - "1.22" |
14 | | - - "1.23" |
15 | | - - "1.24" |
16 | 28 | steps: |
17 | 29 | - name: Check out source code |
18 | 30 | uses: actions/checkout@v4 |
19 | 31 |
|
20 | 32 | - name: Set up Go |
21 | 33 | uses: actions/setup-go@v5 |
22 | 34 | with: |
23 | | - go-version: ${{ matrix.version }} |
| 35 | + go-version: "1.25.3" |
| 36 | + cache: true |
| 37 | + |
| 38 | + - name: Install gosec |
| 39 | + run: go install github.com/securego/gosec/v2/cmd/gosec@latest |
24 | 40 |
|
25 | | - - name: Test |
26 | | - run: make test |
27 | | - env: |
28 | | - # A combination of our GitHub Actions setup, with the Go toolchain, leads to inconsistencies in calling `go env`, in particular with Go 1.21, where having (the default) `GOTOOLCHAIN=auto` results in build failures |
29 | | - GOTOOLCHAIN: local |
| 41 | + - name: Download Go modules |
| 42 | + run: go mod download |
30 | 43 |
|
31 | | - - name: Build |
32 | | - run: go build ./cmd/oapi-codegen |
| 44 | + - name: Run build-ci |
| 45 | + run: make build-ci |
| 46 | + timeout-minutes: 30 |
33 | 47 |
|
34 | | - results: |
35 | | - if: ${{ always() }} |
| 48 | + test-ci: |
| 49 | + name: Test CI |
36 | 50 | runs-on: ubuntu-latest |
37 | | - name: Check build results |
38 | | - needs: [build] |
39 | 51 | steps: |
40 | | - - run: | |
41 | | - result="${{ needs.build.result }}" |
42 | | - if [[ $result == "success" || $result == "skipped" ]]; then |
43 | | - exit 0 |
44 | | - else |
| 52 | + - name: Check out source code |
| 53 | + uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Set up Go |
| 56 | + uses: actions/setup-go@v5 |
| 57 | + with: |
| 58 | + go-version: "1.25.3" |
| 59 | + cache: true |
| 60 | + |
| 61 | + - name: Download Go modules |
| 62 | + run: go mod download |
| 63 | + |
| 64 | + - name: Run generate and check for uncommitted changes |
| 65 | + run: | |
| 66 | + make generate |
| 67 | + if ! git diff --exit-code; then |
| 68 | + echo "ERROR: make generate produced uncommitted changes" |
| 69 | + echo "Please run 'make generate' locally and commit the changes" |
45 | 70 | exit 1 |
46 | 71 | fi |
| 72 | +
|
| 73 | + - name: Run test-ci |
| 74 | + run: make test-ci |
| 75 | + |
| 76 | + integration-tests: |
| 77 | + name: Integration Tests |
| 78 | + runs-on: ubuntu-latest |
| 79 | + # Run on: merge_group (merge queue), push to main, or manual trigger with run_integration=true |
| 80 | + if: github.event_name == 'merge_group' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.run_integration) |
| 81 | + steps: |
| 82 | + - name: Check out source code |
| 83 | + uses: actions/checkout@v4 |
| 84 | + |
| 85 | + - name: Set up Go |
| 86 | + uses: actions/setup-go@v5 |
| 87 | + with: |
| 88 | + go-version: "1.25.3" |
| 89 | + cache: true |
| 90 | + |
| 91 | + - name: Download Go modules |
| 92 | + run: go mod download |
| 93 | + |
| 94 | + - name: Fetch specs |
| 95 | + run: make fetch-specs |
| 96 | + |
| 97 | + - name: Run integration tests |
| 98 | + run: | |
| 99 | + if [ -n "${{ inputs.spec }}" ]; then |
| 100 | + make test-integration SPEC="${{ inputs.spec }}" |
| 101 | + else |
| 102 | + INTEGRATION_MAX_CONCURRENCY=${{ inputs.max_concurrency }} go test -v -tags=integration -count=1 -timeout=60m . |
| 103 | + fi |
| 104 | + timeout-minutes: 65 |
0 commit comments