Skip to content

Add a non-root user #372

Add a non-root user

Add a non-root user #372

Workflow file for this run

name: Test
on:
workflow_dispatch:
push:
paths:
- "**/Dockerfile"
- ".github/workflows/test.yml"
- "reference-project-test/**"
pull_request:
paths:
- "**/Dockerfile"
- ".github/workflows/test.yml"
- "reference-project-test/**"
env:
UNITY_LICENSE: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>\n <License id=\"Terms\">\n <MachineBindings>\n <Binding Key=\"1\" Value=\"576562626572264761624c65526f7578\"/>\n <Binding Key=\"2\" Value=\"576562626572264761624c65526f7578\"/>\n </MachineBindings>\n <MachineID Value=\"D7nTUnjNAmtsUMcnoyrqkgIbYdM=\"/>\n <SerialHash Value=\"2033b8ac3e6faa3742ca9f0bfae44d18f2a96b80\"/>\n <Features>\n <Feature Value=\"33\"/>\n <Feature Value=\"1\"/>\n <Feature Value=\"12\"/>\n <Feature Value=\"2\"/>\n <Feature Value=\"24\"/>\n <Feature Value=\"3\"/>\n <Feature Value=\"36\"/>\n <Feature Value=\"17\"/>\n <Feature Value=\"19\"/>\n <Feature Value=\"62\"/>\n </Features>\n <DeveloperData Value=\"AQAAAEY0LUJHUlgtWEQ0RS1aQ1dWLUM1SlctR0RIQg==\"/>\n <SerialMasked Value=\"F4-BGRX-XD4E-ZCWV-C5JW-XXXX\"/>\n <StartDate Value=\"2021-02-08T00:00:00\"/>\n <UpdateDate Value=\"2021-02-09T00:34:57\"/>\n <InitialActivationDate Value=\"2021-02-08T00:34:56\"/>\n <LicenseVersion Value=\"6.x\"/>\n <ClientProvidedVersion Value=\"2018.4.30f1\"/>\n <AlwaysOnline Value=\"false\"/>\n <Entitlements>\n <Entitlement Ns=\"unity_editor\" Tag=\"UnityPersonal\" Type=\"EDITOR\" ValidTo=\"9999-12-31T00:00:00\"/>\n <Entitlement Ns=\"unity_editor\" Tag=\"DarkSkin\" Type=\"EDITOR_FEATURE\" ValidTo=\"9999-12-31T00:00:00\"/>\n </Entitlements>\n </License>\n<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\"/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><Reference URI=\"#Terms\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>m0Db8UK+ktnOLJBtHybkfetpcKo=</DigestValue></Reference></SignedInfo><SignatureValue>o/pUbSQAukz7+ZYAWhnA0AJbIlyyCPL7bKVEM2lVqbrXt7cyey+umkCXamuOgsWPVUKBMkXtMH8L\n5etLmD0getWIhTGhzOnDCk+gtIPfL4jMo9tkEuOCROQAXCci23VFscKcrkB+3X6h4wEOtA2APhOY\nB+wvC794o8/82ffjP79aVAi57rp3Wmzx+9pe9yMwoJuljAy2sc2tIMgdQGWVmOGBpQm3JqsidyzI\nJWG2kjnc7pDXK9pwYzXoKiqUqqrut90d+kQqRyv7MSZXR50HFqD/LI69h68b7P8Bjo3bPXOhNXGR\n9YCoemH6EkfCJxp2gIjzjWW+l2Hj2EsFQi8YXw==</SignatureValue></Signature></root>"
jobs:
##########################
# Test Backend #
##########################
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@v4
- 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 }}
linuxExcludes: ${{ steps.setup.outputs.linuxExcludes }}
windowsExcludes: ${{ steps.setup.outputs.windowsExcludes }}
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 il2cpp for Unity 2019.2 or earlier
LINUX_EXCLUDES="$LINUX_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2\")) | { version: ., module: \"linux-il2cpp\"} ]'`"
# Exclude il2cpp for Unity 2019.2 or earlier. Unity 2021.1 and 2021.2 also do not build properly and will be skipped
WINDOWS_EXCLUDES="$WINDOWS_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. Issues with 2021.1 and 2021.2 so they are skipped too
WINDOWS_EXCLUDES="$WINDOWS_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. Issues with 2021.1 and 2021.2 so they are skipped too
WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2021.1|2021.2\")) | { version: ., module: \"appletv\"} ]'`"
# No Windows 2018 Android Builds. Issues with 2021.1 and 2021.2 so they are skipped too
WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2021.1|2021.2\")) | { version: ., module: \"android\"} ]'`"
# No Windows mono Builds for Unity 2019.2 or earlier. Issues with 2021.1 and 2021.2 so they are skipped too
WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2|2021.1|2021.2\")) | { version: ., module: \"base\"} ]'`"
LINUX_EXCLUDES=`echo "$LINUX_EXCLUDES" | jq -s -c 'flatten'`
WINDOWS_EXCLUDES=`echo "$WINDOWS_EXCLUDES" | jq -s -c 'flatten'`
echo "Linux Excludes: $LINUX_EXCLUDES"
echo "Windows Excludes: $WINDOWS_EXCLUDES"
echo "linuxExcludes=$LINUX_EXCLUDES" >> $GITHUB_OUTPUT
echo "windowsExcludes=$WINDOWS_EXCLUDES" >> $GITHUB_OUTPUT
#################################
# Build Ubuntu base and hub #
#################################
ubuntu-base-and-hub:
name: Ubuntu Base and Hub
runs-on: ubuntu-latest
steps:
#############
# Setup #
#############
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
with:
driver: docker
#################################
# Build Ubuntu base and hub #
#################################
- name: Build base
uses: docker/build-push-action@v5
with:
file: ./images/ubuntu/base/Dockerfile
tags: base:ubuntu-dev
- name: Build hub
uses: docker/build-push-action@v5
with:
file: ./images/ubuntu/hub/Dockerfile
build-args: baseImage=base:ubuntu-dev
tags: hub:ubuntu-dev
###################################################
# Save images for later steps in the workflow #
###################################################
- name: Save images
run: |
docker images
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
##################################
# Build Windows base and hub #
##################################
windows-base-and-hub:
name: Windows Base and Hub
runs-on: windows-2022
steps:
#############
# Setup #
#############
- uses: actions/checkout@v4
##################################
# Build Windows base and hub #
##################################
- name: Build base
run: |
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 #
###################################################
- name: Show disk space
if: always()
run: get-PSDrive
- 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 #
#############################
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.build-matrix.outputs.versions) }}
module:
- base
- linux-il2cpp
- windows-mono
- mac-mono
- ios
- android
- webgl
include:
- module: base
platform: StandaloneLinux64
- module: linux-il2cpp
platform: StandaloneLinux64
- module: windows-mono
platform: StandaloneWindows64
- module: mac-mono
platform: StandaloneOSX
- module: ios
platform: iOS
- module: android
platform: Android
- module: webgl
platform: WebGL
exclude: ${{ fromJson(needs.build-matrix.outputs.linuxExcludes) }}
steps:
#############
# Setup #
#############
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Free disk space
run: .github/workflows/scripts/free_disk_space.sh
############################
# Restore base and hub #
############################
- uses: actions/download-artifact@v3
with:
name: ubuntu-base-and-hub
- name: Restore base and hub
run: |
docker load -i ubuntu-base-and-hub.tar
rm ubuntu-base-and-hub.tar
######################
# 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=linux-il2cpp" >> $GITHUB_ENV
else
echo "MODULE=${{ matrix.module }}" >> $GITHUB_ENV
fi
###########################
# Build Ubuntu editor #
###########################
- name: Build
# if: steps.build-1.outcome == 'failure'
uses: docker/build-push-action@v5
id: build-1
continue-on-error: true
timeout-minutes: 40
with:
file: ./images/ubuntu/editor/Dockerfile
build-args: |
baseImage=base:ubuntu-dev
hubImage=hub:ubuntu-dev
version=${{ matrix.version }}
changeSet=${{ env.CHANGESET }}
module=${{ env.MODULE }}
tags: editor:ubuntu-dev
###################################
# Build Ubuntu editor (retry) #
###################################
- name: Sleep for retry
if: steps.build-1.outcome == 'failure'
run: sleep 120
- name: Build (Retry)
if: steps.build-1.outcome == 'failure'
uses: docker/build-push-action@v5
id: build-2
# continue-on-error: true
timeout-minutes: 40
with:
file: ./images/ubuntu/editor/Dockerfile
build-args: |
baseImage=base:ubuntu-dev
hubImage=hub:ubuntu-dev
version=${{ matrix.version }}
changeSet=${{ env.CHANGESET }}
module=${{ env.MODULE }}
tags: editor:ubuntu-dev
#####################
# Setup to test #
#####################
- name: Show image size
run: docker images
- name: Setup to test
run: |
# For 'linux-il2cpp' module, switch the script backend to 'IL2CPP'
if [ "${{ matrix.module }}" = "linux-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
#############
# Build #
#############
- name: Build project
uses: game-ci/unity-builder@main
timeout-minutes: 35
with:
unityVersion: ${{ matrix.version }}
customImage: editor:ubuntu-dev
projectPath: reference-project-test
targetPlatform: ${{ matrix.platform }}
allowDirtyBuild: true
###########################
# Build (Ubuntu GZip) #
###########################
- name: "⚙️ Setup (Ubuntu GZip)"
if: env.MODULE == 'webgl'
run: |
# Set WebGL compression format to gzip
sed -i -e 's/webGLCompressionFormat: .*$/webGLCompressionFormat: 1/' reference-project-test/ProjectSettings/ProjectSettings.asset
- 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
projectPath: reference-project-test
targetPlatform: ${{ matrix.platform }}
allowDirtyBuild: true
#############################
# Build (Ubuntu Brotli) #
#############################
- name: "⚙️ Setup (Ubuntu Brotli)"
if: env.MODULE == 'webgl'
run: |
# Set WebGL compression format to brotli
sed -i -e 's/webGLCompressionFormat: .*$/webGLCompressionFormat: 0/' reference-project-test/ProjectSettings/ProjectSettings.asset
- 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
projectPath: reference-project-test
targetPlatform: ${{ matrix.platform }}
allowDirtyBuild: true
############
# Test #
############
- name: Test project
timeout-minutes: 10
uses: game-ci/unity-test-runner@main
with:
unityVersion: ${{ matrix.version }}
customImage: editor:ubuntu-dev
projectPath: reference-project-test
customParameters: -nographics -buildTarget ${{ matrix.platform }}
##############################
# Validate Android Utils #
##############################
- name: Validate Android Utils
if: env.MODULE == 'android'
uses: addnab/docker-run-action@v3
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-2022
strategy:
fail-fast: false
matrix:
# The latest patch versions for each minor version.
version: ${{ fromJson(needs.build-matrix.outputs.versions) }}
module:
- base
- windows-il2cpp
- universal-windows-platform
- appletv
- android
include:
- module: base
platform: StandaloneWindows64
- module: windows-il2cpp
platform: StandaloneWindows64
- module: appletv
platform: tvOS
- module: universal-windows-platform
platform: WSAPlayer
- module: android
platform: Android
exclude: ${{ fromJson(needs.build-matrix.outputs.windowsExcludes) }}
steps:
#############
# Setup #
#############
- uses: actions/checkout@v4
############################
# 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: 90
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: 90
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