Improve unit test coverage for critical code paths #18
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: CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| permissions: | |
| contents: read | |
| # Cancel in-flight runs for the same branch/PR so pushes don't queue up. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ── Format / vet / tidy ────────────────────────────────────────────────────── | |
| check: | |
| name: Format / vet / tidy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Install Mage | |
| run: go install github.com/magefile/mage@v1.15.0 | |
| - name: Check formatting, vet, and module tidy | |
| run: mage dev:check | |
| # ── Unit tests ─────────────────────────────────────────────────────────────── | |
| unit: | |
| name: Unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Install Mage | |
| run: go install github.com/magefile/mage@v1.15.0 | |
| - name: Run unit tests | |
| run: mage test:unit | |
| - name: Coverage summary | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| if [ ! -f coverage.out ]; then exit 0; fi | |
| { | |
| echo "## Test coverage" | |
| echo '```' | |
| go tool cover -func=coverage.out | |
| echo '```' | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| # ── Puppet stack integration tests ────────────────────────────────────────── | |
| # Runs the full OpenVox 8 stack: Go CA (TLS) → OpenVox Server (WEBrick) → | |
| # OpenVoxDB. Requires docker compose and network access to pull base images | |
| # on first run. Same standard/FIPS matrix as the compose job. | |
| puppet: | |
| name: Puppet stack tests (${{ matrix.build }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - build: standard | |
| mage_target: test:puppet | |
| - build: fips | |
| mage_target: test:puppetFIPS | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Install Mage | |
| run: go install github.com/magefile/mage@v1.15.0 | |
| - name: Start rngd (replenish entropy pool for FIPS crypto) | |
| if: matrix.build == 'fips' | |
| run: sudo apt-get install -y --no-install-recommends rng-tools && sudo rngd -r /dev/urandom | |
| - name: Run Puppet stack integration tests | |
| env: | |
| MAGE_TARGET: ${{ matrix.mage_target }} | |
| run: mage "$MAGE_TARGET" | |
| # ── Compose integration tests (docker compose) ─────────────────────────────── | |
| # podman-compose is not pre-installed on GitHub runners; composeCmd() in | |
| # magefile.go falls back to `docker compose` (v2 plugin, always available). | |
| # Same standard/FIPS matrix as the unit test job above. | |
| compose: | |
| name: Compose integration tests (${{ matrix.build }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - build: standard | |
| mage_target: test:integCompose | |
| - build: fips | |
| mage_target: test:integComposeFIPS | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Install Mage | |
| run: go install github.com/magefile/mage@v1.15.0 | |
| - name: Start rngd (replenish entropy pool for FIPS crypto) | |
| if: matrix.build == 'fips' | |
| run: sudo apt-get install -y --no-install-recommends rng-tools && sudo rngd -r /dev/urandom | |
| - name: Run compose integration tests | |
| env: | |
| MAGE_TARGET: ${{ matrix.mage_target }} | |
| run: mage "$MAGE_TARGET" |