From 72dbc5acbf63de7c98bf9dcc05841b6fd56dd46b Mon Sep 17 00:00:00 2001 From: eelke Date: Sun, 22 Feb 2026 09:39:43 +0100 Subject: [PATCH] Add github job to run tests --- .github/workflows/ci.yml | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d51bc52 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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