Fix tests and span length #21
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: Tests | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| actions: write | |
| packages: write | |
| jobs: | |
| unity: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| env: | |
| IMAGE_OPT: oci-mediatypes=true,compression=zstd,compression-level=20,force-compression=true | |
| PROJECT: /MedicineCI | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| UNITY_VERSION: [ | |
| # 2022.3 -- AFAIK 12f is the earliest version with functioning incremental source generators | |
| 2022.3.12f1, 2022.3.62f1, | |
| # 2023.2 | |
| 2023.2.0f1, 2023.2.20f1, | |
| # 6.0 | |
| 6000.0.0f1, 6000.0.55f1, | |
| # 6.1 | |
| 6000.1.0f1, 6000.1.16f1, | |
| # 6.2 | |
| 6000.2.0f1, | |
| # 6.3 | |
| 6000.3.0a3, | |
| ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prep vars | |
| run: | | |
| REPO='${{ github.repository }}' | |
| REPO_LC=$(echo "$REPO" | tr '[:upper:]' '[:lower:]') | |
| echo "REPO_LC=$REPO_LC" >> "$GITHUB_ENV" | |
| echo "IMAGE_TAG=ghcr.io/$REPO_LC/unity-ci:${{ github.sha }}-${{ matrix.UNITY_VERSION }}" >> "$GITHUB_ENV" | |
| echo "CACHE_REF=ghcr.io/$REPO_LC/unity-ci:cache-${{ matrix.UNITY_VERSION }}" >> "$GITHUB_ENV" | |
| - uses: docker/build-push-action@v6 | |
| env: | |
| DOCKER_BUILD_SUMMARY: false | |
| with: | |
| context: . | |
| file: ./.github/workflows/Dockerfile | |
| push: false | |
| tags: ${{ env.IMAGE_TAG }} | |
| build-args: | | |
| UNITY_VERSION=${{ matrix.UNITY_VERSION }} | |
| PROJECT=${{ env.PROJECT }} | |
| secrets: | | |
| unity_serial=${{ secrets.UNITY_SERIAL }} | |
| unity_user=${{ secrets.UNITY_USER }} | |
| unity_password=${{ secrets.UNITY_PASSWORD }} | |
| outputs: | | |
| type=docker | |
| cache-from: type=registry,ref=${{ env.CACHE_REF }} | |
| cache-to: type=registry,ref=${{ env.CACHE_REF }},mode=min | |
| - name: Prepare secrets and license dir | |
| run: | | |
| echo "::add-mask::${{ secrets.UNITY_SERIAL }}" | |
| echo "::add-mask::${{ secrets.UNITY_USER }}" | |
| masked="${{ secrets.UNITY_SERIAL }}" | |
| masked="${masked%????}XXXX" | |
| echo "::add-mask::$masked" | |
| echo "LIC_DIR=$RUNNER_TEMP/unity-lic" >> "$GITHUB_ENV" | |
| mkdir -p "$RUNNER_TEMP/unity-lic" | |
| mkdir -p "$RUNNER_TEMP/unity-secrets" | |
| install -m 600 /dev/null "$RUNNER_TEMP/unity-secrets/unity_serial" | |
| install -m 600 /dev/null "$RUNNER_TEMP/unity-secrets/unity_user" | |
| install -m 600 /dev/null "$RUNNER_TEMP/unity-secrets/unity_password" | |
| printf '%s' '${{ secrets.UNITY_SERIAL }}' > "$RUNNER_TEMP/unity-secrets/unity_serial" | |
| printf '%s' '${{ secrets.UNITY_USER }}' > "$RUNNER_TEMP/unity-secrets/unity_user" | |
| printf '%s' '${{ secrets.UNITY_PASSWORD }}' > "$RUNNER_TEMP/unity-secrets/unity_password" | |
| - name: Run tests | |
| run: | | |
| set -euo pipefail | |
| size_bytes=$(docker image inspect "${{ env.IMAGE_TAG }}" --format='{{.Size}}') | |
| size_mib=$(awk -v b="$size_bytes" 'BEGIN{printf "%.2f", b/1024/1024}') | |
| echo "Docker image size: ${size_mib} MiB" | |
| docker run --rm \ | |
| -v "$GITHUB_WORKSPACE:$PROJECT/Packages/Medicine/" \ | |
| -v "$RUNNER_TEMP/test-results:$PROJECT/test-results" \ | |
| -v "$LIC_DIR:/root/.local/share/unity3d" \ | |
| -v "$RUNNER_TEMP/unity-secrets:/run/secrets:ro" \ | |
| -w $PROJECT \ | |
| "${{ env.IMAGE_TAG }}" \ | |
| unity-editor \ | |
| -projectPath $PROJECT \ | |
| -executeMethod CI.RunTests | |
| - uses: dorny/test-reporter@v2 | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: Unity Test Results | |
| reporter: dotnet-nunit | |
| path: "${{ runner.temp }}/test-results/*tests.xml" | |
| fail-on-error: false |