fix: Action did not work on Windows runners. (#257)

* Remove symlink files

* Update entrypoint scripts for windows runner

* Add windows runner tests

* Fix unity editor path

* Set -nographics option for avoid d3d11 initialization error

* Fix Unity project path in windows standalone build script
pull/267/head
Sokuhatiku 2024-03-21 22:12:35 +09:00 committed by GitHub
parent 35b5a08132
commit 75d0d76deb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 1415 additions and 1450 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; } # - 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: testAllModesLikeInTheReadme:
name: Test in ${{ matrix.testMode }} on version ${{ matrix.unityVersion }} name: Test in ${{ matrix.testMode }} of version ${{ matrix.unityVersion }} on ${{ matrix.baseRunner }}
runs-on: ubuntu-latest runs-on: ${{ matrix.baseRunner }}
strategy: strategy:
fail-fast: false fail-fast: false
max-parallel: 2
matrix: matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath: projectPath:
- unity-project-with-correct-tests - unity-project-with-correct-tests
unityVersion: unityVersion:
@ -57,9 +61,9 @@ jobs:
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }} key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: | restore-keys: |
Library- Library-${{ matrix.baseRunner }}
- uses: ./ - uses: ./
id: tests id: tests
with: with:
@ -76,10 +80,13 @@ jobs:
testRunnerInAllModes: testRunnerInAllModes:
name: Test all modes ✨ name: Test all modes ✨
runs-on: ubuntu-latest runs-on: ${{ matrix.baseRunner }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath: projectPath:
- unity-project-with-correct-tests - unity-project-with-correct-tests
unityVersion: unityVersion:
@ -100,10 +107,9 @@ jobs:
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: | restore-keys: |
Library-${{ matrix.projectPath }}- Library-${{ matrix.baseRunner }}
Library-
# Configure test runner # Configure test runner
- name: Run tests - name: Run tests
@ -134,10 +140,13 @@ jobs:
testRunnerInEditMode: testRunnerInEditMode:
name: Test edit mode 📝 name: Test edit mode 📝
runs-on: ubuntu-latest runs-on: ${{ matrix.baseRunner }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
baseRunner:
- ubuntu-latest
- windows-latest
unityVersion: unityVersion:
- 2022.3.13f1 - 2022.3.13f1
- 2023.1.19f1 - 2023.1.19f1
@ -161,10 +170,9 @@ jobs:
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: | restore-keys: |
Library-${{ matrix.projectPath }}- Library-${{ matrix.baseRunner }}
Library-
# Configure test runner # Configure test runner
- name: Run tests - name: Run tests
@ -195,10 +203,13 @@ jobs:
testRunnerInPlayMode: testRunnerInPlayMode:
name: Test play mode 📺 name: Test play mode 📺
runs-on: ubuntu-latest runs-on: ${{ matrix.baseRunner }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath: projectPath:
- unity-project-with-correct-tests - unity-project-with-correct-tests
unityVersion: unityVersion:
@ -219,10 +230,9 @@ jobs:
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: | restore-keys: |
Library-${{ matrix.projectPath }}- Library-${{ matrix.baseRunner }}
Library-
# Configure test runner # Configure test runner
- name: Run tests - name: Run tests
@ -252,10 +262,13 @@ jobs:
testRunnerInStandalone: testRunnerInStandalone:
name: Test standalone 📺 name: Test standalone 📺
runs-on: ubuntu-latest runs-on: ${{ matrix.baseRunner }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath: projectPath:
- unity-project-with-correct-tests - unity-project-with-correct-tests
unityVersion: unityVersion:
@ -276,10 +289,10 @@ jobs:
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
restore-keys: | restore-keys: |
Library-${{ matrix.projectPath }}- Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}-
Library- Library-${{ matrix.baseRunner }}-
# Configure test runner # Configure test runner
- name: Run tests - name: Run tests
@ -301,10 +314,13 @@ jobs:
testRunnerInStandaloneWithIL2CPP: testRunnerInStandaloneWithIL2CPP:
name: Test standalone with IL2CPP 📺 name: Test standalone with IL2CPP 📺
runs-on: ubuntu-latest runs-on: ${{ matrix.baseRunner }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
baseRunner:
- ubuntu-latest
- windows-latest
projectPath: projectPath:
- unity-project-with-correct-tests - unity-project-with-correct-tests
unityVersion: unityVersion:
@ -325,10 +341,9 @@ jobs:
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: | restore-keys: |
Library-${{ matrix.projectPath }}- Library-${{ matrix.baseRunner }}-
Library-
# Set scripting backend to IL2CPP # Set scripting backend to IL2CPP
- name: Rewrite ProjectSettings - name: Rewrite ProjectSettings
@ -336,6 +351,7 @@ jobs:
DefineOriginal=" scriptingBackend: {}" DefineOriginal=" scriptingBackend: {}"
DefineReplace=" scriptingBackend: \\n Standalone: 1" DefineReplace=" scriptingBackend: \\n Standalone: 1"
sed -i "{s/$DefineOriginal/$DefineReplace/g}" ${{ matrix.projectPath }}/ProjectSettings/ProjectSettings.asset sed -i "{s/$DefineOriginal/$DefineReplace/g}" ${{ matrix.projectPath }}/ProjectSettings/ProjectSettings.asset
shell: bash
# Configure test runner # Configure test runner
- name: Run tests - name: Run tests
@ -357,10 +373,13 @@ jobs:
testEachModeSequentially: testEachModeSequentially:
name: Test each mode sequentially 👩‍👩‍👧‍👦 # don't try this at home (it's much slower) name: Test each mode sequentially 👩‍👩‍👧‍👦 # don't try this at home (it's much slower)
runs-on: ubuntu-latest runs-on: ${{ matrix.baseRunner }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
baseRunner:
- ubuntu-latest
- windows-latest
unityVersion: unityVersion:
- 2022.3.13f1 - 2022.3.13f1
- 2023.1.19f1 - 2023.1.19f1
@ -381,10 +400,9 @@ jobs:
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.baseRunner }}-${{ matrix.projectPath }}
restore-keys: | restore-keys: |
Library-${{ matrix.projectPath }}- Library-${{ matrix.baseRunner }}-
Library-
# Configure first test runner # Configure first test runner
- name: Tests in editmode 📝 - name: Tests in editmode 📝

74
dist/index.js generated vendored
View File

@ -1,57 +1,6 @@
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({ /******/ var __webpack_modules__ = ({
/***/ 4822:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const main_1 = __nccwpck_require__(3109);
const path_1 = __importDefault(__nccwpck_require__(1017));
const post_1 = __nccwpck_require__(95);
/*
* 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".
*/
function run([, name = 'main.js']) {
return __awaiter(this, void 0, void 0, function* () {
const script = path_1.default.basename(name);
switch (script) {
case 'main.js':
yield (0, main_1.run)();
break;
case 'post.js':
yield (0, post_1.run)();
break;
default:
throw new Error(`Unknown script argument: '${script}'`);
}
});
}
run(process.argv);
/***/ }),
/***/ 3109: /***/ 3109:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
@ -23415,13 +23364,22 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/ /******/
/************************************************************************/ /************************************************************************/
/******/ var __webpack_exports__ = {};
/******/ // startup // This entry need to be wrapped in an IIFE because it need to be in strict mode.
/******/ // Load entry module and return exports (() => {
/******/ // This entry module is referenced by other modules so it can't be inlined "use strict";
/******/ var __webpack_exports__ = __nccwpck_require__(4822); var exports = __webpack_exports__;
/******/ module.exports = __webpack_exports__;
/******/ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.post = exports.main = void 0;
var main_1 = __nccwpck_require__(3109);
Object.defineProperty(exports, "main", ({ enumerable: true, get: function () { return main_1.run; } }));
var post_1 = __nccwpck_require__(95);
Object.defineProperty(exports, "post", ({ enumerable: true, get: function () { return post_1.run; } }));
})();
module.exports = __webpack_exports__;
/******/ })() /******/ })()
; ;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

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 100644
View File

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

View File

@ -67,24 +67,24 @@ foreach ( $platform in ${env:TEST_PLATFORMS}.Split(";") )
Write-Output "" Write-Output ""
# Create directories if they do not exist # 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 # 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 # We use -Force to suppress output, doesn't overwrite anything
New-Item -ItemType Directory -Force -Path $Env:UNITY_PROJECT_PATH\Assets\Player New-Item -ItemType Directory -Force -Path $Env:UNITY_PROJECT_PATH\Assets\Player
} }
# Copy the scripts # Copy the scripts
Copy-Item -Path "c:\UnityStandaloneScripts\Assets\Editor" -Destination $Env:UNITY_PROJECT_PATH\Assets\Editor -Recurse Copy-Item -Path "c:\UnityStandaloneScripts\Assets\Editor" -Destination $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\Player" -Destination $UNITY_PROJECT_PATH\Assets\Player -Recurse
# Verify recursive paths # Verify recursive paths
Get-ChildItem -Path $Env:UNITY_PROJECT_PATH\Assets\Editor -Recurse Get-ChildItem -Path $UNITY_PROJECT_PATH\Assets\Editor -Recurse
Get-ChildItem -Path $Env:UNITY_PROJECT_PATH\Assets\Player -Recurse Get-ChildItem -Path $UNITY_PROJECT_PATH\Assets\Player -Recurse
$runTests="-runTests -testPlatform StandaloneWindows64 -builtTestRunnerPath $UNITY_PROJECT_PATH\Build\UnityTestRunner-Standalone.exe" $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 # Catch exit code
$TEST_EXIT_CODE = $TEST_OUTPUT.ExitCode $TEST_EXIT_CODE = $TEST_OUTPUT.ExitCode

1
dist/post.js vendored
View File

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

3
dist/post.js vendored 100644
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'; export { run as main } from './main';
import path from 'path'; export { run as post } from './post';
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);