pipelines using mssql service #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload coverage to Codacy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
services: | |
sqlserver: | |
image: mcr.microsoft.com/mssql/server | |
env: | |
SA_PASSWORD: "test-psw" | |
ACCEPT_EULA: "Y" | |
ports: | |
- 1433:1433 | |
options: >- | |
--health-cmd "exit 0" | |
--health-interval 10s | |
--health-timeout 30s | |
--health-retries 5 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build solution | |
run: dotnet build --configuration Release --no-restore | |
- name: Run tests with coverage | |
env: | |
ConnectionStrings__DefaultConnection: "Server=localhost,1433;Database=master;User Id=sa;Password=test-psw;Trusted_Connection=False;MultipleActiveResultSets=true;" | |
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage/ --settings coverage.runsettings | |
- name: Upload coverage to Codacy | |
env: | |
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
run: | | |
COBERTURA_FILE=$(find . -name coverage.cobertura.xml) | |
if [ -z "$COBERTURA_FILE" ]; then | |
echo "Coverage report not found!" | |
exit 1 | |
fi | |
echo "Found coverage file at: ${COBERTURA_FILE}" | |
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r $COBERTURA_FILE |