diff --git a/.github/workflows/new-ubuntu-base-image-requested.yml b/.github/workflows/new-ubuntu-base-image-requested.yml index 39bdbe15..c8fcfa6b 100644 --- a/.github/workflows/new-ubuntu-base-image-requested.yml +++ b/.github/workflows/new-ubuntu-base-image-requested.yml @@ -18,6 +18,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + ################# # Variables # ################# diff --git a/.github/workflows/new-ubuntu-hub-image-requested.yml b/.github/workflows/new-ubuntu-hub-image-requested.yml index a70b5729..47654a4d 100644 --- a/.github/workflows/new-ubuntu-hub-image-requested.yml +++ b/.github/workflows/new-ubuntu-hub-image-requested.yml @@ -18,6 +18,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + ################# # Variables # ################# diff --git a/.github/workflows/new-ubuntu-legacy-editor-image-requested.yml b/.github/workflows/new-ubuntu-legacy-editor-image-requested.yml index 239ed44a..3c61ff4c 100644 --- a/.github/workflows/new-ubuntu-legacy-editor-image-requested.yml +++ b/.github/workflows/new-ubuntu-legacy-editor-image-requested.yml @@ -28,6 +28,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + ################# # Variables # ################# diff --git a/.github/workflows/new-ubuntu-post-2019-2-editor-image-requested.yml b/.github/workflows/new-ubuntu-post-2019-2-editor-image-requested.yml index a7b89bbf..ac12655f 100644 --- a/.github/workflows/new-ubuntu-post-2019-2-editor-image-requested.yml +++ b/.github/workflows/new-ubuntu-post-2019-2-editor-image-requested.yml @@ -28,6 +28,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + ################# # Variables # ################# diff --git a/.github/workflows/new-windows-base-image-requested.yml b/.github/workflows/new-windows-base-image-requested.yml index 76af35e0..14888cfa 100644 --- a/.github/workflows/new-windows-base-image-requested.yml +++ b/.github/workflows/new-windows-base-image-requested.yml @@ -33,6 +33,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + shell: bash ################# # Variables # diff --git a/.github/workflows/new-windows-hub-image-requested.yml b/.github/workflows/new-windows-hub-image-requested.yml index abb5a07f..960debd9 100644 --- a/.github/workflows/new-windows-hub-image-requested.yml +++ b/.github/workflows/new-windows-hub-image-requested.yml @@ -33,6 +33,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + shell: bash ################# # Variables # diff --git a/.github/workflows/new-windows-legacy-editor-image-requested.yml b/.github/workflows/new-windows-legacy-editor-image-requested.yml index eddd975d..748c8362 100644 --- a/.github/workflows/new-windows-legacy-editor-image-requested.yml +++ b/.github/workflows/new-windows-legacy-editor-image-requested.yml @@ -49,7 +49,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Checkout latest release tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + shell: bash + ################# # Variables # ################# @@ -59,21 +67,21 @@ jobs: if ("${{ github.event.inputs.jobId }}") { # Workflow Dispatch - echo "jobId=${{ github.event.inputs.jobId }}" >> $GITHUB_ENV - echo "editorVersion=${{ github.event.inputs.editorVersion }}" >> $GITHUB_ENV - echo "changeSet=${{ github.event.inputs.changeSet }}" >> $GITHUB_ENV - echo "repoVersionFull=${{ github.event.inputs.repoVersionFull }}" >> $GITHUB_ENV - echo "repoVersionMinor=${{ github.event.inputs.repoVersionMinor }}" >> $GITHUB_ENV - echo "repoVersionMajor=${{ github.event.inputs.repoVersionMajor }}" >> $GITHUB_ENV + echo "jobId=${{ github.event.inputs.jobId }}" >> $GITHUB_OUTPUT + echo "editorVersion=${{ github.event.inputs.editorVersion }}" >> $GITHUB_OUTPUT + echo "changeSet=${{ github.event.inputs.changeSet }}" >> $GITHUB_OUTPUT + echo "repoVersionFull=${{ github.event.inputs.repoVersionFull }}" >> $GITHUB_OUTPUT + echo "repoVersionMinor=${{ github.event.inputs.repoVersionMinor }}" >> $GITHUB_OUTPUT + echo "repoVersionMajor=${{ github.event.inputs.repoVersionMajor }}" >> $GITHUB_OUTPUT } else { # Repo Dispatch - echo "jobId=${{ github.event.client_payload.jobId }}" >> $GITHUB_ENV - echo "editorVersion=${{ github.event.client_payload.editorVersion }}" >> $GITHUB_ENV - echo "changeSet=${{ github.event.client_payload.changeSet }}" >> $GITHUB_ENV - echo "repoVersionFull=${{ github.event.client_payload.repoVersionFull }}" >> $GITHUB_ENV - echo "repoVersionMinor=${{ github.event.client_payload.repoVersionMinor }}" >> $GITHUB_ENV - echo "repoVersionMajor=${{ github.event.client_payload.repoVersionMajor }}" >> $GITHUB_ENV + echo "jobId=${{ github.event.client_payload.jobId }}" >> $GITHUB_OUTPUT + echo "editorVersion=${{ github.event.client_payload.editorVersion }}" >> $GITHUB_OUTPUT + echo "changeSet=${{ github.event.client_payload.changeSet }}" >> $GITHUB_OUTPUT + echo "repoVersionFull=${{ github.event.client_payload.repoVersionFull }}" >> $GITHUB_OUTPUT + echo "repoVersionMinor=${{ github.event.client_payload.repoVersionMinor }}" >> $GITHUB_OUTPUT + echo "repoVersionMajor=${{ github.event.client_payload.repoVersionMajor }}" >> $GITHUB_OUTPUT } - name: Show hook input diff --git a/.github/workflows/new-windows-post-2019-2-editor-image-requested.yml b/.github/workflows/new-windows-post-2019-2-editor-image-requested.yml index 3901a144..339cdae0 100644 --- a/.github/workflows/new-windows-post-2019-2-editor-image-requested.yml +++ b/.github/workflows/new-windows-post-2019-2-editor-image-requested.yml @@ -50,6 +50,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + shell: bash ################# # Variables # @@ -60,21 +68,21 @@ jobs: if ("${{ github.event.inputs.jobId }}") { # Workflow Dispatch - echo "jobId=${{ github.event.inputs.jobId }}" >> $GITHUB_ENV - echo "editorVersion=${{ github.event.inputs.editorVersion }}" >> $GITHUB_ENV - echo "changeSet=${{ github.event.inputs.changeSet }}" >> $GITHUB_ENV - echo "repoVersionFull=${{ github.event.inputs.repoVersionFull }}" >> $GITHUB_ENV - echo "repoVersionMinor=${{ github.event.inputs.repoVersionMinor }}" >> $GITHUB_ENV - echo "repoVersionMajor=${{ github.event.inputs.repoVersionMajor }}" >> $GITHUB_ENV + echo "jobId=${{ github.event.inputs.jobId }}" >> $GITHUB_OUTPUT + echo "editorVersion=${{ github.event.inputs.editorVersion }}" >> $GITHUB_OUTPUT + echo "changeSet=${{ github.event.inputs.changeSet }}" >> $GITHUB_OUTPUT + echo "repoVersionFull=${{ github.event.inputs.repoVersionFull }}" >> $GITHUB_OUTPUT + echo "repoVersionMinor=${{ github.event.inputs.repoVersionMinor }}" >> $GITHUB_OUTPUT + echo "repoVersionMajor=${{ github.event.inputs.repoVersionMajor }}" >> $GITHUB_OUTPUT } else { # Repo Dispatch - echo "jobId=${{ github.event.client_payload.jobId }}" >> $GITHUB_ENV - echo "editorVersion=${{ github.event.client_payload.editorVersion }}" >> $GITHUB_ENV - echo "changeSet=${{ github.event.client_payload.changeSet }}" >> $GITHUB_ENV - echo "repoVersionFull=${{ github.event.client_payload.repoVersionFull }}" >> $GITHUB_ENV - echo "repoVersionMinor=${{ github.event.client_payload.repoVersionMinor }}" >> $GITHUB_ENV - echo "repoVersionMajor=${{ github.event.client_payload.repoVersionMajor }}" >> $GITHUB_ENV + echo "jobId=${{ github.event.client_payload.jobId }}" >> $GITHUB_OUTPUT + echo "editorVersion=${{ github.event.client_payload.editorVersion }}" >> $GITHUB_OUTPUT + echo "changeSet=${{ github.event.client_payload.changeSet }}" >> $GITHUB_OUTPUT + echo "repoVersionFull=${{ github.event.client_payload.repoVersionFull }}" >> $GITHUB_OUTPUT + echo "repoVersionMinor=${{ github.event.client_payload.repoVersionMinor }}" >> $GITHUB_OUTPUT + echo "repoVersionMajor=${{ github.event.client_payload.repoVersionMajor }}" >> $GITHUB_OUTPUT } - name: Show hook input diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml deleted file mode 100644 index ee9d79db..00000000 --- a/.github/workflows/pull-requests.yml +++ /dev/null @@ -1,298 +0,0 @@ -name: PR 😎 - -on: - pull_request_target: {} - -jobs: - reportingTest: - name: "🧪 Test reporting system (${{ matrix.imageType }})" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - jobId: - - dryRun # specifically use `dryRun` for testing. - imageType: - - base - - hub - - editor - baseOs: - - ubuntu - repoVersion: - - 0.1 - include: - - imageType: editor - editorVersion: 2020.1.4f1 - targetPlatform: android - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Report new build - uses: ./.github/workflows/actions/report-to-backend - with: - token: ${{ secrets.VERSIONING_TOKEN }} - jobId: ${{ matrix.jobId }} - status: started - # Build info - imageType: ${{ matrix.imageType }} - baseOs: ${{ matrix.baseOs }} - repoVersion: ${{ matrix.repoVersion }} - editorVersion: ${{ matrix.editorVersion }} - targetPlatform: ${{ matrix.targetPlatform }} - - name: Report build failure - uses: ./.github/workflows/actions/report-to-backend - with: - token: ${{ secrets.VERSIONING_TOKEN }} - jobId: ${{ matrix.jobId }} - status: failed - # Build info - imageType: ${{ matrix.imageType }} - baseOs: ${{ matrix.baseOs }} - repoVersion: ${{ matrix.repoVersion }} - editorVersion: ${{ matrix.editorVersion }} - targetPlatform: ${{ matrix.targetPlatform }} - # Failed specific - reason: 'no real reason' - - name: Report publication - uses: ./.github/workflows/actions/report-to-backend - with: - token: ${{ secrets.VERSIONING_TOKEN }} - jobId: ${{ matrix.jobId }} - status: published - # Build info - imageType: ${{ matrix.imageType }} - baseOs: ${{ matrix.baseOs }} - repoVersion: ${{ matrix.repoVersion }} - editorVersion: ${{ matrix.editorVersion }} - targetPlatform: ${{ matrix.targetPlatform }} - # Published specific - imageRepo: unityci - imageName: ${{ matrix.imageType }} - friendlyTag: ${{ matrix.editorVersion }}-${{ matrix.targetPlatform }}-${{ matrix.repoVersion }} - specificTag: ${{ matrix.baseOs }}-${{ matrix.editorVersion }}-${{ matrix.targetPlatform }}-${{ matrix.repoVersion }} - digest: sha256:ef872b67450a680fbeebe1b037190b8f8fbfb04088531f422873915520e26e0f; - - build-ubuntu: - name: "🧪 Test build Ubuntu (${{ matrix.targetPlatform }})" - runs-on: ubuntu-latest - services: - registry: - image: registry:2 - ports: - - 5000:5000 - strategy: - fail-fast: false - matrix: - targetPlatform: - # This list of target platforms is based on Ubuntu as a base platform - - base - - # Linux Build Support - # - linux-mono # May not exist in newer versions / May be default for Ubuntu - - linux-il2cpp # May not exist in older versions - - # Windows Build Support - - windows-mono - # - windows-il2cpp # May not exist for ubuntu - - # MacOS Build Support - - mac-mono - # - mac-il2cpp # May not exist for ubuntu - - # iOS Build Support - - ios - - # Android Build Support - - android - - # WebGL Build support - - webgl - - # Non-priorities: (but able to support) - # - vuforia-ar # Vuforia Augmented Reality Support - # - appletv # tvOS Build Support - # - samsung # SamsungTV Build Support - # - tizen # Tizen Build Support - # - lumin # Lumin OS (Magic Leap) Build Support - - # Tools: (probably included in build support packs) - # - android-sdk-ndk-tools # Android SDK & NDK Tools - # - android-open-jdk # OpenJDK - # - monodevelop # MonoDevelop / Unity Debugger - - steps: - ############# - # Setup # - ############# - - name: Checkout - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - with: - driver-opts: network=host - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-pr-${{ matrix.targetPlatform }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx-pr-${{ matrix.targetPlatform }} - ${{ runner.os }}-buildx-${{ matrix.targetPlatform }} - ${{ runner.os }}-buildx- - - ####################### - # Free disk space # - ####################### - - name: Free disk space - run: .github/workflows/scripts/free_disk_space.sh - - ################## - # Base image # - ################## - - name: Build base image # and push - uses: docker/build-push-action@v4 - id: build_ubuntu_base_image - with: - file: ./images/ubuntu/base/Dockerfile - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - push: true - tags: localhost:5000/unityci/base:latest - - name: Inspect - run: | - docker buildx imagetools inspect localhost:5000/unityci/base:latest - - ################# - # Hub image # - ################# - - name: Build hub image # and push - uses: docker/build-push-action@v4 - id: build_ubuntu_hub_image - with: - file: ./images/ubuntu/hub/Dockerfile - build-args: | - baseImage=localhost:5000/unityci/base:latest - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - push: true - tags: localhost:5000/unityci/hub:latest - - name: Inspect - run: | - docker buildx imagetools inspect localhost:5000/unityci/hub:latest - - #################### - # Editor image # - #################### - - name: Build editor image # and push - uses: docker/build-push-action@v4 - id: build_editor_image - with: - file: ./images/ubuntu/editor/Dockerfile - build-args: | - hubImage=localhost:5000/unityci/hub:latest - baseImage=localhost:5000/unityci/base:latest - version=2020.1.4f1 - changeSet=fa717bb873ec - module=${{ matrix.targetPlatform }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - push: true - tags: localhost:5000/unityci/editor:latest - - name: Inspect - run: | - docker buildx imagetools inspect localhost:5000/unityci/editor:latest - - ############### - # Metrics # - ############### - - name: Disk space after - if: always() - run: df -h - - build-windows: - name: "🧪 Test build Windows (${{ matrix.targetPlatform }})" - runs-on: windows-2019 - strategy: - fail-fast: false - matrix: - targetPlatform: - - base - - windows-il2cpp - - universal-windows-platform - - appletv - - steps: - ############# - # Setup # - ############# - - name: Checkout - uses: actions/checkout@v3 - - ####################### - # Free disk space # - ####################### - # TODO: Determine what we can free on windows - - ################## - # Base image # - ################## - - name: Build Windows Base Image # and push - id: build_windows_base_image - run: | - docker build ./images/windows/base/ ` - --tag unityci/base:windows-latest - - name: Inspect - run: | - docker inspect unityci/base:windows-latest - - ################# - # Hub image # - ################# - - name: Build Windows Hub Image # and push - id: build_windows_hub_image - run: | - docker build ./images/windows/hub/ ` - --build-arg baseImage=unityci/base:windows-latest ` - --tag unityci/hub:windows-latest - - - name: Inspect - run: | - docker inspect unityci/hub:windows-latest - - #################### - # Editor image # - #################### - - name: Build Windows Editor Image # and push - id: build_windows_editor_image - run: | - docker build ./images/windows/editor/ ` - --build-arg baseImage=unityci/base:windows-latest ` - --build-arg hubImage=unityci/hub:windows-latest ` - --build-arg version=2020.1.4f1 ` - --build-arg changeSet=fa717bb873ec ` - --build-arg module=${{ matrix.targetPlatform }} ` - --tag unityci/editor:windows-latest - - - name: Inspect - run: | - docker inspect unityci/editor:windows-latest - - ############### - # Metrics # - ############### - - name: Disk space after - if: always() - run: get-PSDrive - - testImages-ubuntu: - name: 🧪 Test images - needs: [ build-ubuntu ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - lfs: true - - run: echo "not implemented" - # TODO - Add test that checks if a license is valid after the changes to a dockerfile (hardware id verification) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99c0410c..b5eb4f68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,14 +18,118 @@ env: jobs: ########################## - # Build base and hub # + # Test Backend # ########################## - ubuntu-base-and-hub: - name: Base and hub + reportingTest: + # Only run if not a PR as we need access to secrets + if: github.base_ref == '' + name: "🧪 Test reporting system (${{ matrix.imageType }})" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + jobId: + - dryRun # specifically use `dryRun` for testing. + imageType: + - base + - hub + - editor + baseOs: + - ubuntu + repoVersion: + - 0.1 + include: + - imageType: editor + editorVersion: 2020.1.4f1 + targetPlatform: android + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Report new build + uses: ./.github/workflows/actions/report-to-backend + with: + token: ${{ secrets.VERSIONING_TOKEN }} + jobId: ${{ matrix.jobId }} + status: started + # Build info + imageType: ${{ matrix.imageType }} + baseOs: ${{ matrix.baseOs }} + repoVersion: ${{ matrix.repoVersion }} + editorVersion: ${{ matrix.editorVersion }} + targetPlatform: ${{ matrix.targetPlatform }} + - name: Report build failure + uses: ./.github/workflows/actions/report-to-backend + with: + token: ${{ secrets.VERSIONING_TOKEN }} + jobId: ${{ matrix.jobId }} + status: failed + # Build info + imageType: ${{ matrix.imageType }} + baseOs: ${{ matrix.baseOs }} + repoVersion: ${{ matrix.repoVersion }} + editorVersion: ${{ matrix.editorVersion }} + targetPlatform: ${{ matrix.targetPlatform }} + # Failed specific + reason: 'no real reason' + - name: Report publication + uses: ./.github/workflows/actions/report-to-backend + with: + token: ${{ secrets.VERSIONING_TOKEN }} + jobId: ${{ matrix.jobId }} + status: published + # Build info + imageType: ${{ matrix.imageType }} + baseOs: ${{ matrix.baseOs }} + repoVersion: ${{ matrix.repoVersion }} + editorVersion: ${{ matrix.editorVersion }} + targetPlatform: ${{ matrix.targetPlatform }} + # Published specific + imageRepo: unityci + imageName: ${{ matrix.imageType }} + friendlyTag: ${{ matrix.editorVersion }}-${{ matrix.targetPlatform }}-${{ matrix.repoVersion }} + specificTag: ${{ matrix.baseOs }}-${{ matrix.editorVersion }}-${{ matrix.targetPlatform }}-${{ matrix.repoVersion }} + digest: sha256:ef872b67450a680fbeebe1b037190b8f8fbfb04088531f422873915520e26e0f; + + ########################## + # Setup build matrix # + ########################## + build-matrix: + name: Setup Build Matrix runs-on: ubuntu-latest outputs: versions: ${{ steps.setup.outputs.versions }} excludes: ${{ steps.setup.outputs.excludes }} + steps: + - name: "Setup build matrix" + id: setup + run: | + # Get the Unity versions for test. (The latest patch versions for each minor version.) + VERSIONS=`npx unity-changeset list --versions --latest-patch --json --min 2018.3` + echo "Versions: $VERSIONS" + echo "versions=$VERSIONS" >> $GITHUB_OUTPUT + + # Exclude linux-il2cpp and windows-il2cpp for Unity 2019.2 or earlier + EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2\")) | { version: ., module: \"linux-il2cpp\"} ]'`" + + # Unity 2021.1 and 2021.2 do not build properly on windows targets + EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2|2021.1|2021.2\")) | { version: ., module: \"windows-il2cpp\"} ]'`" + + # Universal Windows Platform is added in 2019 + EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2021.1|2021.2\")) | { version: ., module: \"universal-windows-platform\"} ]'`" + + # AppleTV isn't stable until 2019.2 + EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2021.1|2021.2\")) | { version: ., module: \"appletv\"} ]'`" + + EXCLUDES=`echo "$EXCLUDES" | jq -s -c 'flatten'` + echo "Excludes: $EXCLUDES" + echo "excludes=$EXCLUDES" >> $GITHUB_OUTPUT + + ################################# + # Build Ubuntu base and hub # + ################################# + ubuntu-base-and-hub: + name: Ubuntu Base and Hub + runs-on: ubuntu-latest steps: ############# # Setup # @@ -60,39 +164,70 @@ jobs: docker save -o ubuntu-base-and-hub.tar base:ubuntu-dev hub:ubuntu-dev - uses: actions/upload-artifact@v3 with: + name: ubuntu-base-and-hub path: ubuntu-base-and-hub.tar retention-days: 1 - ########################## - # Setup build matrix # - ########################## - - name: "Setup build matrix" - id: setup + ################################## + # Build Windows base and hub # + ################################## + windows-base-and-hub: + name: Windows Base and Hub + runs-on: windows-2019 + steps: + ############# + # Setup # + ############# + - uses: actions/checkout@v3 + + ################################## + # Build Windows base and hub # + ################################## + - name: Build base run: | - # Get the Unity versions for test. (The latest patch versions for each minor version.) - VERSIONS=`npx unity-changeset list --versions --latest-patch --json --min 2018.3` - echo "Versions: $VERSIONS" - echo "versions=$VERSIONS" >> $GITHUB_OUTPUT + docker build -t base:windows-dev -f ./images/windows/base/Dockerfile . + - name: Build hub + run: | + docker build -t hub:windows-dev -f ./images/windows/hub/Dockerfile --build-arg baseImage=base:windows-dev . + + ################################################### + # Save images for later steps in the workflow # + ################################################### - # Exclude linux-il2cpp for Unity 2019.2 or earlier - EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2\")) | { version: ., module: \"linux-il2cpp\"} ]'`" + - name: Show disk space + if: always() + run: get-PSDrive - EXCLUDES=`echo "$EXCLUDES" | jq -s -c 'flatten'` - echo "Excludes: $EXCLUDES" - echo "excludes=$EXCLUDES" >> $GITHUB_OUTPUT + - name: Save images + run: | + docker images + mkdir c:\artifact + cd c:\artifact + docker save -o windows-base-and-hub.tar base:windows-dev hub:windows-dev + zstd -z -12 --format=zstd windows-base-and-hub.tar + + - uses: actions/upload-artifact@v3 + with: + name: windows-base-and-hub + path: C:/artifact/windows-base-and-hub.tar.zst + retention-days: 1 + + - name: Show disk space + if: always() + run: get-PSDrive ############################# # Build editor and test # ############################# - editor: - needs: ubuntu-base-and-hub - name: Editor (${{ matrix.version }}, ${{ matrix.module }}) + ubuntu-editor: + needs: [ubuntu-base-and-hub, build-matrix] + name: Ubuntu (${{ matrix.version }}, ${{ matrix.module }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: # The latest patch versions for each minor version. - version: ${{ fromJson(needs.ubuntu-base-and-hub.outputs.versions) }} + version: ${{ fromJson(needs.build-matrix.outputs.versions) }} module: - base - linux-il2cpp @@ -107,7 +242,7 @@ jobs: - module: linux-il2cpp platform: StandaloneLinux64 - module: windows-mono - platform: StandaloneWindows + platform: StandaloneWindows64 - module: mac-mono platform: StandaloneOSX - module: ios @@ -116,7 +251,7 @@ jobs: platform: Android - module: webgl platform: WebGL - exclude: ${{ fromJson(needs.ubuntu-base-and-hub.outputs.excludes) }} + exclude: ${{ fromJson(needs.build-matrix.outputs.excludes) }} steps: ############# @@ -134,10 +269,13 @@ jobs: # Restore base and hub # ############################ - uses: actions/download-artifact@v3 + with: + name: ubuntu-base-and-hub + - name: Restore base and hub run: | - docker load -i artifact/ubuntu-base-and-hub.tar - rm -rf artifact + docker load -i ubuntu-base-and-hub.tar + rm ubuntu-base-and-hub.tar ###################### # Setup to build # @@ -218,6 +356,7 @@ jobs: ############# - name: Build project uses: game-ci/unity-builder@main + timeout-minutes: 15 with: unityVersion: ${{ matrix.version }} customImage: editor:ubuntu-dev @@ -236,6 +375,7 @@ jobs: - name: Build project (GZip) if: env.MODULE == 'webgl' uses: game-ci/unity-builder@main + timeout-minutes: 15 with: unityVersion: ${{ matrix.version }} customImage: editor:ubuntu-dev @@ -254,6 +394,7 @@ jobs: - name: Build project (Brotli) if: env.MODULE == 'webgl' uses: game-ci/unity-builder@main + timeout-minutes: 15 with: unityVersion: ${{ matrix.version }} customImage: editor:ubuntu-dev @@ -282,3 +423,134 @@ jobs: with: image: editor:ubuntu-dev run: bash -l -c 'java -version && sdkmanager --version && cat $ANDROID_NDK_HOME/source.properties' + + ############################# + # Build editor and test # + ############################# + windows-editor: + needs: [windows-base-and-hub, build-matrix] + name: Windows (${{ matrix.version }}, ${{ matrix.module }}) + runs-on: windows-2019 + strategy: + fail-fast: false + matrix: + # The latest patch versions for each minor version. + version: ${{ fromJson(needs.build-matrix.outputs.versions) }} + module: + - windows-il2cpp + - universal-windows-platform + - appletv + include: + - module: windows-il2cpp + platform: StandaloneWindows64 + - module: appletv + platform: tvOS + - module: universal-windows-platform + platform: WSAPlayer + exclude: ${{ fromJson(needs.build-matrix.outputs.excludes) }} + + steps: + ############# + # Setup # + ############# + - uses: actions/checkout@v3 + + ############################ + # Restore base and hub # + ############################ + - uses: actions/download-artifact@v3 + with: + name: windows-base-and-hub + - name: Restore base and hub + run: | + mkdir c:/artifact + mv windows-base-and-hub.tar.zst c:/artifact + cd c:/artifact + zstd -d windows-base-and-hub.tar.zst + docker load -i windows-base-and-hub.tar + RAW_WORKSPACE_PATH="${{ github.workspace }}" + WORKSPACE_PATH=${RAW_WORKSPACE_PATH//\\//} + cd $WORKSPACE_PATH + rm -rf c:/artifact + shell: bash + + ###################### + # Setup to build # + ###################### + - name: Setup to build + run: | + # The changeset for unity version + echo "CHANGESET=`npx unity-changeset ${{ matrix.version }}`" >> $GITHUB_ENV + + # For 2019.3 or later, non-il2cpp would also be possible to build with il2cpp image. + if [ `echo "${{ matrix.version }}" | grep -v '\(2018\|2019.1\|2019.2\)'` ] && [ "${{ matrix.module }}" = 'base' ] ; then + echo "MODULE=windows-il2cpp" >> $GITHUB_ENV + else + echo "MODULE=${{ matrix.module }}" >> $GITHUB_ENV + fi + shell: bash + + ########################### + # Build Windows editor # + ########################### + - name: Build + continue-on-error: true + timeout-minutes: 60 + id: build-1 + run: | + docker build -t editor:windows-dev --build-arg baseImage=base:windows-dev ` + --build-arg hubImage=hub:windows-dev --build-arg version=${{ matrix.version }} ` + --build-arg changeSet=${{ env.CHANGESET }} --build-arg module=${{ env.MODULE }} ./images/windows/editor + + #################################### + # Build Windows editor (retry) # + #################################### + - name: Sleep for retry + if: steps.build-1.outcome == 'failure' + run: sleep 120 + + - name: Build (Retry) + if: steps.build-1.outcome == 'failure' + id: build-2 + timeout-minutes: 60 + run: | + docker build -t editor:windows-dev --build-arg baseImage=base:windows-dev ` + --build-arg hubImage=hub:windows-dev --build-arg version=${{ matrix.version }} ` + --build-arg changeSet=${{ env.CHANGESET }} --build-arg module=${{ env.MODULE }} ./images/windows/editor + + ##################### + # Setup to test # + ##################### + - name: Show image size + run: docker images + - name: Setup to test + run: | + # For 'windows-il2cpp' module, switch the script backend to 'IL2CPP' + if [ "${{ matrix.module }}" = "windows-il2cpp" ] ; then + mv -f reference-project-test/ProjectSettings/ProjectSettings_il2cpp.asset reference-project-test/ProjectSettings/ProjectSettings.asset + fi + + # For editors prior to 2020, use built-in packages. Otherwise use the packages.json with the necessary packages. + if [[ $(echo ${{ matrix.version }} | cut -d '.' -f1) -ge 2020 ]]; then + mv -f reference-project-test/Packages_Disabled reference-project-test/Packages + fi + shell: bash + + ############# + # Build # + ############# + - name: Build project + # Only run if not a PR as we need access to secrets + if: github.base_ref == '' + timeout-minutes: 15 + uses: game-ci/unity-builder@main + env: + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} + with: + unityVersion: ${{ matrix.version }} + customImage: editor:windows-dev + projectPath: reference-project-test + targetPlatform: ${{ matrix.platform }} + allowDirtyBuild: true diff --git a/images/ubuntu/hub/Dockerfile b/images/ubuntu/hub/Dockerfile index bba4b585..5b7532c7 100644 --- a/images/ubuntu/hub/Dockerfile +++ b/images/ubuntu/hub/Dockerfile @@ -16,8 +16,11 @@ RUN sh -c 'echo "deb https://hub.unity3d.com/linux/repos/deb stable main" > /etc && apt-get -q install -y "unityhub=$hubVersion" \ && apt-get clean +# Bug in xvfb-run that causes it to redirect stderr to stdout. We want it separate +RUN sed -i 's/^\(.*DISPLAY=:.*XAUTHORITY=.*\)\( "\$@" \)2>&1$/\1\2/' /usr/bin/xvfb-run + # Alias to "unity-hub" with default params -RUN echo '#!/bin/bash\nxvfb-run -ae /dev/stdout /opt/unityhub/unityhub-bin --no-sandbox --headless "$@"' > /usr/bin/unity-hub \ +RUN echo '#!/bin/bash\nxvfb-run -a /opt/unityhub/unityhub-bin --no-sandbox --headless "$@" 2>/dev/null' > /usr/bin/unity-hub \ && chmod +x /usr/bin/unity-hub # Configure diff --git a/images/windows/editor/Dockerfile b/images/windows/editor/Dockerfile index 6d822aa7..eb4fd881 100644 --- a/images/windows/editor/Dockerfile +++ b/images/windows/editor/Dockerfile @@ -12,18 +12,22 @@ FROM $hubImage as Builder # the installation. Otherwise docker believes there was an error ARG version ARG changeSet -RUN "C:/Program Files/Unity Hub/Unity Hub.exe" --no-sandbox --headless install \ - --version %version% \ - --changeset %changeSet% \ - & if %ERRORLEVEL% EQU 1 exit 0 +RUN powershell -Command "&'C:/Program Files/Unity Hub/Unity Hub.exe' '--%' '--no-sandbox --headless install \ + --version %version% --changeset %changeset%' 2>$null | \ + Tee-Object -FilePath 'C:\install-editor.log'; \ + if ((select-string -Path 'C:\install-editor.log' -Pattern \ + 'Failed to install|Error while installing an editor|Completed with errors') -ne $null) { exit 1 } \ + else { exit 0 }" ARG module RUN IF NOT %module% == "base" ( \ - "C:/Program Files/Unity Hub/Unity Hub.exe" --no-sandbox --headless install-modules \ - --version %version% \ - --module %module% \ - --childModules \ - & if %ERRORLEVEL% EQU 1 exit 0 \ + powershell -Command \ + "&'C:/Program Files/Unity Hub/Unity Hub.exe' '--%' '--no-sandbox --headless \ + install-modules --version %version% --module %module% --childModules' 2>$null | \ + Tee-Object -FilePath 'C:\install-module-%module%.log'; \ + if ((select-string -Path 'C:\install-module-%module%.log' -Pattern \ + 'Failed to install|Error while installing an editor|Completed with errors|Missing module|No modules found') -ne $null) \ + { exit 1 } else { exit 0 }" \ ) ############