Add github job to run tests

This commit is contained in:
eelke 2026-02-22 09:39:43 +01:00
parent ad2e952125
commit 72dbc5acbf

70
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,70 @@
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Cache Docker image (postgres)
id: docker-cache
uses: actions/cache@v4
with:
path: /tmp/docker-postgres.tar
key: ${{ runner.os }}-docker-postgres-18.1
- name: Load cached postgres image or pull
run: |
if [ -f /tmp/docker-postgres.tar ]; then
docker load -i /tmp/docker-postgres.tar
else
docker pull postgres:18.1
docker save postgres:18.1 -o /tmp/docker-postgres.tar
fi
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test with coverage
run: |
dotnet test --no-build --configuration Release \
--collect:"XPlat Code Coverage" \
--results-directory ./coverage \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
directory: ./coverage
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ./coverage/**/coverage.cobertura.xml
retention-days: 7