|
| 1 | +name: test |
| 2 | + |
| 3 | +# Runs the test suite (with the >=85% line+branch coverage gate enforced inside |
| 4 | +# the Docker `test` stage) and the infrastructure conformance checks. The Docker |
| 5 | +# build fails on any test or coverage-gate failure, so coverage is enforced |
| 6 | +# independently of Codecov. |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - "master" |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + conformance: |
| 19 | + name: Infra conformance checks |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v6 |
| 24 | + |
| 25 | + - name: Assert .NET target framework and Functions version |
| 26 | + run: | |
| 27 | + grep -q '<TargetFramework>net10.0</TargetFramework>' SoundButtons/SoundButtons.csproj |
| 28 | + grep -q '<AzureFunctionsVersion>v4</AzureFunctionsVersion>' SoundButtons/SoundButtons.csproj |
| 29 | +
|
| 30 | + - name: Assert Dockerfile image and tool pins |
| 31 | + run: | |
| 32 | + # .NET 10 base/build/sdk images |
| 33 | + grep -Eq 'mcr\.microsoft\.com/dotnet/sdk:10\.0' Dockerfile |
| 34 | + # ffmpeg pinned to 8.1 |
| 35 | + grep -q 'static-ffmpeg-upx:8.1' Dockerfile |
| 36 | + # dumb-init pinned to v1.2.5 with checksum verification |
| 37 | + grep -q 'dumb-init/releases/download/v1.2.5/' Dockerfile |
| 38 | + grep -q 'sha256sum -c -' Dockerfile |
| 39 | +
|
| 40 | + - name: Assert container init process (dumb-init PID 1) |
| 41 | + run: | |
| 42 | + grep -q 'ENTRYPOINT \[ "dumb-init"' Dockerfile |
| 43 | + grep -q 'STOPSIGNAL SIGINT' Dockerfile |
| 44 | + # dumb-init must come from the dedicated checksum-verified `download` stage, |
| 45 | + # not be bundled with the ffmpeg image, and must not run with --single-child. |
| 46 | + grep -q 'COPY .*--from=download /dumb-init' Dockerfile |
| 47 | + ! grep -q 'single-child' Dockerfile |
| 48 | +
|
| 49 | + - name: Lint Dockerfile (hadolint) |
| 50 | + uses: hadolint/hadolint-action@v3.1.0 |
| 51 | + with: |
| 52 | + dockerfile: Dockerfile |
| 53 | + |
| 54 | + - name: Set up Helm |
| 55 | + uses: azure/setup-helm@v4 |
| 56 | + |
| 57 | + - name: Assert Kubernetes automountServiceAccountToken disabled by default |
| 58 | + run: | |
| 59 | + helm template helm | grep -q 'automountServiceAccountToken: false' |
| 60 | +
|
| 61 | + test: |
| 62 | + name: Test suite + coverage |
| 63 | + runs-on: ubuntu-latest |
| 64 | + permissions: |
| 65 | + contents: read |
| 66 | + env: |
| 67 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 68 | + steps: |
| 69 | + - name: Checkout |
| 70 | + uses: actions/checkout@v6 |
| 71 | + with: |
| 72 | + submodules: true |
| 73 | + |
| 74 | + - name: Set up Docker Buildx |
| 75 | + uses: docker/setup-buildx-action@v4 |
| 76 | + |
| 77 | + # The `test` stage runs the suite and enforces the >=85% line+branch gate; |
| 78 | + # the build fails here on any test or coverage failure. The `report` stage |
| 79 | + # exports the Cobertura XML + TRX for Codecov. |
| 80 | + - name: Run tests and export coverage report |
| 81 | + run: | |
| 82 | + docker build --target report --output type=local,dest=./out -f Dockerfile . |
| 83 | +
|
| 84 | + # The design requires CI to confirm the production image still builds; the |
| 85 | + # test/report stages are off the production path, so build `final` explicitly. |
| 86 | + - name: Build production image (final stage) |
| 87 | + run: | |
| 88 | + docker build --target final -t soundbuttons-final-ci -f Dockerfile . |
| 89 | +
|
| 90 | + - name: Upload coverage to Codecov |
| 91 | + if: ${{ env.CODECOV_TOKEN != '' }} |
| 92 | + uses: codecov/codecov-action@v5 |
| 93 | + with: |
| 94 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 95 | + files: ./out/testresults/coverage.cobertura.xml |
| 96 | + fail_ci_if_error: false |
0 commit comments