Skip to content

Feature/net10

Feature/net10 #58

Workflow file for this run

name: Build
on:
pull_request:
branches: [master]
jobs:
ubuntu:
runs-on: ubuntu-latest
permissions:
checks: write
defaults:
run:
working-directory: src
services:
httpbin:
image: kennethreitz/httpbin:latest
ports:
- 8080:80
rabbitmq:
image: rabbitmq:3.13
env: { RABBITMQ_DEFAULT_USER: guest, RABBITMQ_DEFAULT_PASS: guest }
ports:
- 5672:5672
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install fonts
run: |
sudo apt-get update && sudo apt-get install -y fonts-noto fonts-dejavu-core
if [ ! -f "/usr/lib/x86_64-linux-gnu/libdl.so" ]; then
sudo ln -s /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so
fi
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
echo "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test (8.0)
run: dotnet test --no-restore --verbosity normal -f net8.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results8.trx"
- name: Upload test results (8.0)
uses: actions/upload-artifact@v4
with:
name: test-results-linux8
path: src/JfYu.UnitTests/TestResults/results8.trx
- name: Test (9.0)
run: dotnet test --no-restore --verbosity normal -f net9.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results9.trx"
- name: Upload test results (9.0)
uses: actions/upload-artifact@v4
with:
name: test-results-linux9
path: src/JfYu.UnitTests/TestResults/results9.trx
- name: Test (10.0)
run: dotnet test --no-restore --verbosity normal -f net10.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=opencover --logger "trx;LogFileName=results10.trx"
- name: Upload test results (10.0)
uses: actions/upload-artifact@v4
with:
name: test-results-linux10
path: src/JfYu.UnitTests/TestResults/results10.trx
- name: Upload coverage results (10.0)
uses: actions/upload-artifact@v4
with:
name: test-results-linux-coverage10
path: src/JfYu.UnitTests/TestResults/coverage.net10.0.opencover.xml
win:
runs-on: windows-latest
permissions:
checks: write
defaults:
run:
working-directory: src
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Setup services
shell: cmd
run: |
choco install redis-64 rabbitmq python -y
python -m pip install httpbin uvicorn asgiref
- name: Start httpbin and test
id: start-httpbin
shell: pwsh
run: |
$pyFile = "asgi_httpbin.py"
@"
from httpbin import app as wsgi_app
from asgiref.wsgi import WsgiToAsgi
app = WsgiToAsgi(wsgi_app)
"@ | Set-Content -Encoding UTF8 $pyFile
Write-Host "Created $pyFile"
$proc = Start-Process -FilePath "python" -ArgumentList @("-m","uvicorn","asgi_httpbin:app","--host","127.0.0.1","--port","8080") -NoNewWindow -PassThru
echo "HTTPBIN_PID=$($proc.Id)" >> $env:GITHUB_ENV
Write-Host "uvicorn httpbin started, PID: $($proc.Id)"
dotnet test --no-restore --verbosity normal -f net481 --logger "trx;LogFileName=results4.trx"
dotnet test --no-restore --verbosity normal -f net8.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results8.trx"
dotnet test --no-restore --verbosity normal -f net9.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results9.trx"
dotnet test --no-restore --verbosity normal -f net10.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results10.trx"
- name: Upload test results (4.81)
uses: actions/upload-artifact@v4
with:
name: test-results-win48
path: src/JfYu.UnitTests/TestResults/results4.trx
- name: Upload test results (8.0)
uses: actions/upload-artifact@v4
with:
name: test-results-win8
path: src/JfYu.UnitTests/TestResults/results8.trx
- name: Upload test results (9.0)
uses: actions/upload-artifact@v4
with:
name: test-results-win9
path: src/JfYu.UnitTests/TestResults/results9.trx
- name: Upload test results (10.0)
uses: actions/upload-artifact@v4
with:
name: test-results-win10
path: src/JfYu.UnitTests/TestResults/results10.trx
mac:
runs-on: macos-latest
permissions:
checks: write
defaults:
run:
working-directory: src
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Setup services
shell: bash
run: |
brew update
brew install redis rabbitmq
brew services start redis
brew services start rabbitmq
# Wait for Redis to be ready
for i in {1..30}; do
if redis-cli ping &> /dev/null; then
echo "Redis is ready"
break
fi
echo "Waiting for Redis to be ready... ($i/30)"
sleep 1
done
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install httpbin uvicorn asgiref
cat << 'EOF' > asgi_httpbin.py
from httpbin import app as wsgi_app
from asgiref.wsgi import WsgiToAsgi
app = WsgiToAsgi(wsgi_app)
EOF
echo "Created asgi_httpbin.py"
python -m uvicorn asgi_httpbin:app --host 127.0.0.1 --port 8080 &
HTTPBIN_PID=$!
echo "HTTPBIN_PID=$HTTPBIN_PID" >> $GITHUB_ENV
echo "uvicorn httpbin started, PID=$HTTPBIN_PID"
dotnet test --no-restore --verbosity normal -f net8.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results8.trx"
dotnet test --no-restore --verbosity normal -f net9.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results9.trx"
dotnet test --no-restore --verbosity normal -f net10.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results10.trx"
- name: Upload test results (8.0)
uses: actions/upload-artifact@v4
with:
name: test-results-mac8
path: src/JfYu.UnitTests/TestResults/results8.trx
- name: Upload test results (9.0)
uses: actions/upload-artifact@v4
with:
name: test-results-mac9
path: src/JfYu.UnitTests/TestResults/results9.trx
- name: Upload test results (10.0)
uses: actions/upload-artifact@v4
with:
name: test-results-mac10
path: src/JfYu.UnitTests/TestResults/results10.trx
sonarcloud:
needs: [win, ubuntu, mac]
runs-on: ubuntu-latest
defaults:
run:
working-directory: src
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download test results (win48)
uses: dawidd6/action-download-artifact@v9
with:
name: test-results-win48
path: TestResults
run_id: ${{ github.run_id }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Download test results (win10)
uses: dawidd6/action-download-artifact@v9
with:
name: test-results-win10
path: TestResults
run_id: ${{ github.run_id }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Download test results (coverage10)
uses: dawidd6/action-download-artifact@v9
with:
name: test-results-linux-coverage10
path: TestResults
run_id: ${{ github.run_id }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Install SonarScanner for .NET
run: dotnet tool install --global dotnet-sonarscanner
- name: SonarCloud Begin
run: |
dotnet sonarscanner begin \
/k:"jfwangncs_JfYu" \
/o:"jfwang" \
/d:sonar.login="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.cs.vstest.reportsPaths=../TestResults/*.trx \
/d:sonar.cs.opencover.reportsPaths=../TestResults/coverage.net10.0.opencover.xml
- name: Build
run: dotnet build --no-incremental
- name: SonarCloud End
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"