CI Refactor Docker container management to use Testcontainers #16
Workflow file for this run
This file contains hidden or 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: CI | |
| run-name: CI ${{ github.event.pull_request.title }} | |
| on: | |
| pull_request: | |
| concurrency: | |
| group: ci-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| discover-tests: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| test-projects: ${{ steps.find-tests.outputs.projects }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8 | |
| 9 | |
| 10 | |
| - name: Find test projects | |
| id: find-tests | |
| run: | | |
| # Use dotnet msbuild to evaluate and list test project references from traversal project | |
| dotnet msbuild ./all.csproj -p:BuildTestsOnly=true -t:Restore -v:q -nologo | |
| # Get the evaluated ProjectReference items using MSBuild | |
| projects=$(dotnet msbuild ./all.csproj -p:BuildTestsOnly=true -getItem:ProjectReference 2>/dev/null | \ | |
| grep -E "Include=" | \ | |
| sed -E 's/.*Include="([^"]+)".*/\1/' | \ | |
| jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| # Fallback: parse the glob pattern directly if getItem doesn't work | |
| if [ -z "$projects" ] || [ "$projects" == "[]" ]; then | |
| projects=$(ls -1 test/**/*Tests.csproj 2>/dev/null | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| fi | |
| echo "projects=$projects" >> $GITHUB_OUTPUT | |
| echo "Found test projects:" | |
| echo "$projects" | jq -r '.[]' | |
| shell: bash | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8 | |
| 9 | |
| 10 | |
| - name: Build projects | |
| run: dotnet build ./all.csproj | |
| shell: bash | |
| tests: | |
| needs: [discover-tests, build] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| project: ${{ fromJson(needs.discover-tests.outputs.test-projects) }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8 | |
| 9 | |
| 10 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-output | |
| - name: Docker Information | |
| run: | | |
| echo -e "\n\033[0;34mDocker System Info \033[0m" | |
| docker system info | |
| echo -e "\n\033[0;34mDocker Containers \033[0m" | |
| docker ps -a | |
| shell: bash | |
| - name: Run tests for ${{ matrix.project }} | |
| run: dotnet test ${{ matrix.project }} --no-build | |
| shell: bash |