diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..429c8fb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,96 @@ +# Secrets +# UNITY_LICENSE: +name: test + +on: + push: + branches: + - develop + tags: + - "!*" + pull_request: + types: + - opened + - synchronize + +jobs: + unity-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + unityVersion: [ + "2018.3.14f1", + "2018.4.30f1", + "2019.1.14f1", + "2019.2.21f1", + "2019.3.15f1", + "2019.4.16f1", + "2020.1.17f1", + "2020.2.1f1", + ] + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + + steps: + # Checkout sandbox project + - uses: actions/checkout@v2 + with: + ref: sandbox + submodules: true + fetch-depth: 0 + + # Update package submodule + - name: "Update package submodule" + working-directory: Packages/dev + run: git checkout ${{ github.sha }} + + - uses: actions/cache@v2 + with: + path: Library + key: Library-${{ matrix.unityVersion }}-${{ github.sha }} + restore-keys: | + Library-${{ matrix.unityVersion }}- + Library- + + # Install codecoverage package + - name: "Install codecoverage package" + if: startsWith(matrix.unityVersion, '2019.4.') + run: | + npx openupm-cli add -f com.unity.testtools.codecoverage@0.4.0-preview + + # Run tests + - name: "Run tests" + uses: game-ci/unity-test-runner@main + with: + unityVersion: ${{ matrix.unityVersion }} + customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }} + customParameters: -enableCodeCoverage + # customParameters: -enableCodeCoverage -coverageOptions assemblyFilters:+CSharpCompilerSettings_,-*-CSharp,-*.Tests,-IgnoreAccessibility + + - uses: actions/upload-artifact@v2 + if: always() + with: + name: TestResults-${{ matrix.unityVersion }} + path: | + artifacts/*.xml + CodeCoverage/**/TestCoverageResults_*.xml + + publish: + needs: unity-test + runs-on: ubuntu-latest + if: always() + steps: + + - uses: actions/download-artifact@v2 + with: + path: artifacts + + - uses: testspace-com/setup-testspace@v1 + with: + domain: ${{github.repository_owner}} + + - name: Push test results + if: always() + run: | + testspace `find . -name '*.xml' | tr '\n' ' '` \ No newline at end of file diff --git a/.github/workflows/unity-test.yml b/.github/workflows/unity-test.yml deleted file mode 100644 index bd6adae..0000000 --- a/.github/workflows/unity-test.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: unity-test - -on: - push: - branches: - - develop - tags: - - "!*" - pull_request: - types: - - opened - - synchronize - -jobs: - unity-test: - strategy: - fail-fast: false - matrix: - unity: - [ - "2018.3.14f1", - "2018.4.25f1", - "2019.1.14f1", - "2019.2.11f1", - "2019.3.15f1", - "2019.4.8f1", - "2020.1.5f1", - ] - - runs-on: ubuntu-latest - container: - # Use Unity image from https://hub.docker.com/r/gableroux/unity3d/tags - image: gableroux/unity3d:${{ matrix.unity }} - - steps: - # Activate Unity Editor - - name: Activate Unity Editor - id: activation - run: | - apt-get update > /dev/null - apt-get install software-properties-common -y > /dev/null - apt-add-repository ppa:git-core/ppa -y > /dev/null - apt-get update > /dev/null - apt-get install git -y > /dev/null - git clone https://gist.github.com/135c940b45ec4e385861c8711777db7f.git .ulfs - chmod 755 .ulfs/activate.sh && .ulfs/activate.sh ${{ matrix.unity }} - - # (On failed activation) Upload unity activation file - - name: Upload unity activation file - uses: actions/upload-artifact@v2 - if: failure() - with: - name: Unity_v${{ matrix.unity }}.alf - path: ./*.alf - - # Checkout sandbox project - - uses: actions/checkout@v2 - with: - ref: "sandbox" - submodules: "true" - - # Update package submodule - - name: "Update package submodule" - working-directory: Packages/dev - run: git checkout ${{ github.head_ref }} - - # Install codecoverage package - - name: "Install codecoverage package" - if: always() && steps.activation.conclusion == 'success' - run: | - [ -n "`echo ${{ matrix.unity }} | grep -e '\(2017.\|2018.\|2019.1.\|2019.2.\)'`" ] && exit 0 - npm i -g openupm-cli - openupm add com.unity.testtools.codecoverage - - # Run playmode tests - - name: "Run playmode tests" - if: always() && steps.activation.conclusion == 'success' - run: | - xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ - /opt/Unity/Editor/Unity -batchmode -nographics -silent-crashes -logFile -projectPath . \ - -runTests -testPlatform playmode -enableCodeCoverage - - # Run editmode tests - - name: "Run editmode tests" - if: always() && steps.activation.conclusion == 'success' - run: | - xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ - /opt/Unity/Editor/Unity -batchmode -nographics -silent-crashes -logFile -projectPath . \ - -runTests -testPlatform editmode -enableCodeCoverage - - # Setup testspace - - uses: testspace-com/setup-testspace@v1 - if: always() && steps.activation.conclusion == 'success' - with: - domain: ${{ github.repository_owner }} - - # Push test results - - name: Push test results - if: always() && steps.activation.conclusion == 'success' - run: testspace "[${{ matrix.unity }}]TestResults-*.xml" "[Code Coverage]CodeCoverage/**/TestCoverageResults_*.xml"