feat(ci): Add GitHub Actions workflows for test automation and status badges

Add comprehensive test automation setup with GitHub Actions:
- Create test.yml for running tests on main/develop branches
- Add pr-test.yml for PR validation with test results comments
- Add update-badges.yml for dynamic test status badge updates
- Configure code coverage reporting with Codecov integration

Documentation:
- Add BADGE_SETUP.md with instructions for configuring test status badges
- Add WORKFLOWS_GUIDE.md explaining CI/CD workflow setup
- Update README.md with build and test status badges

Test Framework:
- Configure test project to use .NET 9.0
- Set up test coverage reporting with coverlet
- Add integration tests with WireMock for API mocking
- Add unit tests for configuration and HTTP client components
- Document testing strategy in TestingStrategy.md

Build:
- Add Dockerfile.test for containerized testing
- Update .gitignore for test artifacts
- Configure test dependencies in VRCAuthProxy.Tests.csproj

This change enables automated testing on PRs and branches, with visual status indicators and detailed test results in PR comments.
This commit is contained in:
MiscFrizzy 2025-04-07 06:30:31 -04:00
parent 23b5a504b5
commit 319f1071bf
18 changed files with 939 additions and 12 deletions

48
.github/workflows/pr-test.yml vendored Normal file
View file

@ -0,0 +1,48 @@
name: PR Tests
on:
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test with results
run: dotnet test --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --results-directory ./TestResults
- name: Test with coverage
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info
- name: Upload coverage report to PR
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: ./lcov.info
- name: Comment PR with test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: "**/TestResults/*.trx"
- name: Add Coverage PR Comment
uses: codecov/codecov-action@v3
with:
file: ./lcov.info
fail_ci_if_error: false
verbose: true

46
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,46 @@
name: Run Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test with coverage
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./lcov.info
fail_ci_if_error: false
- name: Create status badge
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.GIST_ID }}
filename: vrcauthproxy-tests.json
label: tests
message: passing
color: success

34
.github/workflows/update-badges.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: Update Badges
on:
workflow_run:
workflows: ["Run Tests"]
types:
- completed
workflow_dispatch:
jobs:
update-badges:
runs-on: ubuntu-latest
steps:
- name: Update test status badge - Success
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.GIST_ID }}
filename: vrcauthproxy-tests.json
label: tests
message: passing
color: success
- name: Update test status badge - Failure
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.GIST_ID }}
filename: vrcauthproxy-tests.json
label: tests
message: failing
color: critical