ci: Run validation job on Linux, macOS, Windows #1179
Workflow file for this run
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
| name: pr | |
| on: [pull_request] | |
| permissions: {} | |
| env: | |
| IMAGE: openpolicyagent/conftest | |
| PLATFORMS: linux/amd64,linux/arm64 | |
| jobs: | |
| style: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout all PR branch and commits | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: ${{ github.event.pull_request.commits }} | |
| - name: setup go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: "1.25.x" | |
| cache: false | |
| - name: validate conventional commit prefix | |
| working-directory: scripts | |
| run: ./validate-conventional-commit-prefix.sh | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v8 | |
| with: | |
| args: --timeout=5m --color=always --max-same-issues=0 --max-issues-per-linter=0 | |
| - name: setup regal | |
| uses: StyraInc/setup-regal@v1 | |
| with: | |
| version: v0.30 | |
| - name: lint examples - warnings | |
| continue-on-error: true # Regal returns non-zero even with fail-level set to warning. | |
| run: >- | |
| regal lint | |
| examples | |
| --disable directory-package-mismatch | |
| --disable unresolved-import | |
| --format github | |
| - name: lint examples - blocking | |
| run: >- | |
| regal lint | |
| examples | |
| --disable-all | |
| --enable-category bugs | |
| --format github | |
| validate: | |
| strategy: | |
| matrix: | |
| os: | |
| - 'ubuntu-latest' | |
| - 'macos-latest' | |
| - 'windows-latest' | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: checkout source | |
| uses: actions/checkout@v5 | |
| - name: setup go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: "1.25.x" | |
| cache: false | |
| - name: build | |
| run: make build | |
| - name: unit test | |
| run: make test | |
| # Ensure Actions runner has Python installed | |
| # This is required for pre-commit tests to work | |
| - name: setup python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.13' | |
| cache: 'pip' | |
| - name: setup bats | |
| uses: bats-core/[email protected] | |
| with: | |
| # Pin bats version to fix CI issue: https://github.com/bats-core/bats-action/pull/4 | |
| bats-version: "1.10.0" | |
| support-install: false | |
| assert-install: false | |
| detik-install: false | |
| file-install: false | |
| - name: test examples (nix) | |
| if: ${{ matrix.os != 'windows-latest' }} | |
| run: make test-examples | |
| - name: test examples (windows) | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| run: | | |
| $env:Path += ";C:\Users\runneradmin\.local\share\bats\bin" | |
| make test-examples | |
| - name: acceptance (nix) | |
| if: ${{ matrix.os != 'windows-latest' }} | |
| run: make test-acceptance | |
| # TODO: Uncomment as a part of https://github.com/open-policy-agent/conftest/issues/1203 | |
| # - name: acceptance (windows) | |
| # if: ${{ matrix.os == 'windows-latest' }} | |
| # run: | | |
| # $env:Path += ";C:\Users\runneradmin\.local\share\bats\bin" | |
| # make test-acceptance | |
| - name: test oci push/pull | |
| run: ./scripts/push-pull-e2e.sh | |
| docker-conftest: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - validate | |
| steps: | |
| - name: checkout source | |
| uses: actions/checkout@v5 | |
| - name: setup docker buildx | |
| run: docker buildx create --name conftestbuild --use | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: false | |
| # The foo tag below validates putting one tag per line (like we do in the release flow) | |
| # works as expected. | |
| tags: | | |
| ${{ env.IMAGE }}:latest | |
| ${{ env.IMAGE }}:foo | |
| platforms: ${{ env.PLATFORMS }} | |
| docker-examples: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - validate | |
| steps: | |
| - name: checkout source | |
| uses: actions/checkout@v5 | |
| - name: setup docker buildx | |
| run: docker buildx create --name conftestbuild --use | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| target: examples | |
| push: false | |
| tags: ${{ env.IMAGE }}:examples | |
| platforms: ${{ env.PLATFORMS }} |