ci: don't use test results #35
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: Unity Tests | |
on: | |
push: | |
branches: # Only run jobs if files changed on this branch | |
- master | |
paths: # Only run jobs if files changed at these paths | |
- '.github/workflows/**' | |
- 'Assets/**' | |
- 'Packages/**' | |
- 'ProjectSettings/**' | |
- 'ci/**' | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
jobs: | |
# Run the Unity tests | |
tests: | |
name: Run ${{ matrix.unity-version }} tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
unity-version: | |
- 2021.3.34f1 | |
- 2022.1.24f1 | |
- 2022.2.21f1 | |
- 2022.3.17f1 | |
- 2023.1.20f1 | |
- 2023.2.5f1 | |
steps: | |
# Checkout the repo | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
lfs: true | |
fetch-depth: 0 | |
# Cache library folder for faster tests | |
- name: Cache library | |
uses: actions/[email protected] | |
with: | |
path: Library | |
key: Library-${{ matrix.unity-version }} | |
restore-keys: | | |
Library- | |
# Run tests | |
- name: Run tests | |
uses: game-ci/unity-test-runner@v4 | |
id: tests | |
with: | |
unityVersion: ${{ matrix.unity-version }} | |
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+Hertzole.ScriptableValues' | |
# Upload test results | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: Test results - ${{ matrix.unity-version }} | |
path: ${{ steps.tests.outputs.artifactsPath }} | |
# Upload coverage results | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: Coverage results - ${{ matrix.unity-version }} | |
path: ${{ steps.tests.outputs.coveragePath }} | |
sonarscan: | |
needs: [tests] | |
name: SonarScan | |
runs-on: ubuntu-latest | |
container: unityci/editor:ubuntu-2021.3.34f1-base-3.0.1 | |
steps: | |
- name: Activate Unity | |
continue-on-error: true | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
run: | | |
echo "$UNITY_LICENSE" | tr -d '\r' > License.ulf | |
unity-editor -nographics -logFile /dev/stdout -manualLicenseFile License.ulf -quit | |
- name: Checkout repository | |
uses: actions/[email protected] | |
with: | |
lfs: true | |
fetch-depth: 0 | |
- name: Cache library | |
uses: actions/[email protected] | |
with: | |
path: Library | |
key: Library-Scanner | |
restore-keys: | | |
Library-Scanner | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.x | |
- name: Install Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Install scanner | |
run: dotnet tool install dotnet-sonarscanner --tool-path . --version 6.0.0 | |
- name: Generate Solution | |
run: unity-editor -nographics -logFile /dev/stdout -customBuildName scriptable-values -projectPath . -executeMethod GitTools.Solution.Sync -quit | |
# Get the coverage results from the artifacts | |
- name: Get test reports | |
uses: actions/download-artifact@v4 | |
with: | |
name: Test results - 2021.3.34f1 | |
path: Tests | |
# Get the test coverage results from the artifacts | |
- name: Get test coverage | |
uses: actions/download-artifact@v4 | |
with: | |
name: Coverage results - 2021.3.34f1 | |
path: Coverage | |
# The test results have a different path than what SonarQube can read. | |
# We need to remove the github/workspace/ path. | |
- name: Fix paths | |
run: | | |
chmod +x ./ci/fix_paths.sh | |
./ci/fix_paths.sh Coverage | |
# For now, just upload the fixed paths | |
- name: Upload fixed paths | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Fixed paths | |
path: Coverage | |
- name: SonarQube analysis | |
env: | |
FrameworkPathOverride: /opt/unity/Editor/Data/MonoBleedingEdge/ | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
./dotnet-sonarscanner begin \ | |
/o:"hertzole" \ | |
/k:"scriptable-values" \ | |
/d:sonar.host.url=https://sonarcloud.io \ | |
/d:sonar.verbose=true \ | |
/d:sonar.token=$SONAR_TOKEN \ | |
/d:sonar.cs.opencover.reportsPaths=Coverage/workspace-opencov/**.xml | |
dotnet build scriptable-values.sln | |
./dotnet-sonarscanner end /d:sonar.token=$SONAR_TOKEN |