Merge pull request #20 from altuslabsxyz/docs/add-v2 #104
This file contains hidden or 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
| # Continuous Integration Workflow | |
| # Runs tests, linting, and build checks on all code changes | |
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| pull_request: | |
| branches: | |
| - '**' | |
| workflow_dispatch: | |
| inputs: | |
| debug: | |
| description: 'Enable debug logging' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| # Cancel in-progress runs for the same branch | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| GO_VERSION_FILE: go.mod | |
| GOWORK: off | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: ${{ env.GO_VERSION_FILE }} | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Build | |
| run: go build -o /dev/null ./... | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: ${{ env.GO_VERSION_FILE }} | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run tests with race detection | |
| run: go test -p 1 -race -v ./... | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: ${{ env.GO_VERSION_FILE }} | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run golangci-lint | |
| uses: golangci/golangci-lint-action@v7 | |
| with: | |
| version: latest | |
| skip-cache: true | |
| args: --timeout=5m | |
| proto: | |
| name: Proto | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Needed for breaking change detection | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: ${{ env.GO_VERSION_FILE }} | |
| cache: true | |
| - name: Setup Buf | |
| uses: bufbuild/buf-setup-action@v1 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Lint protos | |
| run: buf lint | |
| - name: Check for breaking changes | |
| if: github.event_name == 'pull_request' | |
| env: | |
| BASE_REF: ${{ github.base_ref }} | |
| run: | | |
| git fetch origin $BASE_REF:$BASE_REF | |
| buf breaking --against ".git#branch=${BASE_REF}" | |
| - name: Verify generated code is up-to-date | |
| run: | | |
| buf generate | |
| if [ -n "$(git status --porcelain api/proto/gen)" ]; then | |
| echo "::error::Generated proto code is out of date. Run 'make proto' and commit." | |
| git diff api/proto/gen | |
| exit 1 | |
| fi | |
| ci-complete: | |
| name: CI Complete | |
| runs-on: ubuntu-latest | |
| needs: [build, test, lint, proto] | |
| if: always() | |
| steps: | |
| - name: Check results | |
| env: | |
| BUILD_RESULT: ${{ needs.build.result }} | |
| TEST_RESULT: ${{ needs.test.result }} | |
| LINT_RESULT: ${{ needs.lint.result }} | |
| PROTO_RESULT: ${{ needs.proto.result }} | |
| run: | | |
| if [ "$BUILD_RESULT" == "failure" ] || [ "$TEST_RESULT" == "failure" ] || [ "$LINT_RESULT" == "failure" ] || [ "$PROTO_RESULT" == "failure" ]; then | |
| echo "CI failed" | |
| exit 1 | |
| fi | |
| echo "CI passed" |