Compare commits

...

8 Commits

Author SHA1 Message Date
Gabriel Le Breton
32df7d8e80 Update dist files permissions to 644 2024-01-21 20:59:20 -05:00
Sokuhatiku
52b336a8c9 Fix Unity project path in windows standalone build script 2024-01-10 00:10:34 +09:00
Sokuhatiku
b19f319cde Set -nographics option for avoid d3d11 initialization error 2024-01-07 01:54:11 +09:00
Sokuhatiku
3e4f69fa9e Fix unity editor path 2024-01-07 01:51:51 +09:00
Sokuhatiku
dc953e9a37 Add windows runner tests 2024-01-05 23:37:06 +09:00
Sokuhatiku
dea8579ade Update entrypoint scripts for windows runner 2024-01-05 00:22:23 +09:00
Sokuhatiku
e1ebe51bcf Remove symlink files 2024-01-04 18:49:16 +09:00
Falko
7c242f70d9 Set fullProjectPath variable in entrypoint.sh (#256)
* Set fullProjectPath variable in entrypoint.sh (#255)

* Add test that runs as host user

This should catch bugs like the one described in #255.
2023-12-25 11:53:38 +01:00
8 changed files with 1405 additions and 1434 deletions

View File

@@ -27,11 +27,15 @@ jobs:
# - run: yarn build --quiet && git diff --quiet action || { echo "ERROR - index.js is different from repository version. Forgot to run `yarn build`?" ; exit 62; }
testAllModesLikeInTheReadme:
name: Test in ${{ matrix.testMode }} on version ${{ matrix.unityVersion }}
runs-on: ubuntu-latest
name: Test in ${{ matrix.testMode }} of version ${{ matrix.unityVersion }} on ${{ matrix.baseRunner }}
runs-on: ${{ matrix.baseRunner }}
strategy:
fail-fast: false
max-parallel: 2
matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath:
- unity-project-with-correct-tests
unityVersion:
@@ -57,9 +61,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}
key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: |
Library-
Library-${{ matrix.baseRunner }}
- uses: ./
id: tests
with:
@@ -76,10 +80,13 @@ jobs:
testRunnerInAllModes:
name: Test all modes ✨
runs-on: ubuntu-latest
runs-on: ${{ matrix.baseRunner }}
strategy:
fail-fast: false
matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath:
- unity-project-with-correct-tests
unityVersion:
@@ -100,10 +107,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
Library-${{ matrix.baseRunner }}
# Configure test runner
- name: Run tests
@@ -134,16 +140,22 @@ jobs:
testRunnerInEditMode:
name: Test edit mode 📝
runs-on: ubuntu-latest
runs-on: ${{ matrix.baseRunner }}
strategy:
fail-fast: false
matrix:
baseRunner:
- ubuntu-latest
- windows-latest
unityVersion:
- 2022.3.13f1
- 2023.1.19f1
- 2023.2.2f1
projectPath:
- unity-project-with-correct-tests
runAsHostUser:
- true
- false
steps:
###########################
# Checkout #
@@ -158,10 +170,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
Library-${{ matrix.baseRunner }}
# Configure test runner
- name: Run tests
@@ -170,6 +181,7 @@ jobs:
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
runAsHostUser: ${{ matrix.runAsHostUser }}
testMode: editmode
artifactsPath: artifacts/editmode
@@ -191,10 +203,13 @@ jobs:
testRunnerInPlayMode:
name: Test play mode 📺
runs-on: ubuntu-latest
runs-on: ${{ matrix.baseRunner }}
strategy:
fail-fast: false
matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath:
- unity-project-with-correct-tests
unityVersion:
@@ -215,10 +230,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
Library-${{ matrix.baseRunner }}
# Configure test runner
- name: Run tests
@@ -248,10 +262,13 @@ jobs:
testRunnerInStandalone:
name: Test standalone 📺
runs-on: ubuntu-latest
runs-on: ${{ matrix.baseRunner }}
strategy:
fail-fast: false
matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath:
- unity-project-with-correct-tests
unityVersion:
@@ -272,10 +289,10 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}-
Library-${{ matrix.baseRunner }}-
# Configure test runner
- name: Run tests
@@ -297,10 +314,13 @@ jobs:
testRunnerInStandaloneWithIL2CPP:
name: Test standalone with IL2CPP 📺
runs-on: ubuntu-latest
runs-on: ${{ matrix.baseRunner }}
strategy:
fail-fast: false
matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath:
- unity-project-with-correct-tests
unityVersion:
@@ -321,10 +341,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
Library-${{ matrix.baseRunner }}-
# Set scripting backend to IL2CPP
- name: Rewrite ProjectSettings
@@ -332,6 +351,7 @@ jobs:
DefineOriginal=" scriptingBackend: {}"
DefineReplace=" scriptingBackend: \\n Standalone: 1"
sed -i "{s/$DefineOriginal/$DefineReplace/g}" ${{ matrix.projectPath }}/ProjectSettings/ProjectSettings.asset
shell: bash
# Configure test runner
- name: Run tests
@@ -353,10 +373,13 @@ jobs:
testEachModeSequentially:
name: Test each mode sequentially 👩‍👩‍👧‍👦 # don't try this at home (it's much slower)
runs-on: ubuntu-latest
runs-on: ${{ matrix.baseRunner }}
strategy:
fail-fast: false
matrix:
baseRunner:
- ubuntu-latest
- windows-latest
unityVersion:
- 2022.3.13f1
- 2023.1.19f1
@@ -377,10 +400,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
Library-${{ matrix.baseRunner }}-
# Configure first test runner
- name: Tests in editmode 📝

2688
dist/index.js generated vendored

File diff suppressed because it is too large Load Diff

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

1
dist/main.js vendored
View File

@@ -1 +0,0 @@
index.js

3
dist/main.js vendored Normal file
View File

@@ -0,0 +1,3 @@
const index = require('./index.js');
index.main();

View File

@@ -9,6 +9,8 @@ fi
if [[ "$RUN_AS_HOST_USER" == "true" ]]; then
echo "Running as host user"
fullProjectPath="$GITHUB_WORKSPACE/$PROJECT_PATH"
# Stop on error if we can't set up the user
set -e

View File

@@ -67,24 +67,24 @@ foreach ( $platform in ${env:TEST_PLATFORMS}.Split(";") )
Write-Output ""
# Create directories if they do not exist
if(-Not (Test-Path -Path $Env:UNITY_PROJECT_PATH\Assets\Editor))
if(-Not (Test-Path -Path $UNITY_PROJECT_PATH\Assets\Editor))
{
# We use -Force to suppress output, doesn't overwrite anything
New-Item -ItemType Directory -Force -Path $Env:UNITY_PROJECT_PATH\Assets\Editor
New-Item -ItemType Directory -Force -Path $UNITY_PROJECT_PATH\Assets\Editor
}
if(-Not (Test-Path -Path $Env:UNITY_PROJECT_PATH\Assets\Player))
if(-Not (Test-Path -Path $UNITY_PROJECT_PATH\Assets\Player))
{
# We use -Force to suppress output, doesn't overwrite anything
New-Item -ItemType Directory -Force -Path $Env:UNITY_PROJECT_PATH\Assets\Player
}
# Copy the scripts
Copy-Item -Path "c:\UnityStandaloneScripts\Assets\Editor" -Destination $Env:UNITY_PROJECT_PATH\Assets\Editor -Recurse
Copy-Item -Path "c:\UnityStandaloneScripts\Assets\Player" -Destination $Env:UNITY_PROJECT_PATH\Assets\Player -Recurse
Copy-Item -Path "c:\UnityStandaloneScripts\Assets\Editor" -Destination $UNITY_PROJECT_PATH\Assets\Editor -Recurse
Copy-Item -Path "c:\UnityStandaloneScripts\Assets\Player" -Destination $UNITY_PROJECT_PATH\Assets\Player -Recurse
# Verify recursive paths
Get-ChildItem -Path $Env:UNITY_PROJECT_PATH\Assets\Editor -Recurse
Get-ChildItem -Path $Env:UNITY_PROJECT_PATH\Assets\Player -Recurse
Get-ChildItem -Path $UNITY_PROJECT_PATH\Assets\Editor -Recurse
Get-ChildItem -Path $UNITY_PROJECT_PATH\Assets\Player -Recurse
$runTests="-runTests -testPlatform StandaloneWindows64 -builtTestRunnerPath $UNITY_PROJECT_PATH\Build\UnityTestRunner-Standalone.exe"
}
@@ -106,7 +106,20 @@ foreach ( $platform in ${env:TEST_PLATFORMS}.Split(";") )
}
}
$TEST_OUTPUT = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${env:UNITY_VERSION}\editor\Unity.exe" -ArgumentList "-batchmode -logFile $FULL_ARTIFACTS_PATH\$platform.log -projectPath $UNITY_PROJECT_PATH -coverageResultsPath $FULL_COVERAGE_RESULTS_PATH $runTests -enableCodeCoverage -debugCodeOptimization -coverageOptions ${env:COVERAGE_OPTIONS} ${env:CUSTOM_PARAMETERS}"
$TEST_OUTPUT = Start-Process -FilePath "$Env:UNITY_PATH/Editor/Unity.exe" `
-NoNewWindow `
-Wait `
-PassThru `
-ArgumentList "-batchmode `
-nographics `
-logFile $FULL_ARTIFACTS_PATH\$platform.log `
-projectPath $UNITY_PROJECT_PATH `
-coverageResultsPath $FULL_COVERAGE_RESULTS_PATH `
$runTests `
-enableCodeCoverage `
-debugCodeOptimization `
-coverageOptions ${env:COVERAGE_OPTIONS} `
${env:CUSTOM_PARAMETERS}"
# Catch exit code
$TEST_EXIT_CODE = $TEST_OUTPUT.ExitCode

1
dist/post.js vendored
View File

@@ -1 +0,0 @@
index.js

3
dist/post.js vendored Normal file
View File

@@ -0,0 +1,3 @@
const index = require('./index.js');
index.post();

View File

@@ -1,30 +1,2 @@
import { run as main } from './main';
import path from 'path';
import { run as post } from './post';
/*
* GitHub Action can provide multiple executable entrypoints (pre, main, post),
* but it is complicated process to generate multiple `.js` files with `ncc`.
* So we rather generate just one entrypoint, that is symlinked to multiple locations (main.js and post.js).
* Then when GitHub Action Runner executes it as `node path/to/main.js` and `node path/to/post.js`,
* it can read arguments it was executed with and decide which file to execute.
* The argv[0] is going to be a full path to `node` executable and
* the argv[1] is going to be the full path to the script.
* In case index.js would be marked executable and executed directly without the argv[1] it defaults to "main.js".
*/
async function run([, name = 'main.js']: string[]) {
const script = path.basename(name);
switch (script) {
case 'main.js':
await main();
break;
case 'post.js':
await post();
break;
default:
throw new Error(`Unknown script argument: '${script}'`);
}
}
run(process.argv);
export { run as main } from './main';
export { run as post } from './post';