|
| 1 | +name: Build and Test PR |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + pull-requests: read |
| 10 | + actions: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: pull-request-ci-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + changes: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + # Expose matched filters as job 'src' output variable |
| 21 | + paths: ${{ steps.filter.outputs.changes }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + - name: Harden Runner |
| 25 | + uses: step-security/harden-runner@v2 |
| 26 | + with: |
| 27 | + disable-sudo: true |
| 28 | + egress-policy: block |
| 29 | + allowed-endpoints: > |
| 30 | + api.github.com:443 |
| 31 | + github.com:443 |
| 32 | + - uses: dorny/paths-filter@v3 |
| 33 | + id: filter |
| 34 | + with: |
| 35 | + filters: .github/filters.yml |
| 36 | + |
| 37 | + yamllint: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + needs: changes |
| 40 | + if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }} |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + - name: Validate YAML file |
| 44 | + run: yamllint templates |
| 45 | + |
| 46 | + go-build-test: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + needs: changes |
| 49 | + if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }} |
| 50 | + steps: |
| 51 | + - name: Harden Runner |
| 52 | + uses: step-security/harden-runner@v2 |
| 53 | + with: |
| 54 | + disable-sudo: true |
| 55 | + egress-policy: block |
| 56 | + allowed-endpoints: > |
| 57 | + api.github.com:443 |
| 58 | + github.com:443 |
| 59 | + golang.org:443 |
| 60 | + proxy.golang.org:443 |
| 61 | + sum.golang.org:443 |
| 62 | + objects.githubusercontent.com:443 |
| 63 | + storage.googleapis.com:443 |
| 64 | + cli.codecov.io:443 |
| 65 | + api.codecov.io:443 |
| 66 | + ingest.codecov.io:443 |
| 67 | + raw.githubusercontent.com:443 |
| 68 | +
|
| 69 | + - uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Set up Go |
| 72 | + uses: actions/setup-go@v5 |
| 73 | + with: |
| 74 | + go-version-file: 'go.mod' |
| 75 | + check-latest: true |
| 76 | + |
| 77 | + - name: Build |
| 78 | + run: make build |
| 79 | + |
| 80 | + - name: Check for generated diff |
| 81 | + run: make check-gen-diff |
| 82 | + |
| 83 | + - name: Test |
| 84 | + run: make test |
| 85 | + |
| 86 | + docker-build: |
| 87 | + runs-on: ubuntu-latest |
| 88 | + needs: changes |
| 89 | + if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }} |
| 90 | + steps: |
| 91 | + - name: Harden Runner |
| 92 | + uses: step-security/harden-runner@v2 |
| 93 | + with: |
| 94 | + disable-sudo: true |
| 95 | + egress-policy: block |
| 96 | + allowed-endpoints: > |
| 97 | + api.github.com:443 |
| 98 | + github.com:443 |
| 99 | + proxy.golang.org:443 |
| 100 | + sum.golang.org:443 |
| 101 | + go.dev:443 |
| 102 | + dl.google.com:443 |
| 103 | + golang.org:443 |
| 104 | + objects.githubusercontent.com:443 |
| 105 | + registry-1.docker.io:443 |
| 106 | + auth.docker.io:443 |
| 107 | + production.cloudflare.docker.com:443 |
| 108 | + gcr.io:443 |
| 109 | + storage.googleapis.com:443 |
| 110 | +
|
| 111 | + - uses: actions/checkout@v4 |
| 112 | + |
| 113 | + - name: Docker cache |
| 114 | + uses: ScribeMD/docker-cache@0.5.0 |
| 115 | + with: |
| 116 | + key: docker-${{ runner.os }}-${{ hashFiles('go.sum') }} |
| 117 | + |
| 118 | + - name: Build the Docker image |
| 119 | + run: make docker-build |
0 commit comments