From 45b231938b066237e55063a32e4a19a90338d66b Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Mon, 19 Oct 2020 12:53:30 -0400 Subject: [PATCH] Simplify unity-actions workflow (#1) * Simplify unity-actions workflow * Remove WebGL from build as it's currently failing * Trigger builds on main branch push This is tricky. I wish we could trigger on all branches push, but it seems like internal PRs are run twice when using this: ```yaml on: pull_request: {} push: {} ``` So specifying a branch is a bit better somehow. Related discussions: * https://github.community/t/how-to-run-a-workflow-only-once-even-when-triggered-mutliple-times/16436 * https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662 --- .github/workflows/main.yml | 87 +++++++++++++++++++------ .github/workflows/manual_activation.yml | 28 -------- 2 files changed, 68 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/manual_activation.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 383979a..b393930 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Actions 😎 +name: Unity Actions on: pull_request: {} @@ -6,18 +6,76 @@ on: env: UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_VERSION: 2020.1.7f1 + PROJECT_PATH: . jobs: - buildAndTestForSomePlatforms: + checklicense: + name: check if UNITY_LICENSE is set in github secrets + runs-on: ubuntu-latest + outputs: + is_unity_license_set: ${{ steps.checklicense_job.outputs.is_unity_license_set }} + steps: + - name: Check whether unity activation requests should be done + id: checklicense_job + run: | + echo "Skip activation job: ${{ env.UNITY_LICENSE != '' }}" + echo "::set-output name=is_unity_license_set::${{ env.UNITY_LICENSE != '' }}" + activation: + needs: [checklicense] + if: needs.checklicense.outputs.is_unity_license_set == 'false' + name: Request activation file 🔑 + runs-on: ubuntu-latest + steps: + # Request manual activation file + - name: Request manual activation file + id: getManualLicenseFile + uses: webbertakken/unity-request-manual-activation-file@master + with: + unityVersion: ${{ env.UNITY_VERSION }} + # Upload artifact (Unity_v20XX.X.XXXX.alf) + - name: Expose as artifact + uses: actions/upload-artifact@v1 + with: + name: ${{ steps.getManualLicenseFile.outputs.filePath }} + path: ${{ steps.getManualLicenseFile.outputs.filePath }} + + test: + needs: [checklicense] + if: needs.checklicense.outputs.is_unity_license_set == 'true' + name: Test all modes ✨ + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + lfs: true + - uses: actions/cache@v1.1.0 + with: + path: Library + key: Library-test-project-${{ matrix.targetPlatform }} + restore-keys: | + Library-test-project- + Library- + - uses: webbertakken/unity-test-runner@v1.7 + id: testRunner + with: + projectPath: ${{ env.PROJECT_PATH }} + unityVersion: ${{ env.UNITY_VERSION }} + testMode: all + customParameters: "-nographics" + - uses: actions/upload-artifact@v1 + with: + name: Test results (all modes) + path: ${{ steps.testRunner.outputs.artifactsPath }} + + build: + needs: [checklicense] + if: needs.checklicense.outputs.is_unity_license_set == 'true' name: Build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - projectPath: - - . - unityVersion: - - 2020.1.7f1 targetPlatform: - StandaloneOSX - StandaloneWindows64 @@ -33,21 +91,12 @@ jobs: restore-keys: | Library-${{ matrix.projectPath }}- Library- -# - uses: webbertakken/unity-test-runner@master -# id: testRunner -# with: -# projectPath: ${{ matrix.projectPath }} -# unityVersion: ${{ matrix.unityVersion }} -# - uses: actions/upload-artifact@v1 -# with: -# name: Test results (all modes) -# path: ${{ steps.testRunner.outputs.artifactsPath }} - - uses: webbertakken/unity-builder@master + - uses: webbertakken/unity-builder@v1.4 with: - projectPath: ${{ matrix.projectPath }} - unityVersion: ${{ matrix.unityVersion }} + projectPath: ${{ env.PROJECT_PATH }} + unityVersion: ${{ env.UNITY_VERSION }} targetPlatform: ${{ matrix.targetPlatform }} - customParameters: '-nographics' + customParameters: "-nographics" - uses: actions/upload-artifact@v1 with: name: Build diff --git a/.github/workflows/manual_activation.yml b/.github/workflows/manual_activation.yml deleted file mode 100644 index 1336b8d..0000000 --- a/.github/workflows/manual_activation.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Acquire activation file -on: -#uncomment this to make it show once, stop the job in github actions, comment it again, then run using the "Run workflow" button and fill the form with desired unity version -# push: { branches: [main] } - - workflow_dispatch: - inputs: - unityVersion: - description: 'Unity version to use during activation request' - required: true - default: 2020.1.7f1 -jobs: - activation: - name: Request manual activation file 🔑 - runs-on: ubuntu-latest - steps: - # Request manual activation file - - name: Request manual activation file - id: getManualLicenseFile - uses: webbertakken/unity-request-manual-activation-file@master - with: - unityVersion: ${{ github.event.inputs.unityVersion }} - # Upload artifact (Unity_v20XX.X.XXXX.alf) - - name: Expose as artifact - uses: actions/upload-artifact@v1 - with: - name: ${{ steps.getManualLicenseFile.outputs.filePath }} - path: ${{ steps.getManualLicenseFile.outputs.filePath }}