Skip to content

Prototype rhythm minigame #561

Prototype rhythm minigame

Prototype rhythm minigame #561

Workflow file for this run

name: Test
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: 'Test'
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/develop' || !contains(github.event.pull_request.body, '#no-test') }}
strategy:
fail-fast: false
matrix:
worker: [0, 1, 2, 3, 4, 5, 6, 7]
steps:
- uses: actions/checkout@v4
- name: Install vendor
run: ./install_vendor.sh ${{ secrets.vendor_url }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Install Ruby dependencies
run: bundle install
# PulseAudio does not work in Docker container
- name: Patch FMOD to disable sound
run: |
sed -i'' \
's/result = coreSystem.setOutput(outputType);/result = coreSystem.setOutput(FMOD.OUTPUTTYPE.NOSOUND);/' \
Assets/Plugins/FMOD/src/RuntimeManager.cs
- name: Cache Library
uses: actions/cache@v4
with:
path: Library
key: Library-${{ matrix.worker }}
- name: Get tests for the current worker
id: get_tests
run: |
tests=$(cat Assets/test/*.test.cs |
perl -ne 'm/public class (\w+) : ABaseTest/ && print "$1\n"' |
awk "NR % $WORKER_COUNT == $WORKER" |
paste -sd ';' -)
echo "tests=$tests" | tee -a $GITHUB_OUTPUT
env:
WORKER_COUNT: 8
WORKER: ${{ matrix.worker }}
- name: Run tests
id: tests
uses: 12joan/ci-unity-test-runner@main
continue-on-error: true
env:
# gh secret set UNITY_LICENSE < /Library/Application\ Support/Unity/Unity_lic.ulf
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
customParameters: -testFilter ${{ steps.get_tests.outputs.tests }}
# Caching Library may be causing an intermittent error "Unable to find
# type [UnityEngine.CoreModule.dll]". A symptom of this is that
# playmode-results.yml is never created. If this happens, delete Library
# and re-run the tests.
- name: Check if re-run is necessary
id: check_rerun
if: steps.tests.outcome == 'failure'
run: |
test -f artifacts/playmode-results.xml && exit 1
sudo rm -rf Library
- name: Re-run tests
if: steps.check_rerun.outcome == 'success'
uses: 12joan/ci-unity-test-runner@main
env:
# gh secret set UNITY_LICENSE < /Library/Application\ Support/Unity/Unity_lic.ulf
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
customParameters: -testFilter ${{ steps.get_tests.outputs.tests }}
- name: Report test results
if: always()
run: |
bundle exec ruby report_test_results.rb | tee -a results.txt
cat results.txt | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' >> $GITHUB_STEP_SUMMARY
- name: Upload Percy screenshots
uses: actions/upload-artifact@v4
with:
name: Percy (${{ matrix.worker }})
path: Percy
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: Test results (${{ matrix.worker }})
path: artifacts
percy:
name: 'Percy'
runs-on: ubuntu-latest
needs: test
if: ${{ github.ref == 'refs/heads/develop' || !contains(github.event.pull_request.body, '#no-percy') }}
steps:
- uses: actions/checkout@v4
- name: Install Yarn dependencies
run: yarn install
- name: Download screenshot artifacts
uses: actions/download-artifact@v4
with:
path: Percy
pattern: Percy (*)
merge-multiple: true
- name: Upload screenshots to Percy
run: yarn percy:upload
env:
# gh secret set PERCY_TOKEN <a Percy Web token>
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}