mirror of
https://github.com/ivuorinen/hiha-arvio.git
synced 2026-01-26 03:14:00 +00:00
- Add least-privilege permissions to all GitHub Actions jobs - Fixes 8 CodeQL security findings (actions/missing-workflow-permissions) - Build jobs: contents:read, actions:write - Release job: contents:write, actions:read - Test job: contents:read, checks:write, actions:write - Status jobs: no permissions needed - Add wasm-tools-net8 workload installation for test workflow Follows principle of least privilege and GitHub Actions security best practices.
55 lines
1.6 KiB
YAML
55 lines
1.6 KiB
YAML
name: Test
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
|
|
jobs:
|
|
test:
|
|
name: Run Tests
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
checks: write
|
|
actions: write
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
|
|
with:
|
|
dotnet-version: '8.0.x'
|
|
|
|
- name: Install WebAssembly Tools workload
|
|
run: dotnet workload install wasm-tools-net8
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore tests/HihaArvio.Tests/HihaArvio.Tests.csproj /p:TargetFrameworks=net8.0
|
|
|
|
- name: Build test project
|
|
run: dotnet build tests/HihaArvio.Tests/HihaArvio.Tests.csproj --configuration Release --no-restore /p:TargetFrameworks=net8.0
|
|
|
|
- name: Run tests
|
|
run: dotnet test tests/HihaArvio.Tests/HihaArvio.Tests.csproj --configuration Release --no-build --verbosity normal /p:TargetFrameworks=net8.0 --logger "trx;LogFileName=test-results.trx"
|
|
|
|
- name: Publish test results
|
|
uses: dorny/test-reporter@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3 # v2.1.1
|
|
if: always()
|
|
with:
|
|
name: Test Results
|
|
path: '**/test-results.trx'
|
|
reporter: dotnet-trx
|
|
fail-on-error: true
|
|
|
|
- name: Upload test results
|
|
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
if: always()
|
|
with:
|
|
name: test-results
|
|
path: '**/test-results.trx'
|
|
retention-days: 30
|