diff --git a/.github/workflows/build-tests.yml b/.github/workflows/build-tests.yml new file mode 100644 index 00000000..abaf3fbe --- /dev/null +++ b/.github/workflows/build-tests.yml @@ -0,0 +1,83 @@ +name: Builds + +on: + push: { branches: [main] } + pull_request_target: + paths-ignore: + - '.github/**' + +jobs: + buildForAllPlatforms: + name: Build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + projectPath: + - test-project + unityVersion: + - 2019.2.11f1 + - 2019.3.15f1 + unityLicense: + - ${{ secrets.UNITY_LICENSE }} + targetPlatform: + - StandaloneOSX # Build a macOS standalone (Intel 64-bit). + - StandaloneWindows64 # Build a Windows 64-bit standalone. + - StandaloneLinux64 # Build a Linux 64-bit standalone. + - iOS # Build an iOS player. + - Android # Build an Android .apk. + - WebGL # WebGL. + # - StandaloneWindows # Build a Windows standalone. + # - WSAPlayer # Build an Windows Store Apps player. + # - PS4 # Build a PS4 Standalone. + # - XboxOne # Build a Xbox One Standalone. + # - tvOS # Build to Apple's tvOS platform. + # - Switch # Build a Nintendo Switch player + steps: + ########################### + # Checkout # + ########################### + - name: Checkout (default) + uses: actions/checkout@v2 + if: github.event.event_type != 'pull_request_target' + with: + lfs: true + - name: Checkout (pull_request_target) + uses: actions/checkout@v2 + if: github.event.event_type == 'pull_request_target' + with: + lfs: true + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + ########################### + # Cache # + ########################### + - uses: actions/cache@v2 + with: + path: ${{ matrix.projectPath }}/Library + key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} + restore-keys: | + Library-${{ matrix.projectPath }}- + Library- + + ########################### + # Build # + ########################### + - uses: ./ + env: + UNITY_LICENSE: ${{ matrix.unityLicense }} + with: + projectPath: ${{ matrix.projectPath }} + unityVersion: ${{ matrix.unityVersion }} + targetPlatform: ${{ matrix.targetPlatform }} + customParameters: -profile SomeProfile -someBoolean -someValue exampleValue + + ########################### + # Upload # + ########################### + - uses: actions/upload-artifact@v2 + with: + name: Build (${{ matrix.unityVersion }}) + path: build + retention-days: 14 diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index d191a623..844eca1d 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -1,13 +1,14 @@ -name: Delete old artifacts +name: Cleanup (cron) on: schedule: - cron: '30 10 * * SUN' # every sunday at 10:30 jobs: - delete-artifacts: + deleteArtifacts: runs-on: ubuntu-latest steps: - - uses: kolpav/purge-artifacts-action@v1 + - name: Delete old artifacts + uses: kolpav/purge-artifacts-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} expire-in: 21 days diff --git a/.github/workflows/integrity-check.yml b/.github/workflows/integrity-check.yml new file mode 100644 index 00000000..fcb970d9 --- /dev/null +++ b/.github/workflows/integrity-check.yml @@ -0,0 +1,24 @@ +name: Integrity + +on: + push: { branches: [main] } + pull_request: {} + +env: + CODECOV_TOKEN: '2f2eb890-30e2-4724-83eb-7633832cf0de' + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12.x + - run: yarn + - run: yarn lint + - run: yarn test --coverage + - run: bash <(curl -s https://codecov.io/bash) + - run: yarn build || { echo "build command should always succeed" ; exit 61; } + # - run: yarn build --quiet && git diff --quiet action || { echo "action should be auto generated" ; git diff action ; exit 62; } diff --git a/.github/workflows/kubernetes-tests.yml b/.github/workflows/kubernetes-tests.yml new file mode 100644 index 00000000..74a993c0 --- /dev/null +++ b/.github/workflows/kubernetes-tests.yml @@ -0,0 +1,91 @@ +name: Kubernetes + +on: + push: { branches: [main] } + pull_request_target: + paths-ignore: + - '.github/**' + +env: + GKE_ZONE: 'us-central1-c' + GKE_REGION: 'us-central1' + GKE_PROJECT: 'unitykubernetesbuilder' + GKE_CLUSTER: 'unity-builder-cluster' + +jobs: + k8sBuilds: + name: K8s build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }} + runs-on: ubuntu-latest + continue-on-error: true + strategy: + fail-fast: false + matrix: + targetPlatform: + - StandaloneLinux64 + - StandaloneWindows64 + unityLicense: + - ${{ secrets.UNITY_LICENSE }} + steps: + ########################### + # Checkout # + ########################### + - name: Checkout (default) + uses: actions/checkout@v2 + if: github.event.event_type != 'pull_request_target' + with: + lfs: true + - name: Checkout (pull_request_target) + uses: actions/checkout@v2 + if: github.event.event_type == 'pull_request_target' + with: + lfs: true + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + ########################### + # Spin up # + ########################### + - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master + with: + version: '288.0.0' + service_account_email: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_EMAIL }} + service_account_key: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} + - run: ./action/bootstrapper/ApplyClusterAndAcquireLock.sh ${{ env.GKE_PROJECT }} ${{ env.GKE_CLUSTER }} ${{ env.GKE_ZONE }} + + ########################### + # Build # + ########################### + - uses: frostebite/File-To-Base64@master + id: read-base64 + with: + filePath: ~/.kube/config + - uses: ./ + id: k8s-unity-build + env: + UNITY_LICENSE: ${{ matrix.unityLicense }} + with: + targetPlatform: ${{ matrix.targetPlatform }} + kubeConfig: ${{ steps.read-base64.outputs.base64 }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + projectPath: test-project + unityVersion: 2019.3.15f1 + + ########################### + # Upload # + ########################### + - uses: frostebite/K8s-Download-Volume@master + with: + kubeConfig: ${{ steps.read-base64.outputs.base64 }} + volume: ${{ steps.k8s-unity-build.outputs.volume }} + sourcePath: repo/build/ + - uses: actions/upload-artifact@v2 + with: + name: Kubernetes Build (${{ matrix.targetPlatform }}) + path: k8s-volume-download + retention-days: 14 + + ########################### + # Spin down # + ########################### + - run: ./action/bootstrapper/ReleaseLockAndAttemptShutdown.sh ${{ env.GKE_PROJECT }} ${{ env.GKE_CLUSTER }} ${{ env.GKE_ZONE }} + if: ${{ always() }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 8fea4512..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,181 +0,0 @@ -name: Actions - -on: - push: { branches: [main] } - pull_request_target: - paths-ignore: - - '.github/**' - -env: - CODECOV_TOKEN: '2f2eb890-30e2-4724-83eb-7633832cf0de' - GKE_ZONE: 'us-central1-c' - GKE_REGION: 'us-central1' - GKE_PROJECT: 'unitykubernetesbuilder' - GKE_CLUSTER: 'unity-builder-cluster' - -jobs: - tests: - name: Tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 12.x - - run: yarn - - run: yarn lint - - run: yarn test --coverage - - run: bash <(curl -s https://codecov.io/bash) - - run: yarn build || { echo "build command should always succeed" ; exit 61; } - # - run: yarn build --quiet && git diff --quiet action || { echo "action should be auto generated" ; git diff action ; exit 62; } - buildForAllPlatforms: - name: Build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - projectPath: - - test-project - unityVersion: - - 2019.2.11f1 - - 2019.3.15f1 - unityLicense: - - ${{ secrets.UNITY_LICENSE }} - targetPlatform: - - StandaloneOSX # Build a macOS standalone (Intel 64-bit). - - StandaloneWindows64 # Build a Windows 64-bit standalone. - - StandaloneLinux64 # Build a Linux 64-bit standalone. - - iOS # Build an iOS player. - # - Android # Build an Android .apk. - # - StandaloneWindows # Build a Windows standalone. - # - WebGL # WebGL. - # - WSAPlayer # Build an Windows Store Apps player. - # - PS4 # Build a PS4 Standalone. - # - XboxOne # Build a Xbox One Standalone. - # - tvOS # Build to Apple's tvOS platform. - # - Switch # Build a Nintendo Switch player - steps: - ########################### - # Checkout # - ########################### - - name: Checkout (default) - uses: actions/checkout@v2 - if: github.event.event_type != 'pull_request_target' - with: - lfs: true - - name: Checkout (pull_request_target) - uses: actions/checkout@v2 - if: github.event.event_type == 'pull_request_target' - with: - lfs: true - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - - ########################### - # Cache # - ########################### - - uses: actions/cache@v2 - with: - path: ${{ matrix.projectPath }}/Library - key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} - restore-keys: | - Library-${{ matrix.projectPath }}- - Library- - - ########################### - # Build # - ########################### - - uses: ./ - env: - UNITY_LICENSE: ${{ matrix.unityLicense }} - with: - projectPath: ${{ matrix.projectPath }} - unityVersion: ${{ matrix.unityVersion }} - targetPlatform: ${{ matrix.targetPlatform }} - customParameters: -profile SomeProfile -someBoolean -someValue exampleValue - - ########################### - # Upload # - ########################### - - uses: actions/upload-artifact@v2 - with: - name: Build (${{ matrix.unityVersion }}) - path: build - retention-days: 14 - - k8sBuilds: - name: K8s build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }} - runs-on: ubuntu-latest - continue-on-error: true - strategy: - fail-fast: false - matrix: - targetPlatform: - - StandaloneLinux64 - - StandaloneWindows64 - unityLicense: - - ${{ secrets.UNITY_LICENSE }} - steps: - ########################### - # Checkout # - ########################### - - name: Checkout (default) - uses: actions/checkout@v2 - if: github.event.event_type != 'pull_request_target' - with: - lfs: true - - name: Checkout (pull_request_target) - uses: actions/checkout@v2 - if: github.event.event_type == 'pull_request_target' - with: - lfs: true - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - - ########################### - # Spin up # - ########################### - - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master - with: - version: '288.0.0' - service_account_email: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_EMAIL }} - service_account_key: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} - - run: ./action/bootstrapper/ApplyClusterAndAcquireLock.sh ${{ env.GKE_PROJECT }} ${{ env.GKE_CLUSTER }} ${{ env.GKE_ZONE }} - - ########################### - # Build # - ########################### - - uses: frostebite/File-To-Base64@master - id: read-base64 - with: - filePath: ~/.kube/config - - uses: ./ - id: k8s-unity-build - env: - UNITY_LICENSE: ${{ matrix.unityLicense }} - with: - targetPlatform: ${{ matrix.targetPlatform }} - kubeConfig: ${{ steps.read-base64.outputs.base64 }} - githubToken: ${{ secrets.GITHUB_TOKEN }} - projectPath: test-project - unityVersion: 2019.3.15f1 - - ########################### - # Upload # - ########################### - - uses: frostebite/K8s-Download-Volume@master - with: - kubeConfig: ${{ steps.read-base64.outputs.base64 }} - volume: ${{ steps.k8s-unity-build.outputs.volume }} - sourcePath: repo/build/ - - uses: actions/upload-artifact@v2 - with: - name: Kubernetes Build (${{ matrix.targetPlatform }}) - path: k8s-volume-download - retention-days: 14 - - ########################### - # Spin down # - ########################### - - run: ./action/bootstrapper/ReleaseLockAndAttemptShutdown.sh ${{ env.GKE_PROJECT }} ${{ env.GKE_CLUSTER }} ${{ env.GKE_ZONE }} - if: ${{ always() }}