Skip to content

Add CI/CD pipeline

Add CI/CD pipeline #14

Workflow file for this run

name: AppRating Build, Test & Publish
on:
push:
branches: [ main ]
tags-ignore: [ "*-v*" ]
paths:
- "backend/**"
pull_request:
branches: [ main ]
paths:
- "backend/**"
workflow_dispatch:
jobs:
ci:
name: Build, Test & Publish
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./publisher
env:
DOTNET_VERSION: 8.0.100
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore
run: dotnet restore
- name: Check formatting
run: dotnet csharpier . --check
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet msbuild /t:RunTests /p:Configuration=Release /p:LogFileName=$PWD/../TestResults/tests.trx
working-directory: ./tests
- name: Integration test
run: >
dotnet test
./tests/LeanCode.AppRating.IntegrationTests/LeanCode.AppRating.IntegrationTests.csproj
--no-build
--collect "XPlat Code Coverage"
--settings test/coverlet.runsettings
--logger "trx;LogFileName=LeanCode.AppRating.IntegrationTests.trx"
--results-directory TestResults
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: publisher_test_results.zip
path: backend/TestResults/*.trx
publish-test-results:
name: Publish Tests Results
needs: ci
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
pull-requests: write
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Extract Artifacts
run: |
for file in artifacts/*.zip; do
if [[ -f "$file" ]]; then
dir="${file%.zip}"
mkdir -p "$dir"
unzip -d "$dir" "$file"
fi
done
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
trx_files: "artifacts/*/**/*.trx"