Skip to content

chore: add GitHub Actions #2

chore: add GitHub Actions

chore: add GitHub Actions #2

name: Test with code coverage
on:
push:
branches:
- '**'
env:
DOTNET_INSTALL_DIR: "./.dotnet"
jobs:
test:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.100
- name: chown
run: |
sudo chown -R $USER:$USER /home/runneradmin
- name: Install dependencies
run: dotnet restore test/RandomContract.Tests.csproj --verbosity quiet
- name: Build
run: dotnet build test/RandomContract.Tests.csproj --no-restore /clp:ErrorsOnly /p:GeneratePackageOnBuild=false --verbosity quiet
- name: Test
run: |
for name in `ls ./test/*.Tests.csproj | awk '{print $NF}'`;
do
dotnet test ${name} --no-restore --no-build --logger trx --settings CodeCoverage.runsettings --results-directory coverage --collect:"XPlat Code Coverage"
done
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: coverage/*/coverage.cobertura.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}