| # reusable workflow |
| name: .test-unit |
| |
| # TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025 |
| |
| # Default to 'contents: read', which grants actions to read commits. |
| # |
| # If any permission is set, any permission not included in the list is |
| # implicitly set to "none". |
| # |
| # see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions |
| permissions: |
| contents: read |
| |
| on: |
| workflow_call: |
| |
| env: |
| GO_VERSION: "1.24.9" |
| GOTESTLIST_VERSION: v0.3.1 |
| TESTSTAT_VERSION: v0.1.25 |
| SETUP_BUILDX_VERSION: edge |
| SETUP_BUILDKIT_IMAGE: moby/buildkit:latest |
| |
| jobs: |
| unit: |
| runs-on: ubuntu-24.04 |
| timeout-minutes: 120 # guardrails timeout for the whole job |
| continue-on-error: ${{ github.event_name != 'pull_request' }} |
| strategy: |
| fail-fast: false |
| matrix: |
| mode: |
| - "" |
| - firewalld |
| steps: |
| - |
| name: Checkout |
| uses: actions/checkout@v4 |
| - |
| name: Set up runner |
| uses: ./.github/actions/setup-runner |
| - |
| name: Prepare |
| run: | |
| CACHE_DEV_SCOPE=dev |
| if [[ "${{ matrix.mode }}" == *"firewalld"* ]]; then |
| echo "FIREWALLD=true" >> $GITHUB_ENV |
| CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}firewalld" |
| fi |
| echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV |
| - |
| name: Set up Docker Buildx |
| uses: docker/setup-buildx-action@v3 |
| with: |
| version: ${{ env.SETUP_BUILDX_VERSION }} |
| driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }} |
| buildkitd-flags: --debug |
| - |
| name: Build dev image |
| uses: docker/bake-action@v6 |
| with: |
| targets: dev |
| set: | |
| dev.cache-from=type=gha,scope=${{ env.CACHE_DEV_SCOPE }} |
| - |
| name: Test |
| run: | |
| make -o build test-unit |
| - |
| name: Prepare reports |
| if: always() |
| run: | |
| mkdir -p bundles /tmp/reports |
| find bundles -type f \( -name '*-report.json' -o -name '*.log' -o -name '*.out' -o -name '*.prof' -o -name '*-report.xml' \) -print | xargs sudo tar -czf /tmp/reports.tar.gz |
| tar -xzf /tmp/reports.tar.gz -C /tmp/reports |
| sudo chown -R $(id -u):$(id -g) /tmp/reports |
| tree -nh /tmp/reports |
| - |
| name: Send to Codecov |
| uses: codecov/codecov-action@v4 |
| with: |
| directory: ./bundles |
| env_vars: RUNNER_OS |
| flags: unit |
| token: ${{ secrets.CODECOV_TOKEN }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533 |
| - |
| name: Upload reports |
| if: always() |
| uses: actions/upload-artifact@v4 |
| with: |
| name: test-reports-unit--${{ matrix.mode }} |
| path: /tmp/reports/* |
| retention-days: 1 |
| |
| unit-report: |
| runs-on: ubuntu-24.04 |
| timeout-minutes: 10 |
| continue-on-error: ${{ github.event_name != 'pull_request' }} |
| if: always() |
| needs: |
| - unit |
| steps: |
| - |
| name: Set up Go |
| uses: actions/setup-go@v5 |
| with: |
| go-version: ${{ env.GO_VERSION }} |
| cache: false |
| - |
| name: Download reports |
| uses: actions/download-artifact@v4 |
| with: |
| pattern: test-reports-unit-* |
| path: /tmp/reports |
| - |
| name: Install teststat |
| run: | |
| go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }} |
| - |
| name: Create summary |
| run: | |
| find /tmp/reports -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> $GITHUB_STEP_SUMMARY |