diff --git a/.eslintrc.json b/.eslintrc.json index 7ff0c589..ce2dfb06 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,22 +1,11 @@ { - "plugins": [ - "jest", - "@typescript-eslint", - "prettier", - "unicorn" - ], - "extends": [ - "plugin:unicorn/recommended", - "plugin:github/recommended", - "plugin:prettier/recommended" - ], + "plugins": ["jest", "@typescript-eslint", "prettier", "unicorn"], + "extends": ["plugin:unicorn/recommended", "plugin:github/recommended", "plugin:prettier/recommended"], "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": 2020, "sourceType": "module", - "extraFileExtensions": [ - ".mjs" - ], + "extraFileExtensions": [".mjs"], "ecmaFeatures": { "impliedStrict": true }, @@ -33,10 +22,7 @@ // Namespaces or sometimes needed "import/no-namespace": "off", // Properly format comments - "spaced-comment": [ - "error", - "always" - ], + "spaced-comment": ["error", "always"], "lines-around-comment": [ "error", { @@ -71,12 +57,7 @@ // Enforce camelCase "camelcase": "error", // Allow forOfStatements - "no-restricted-syntax": [ - "error", - "ForInStatement", - "LabeledStatement", - "WithStatement" - ], + "no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"], // Continue is viable in forOf loops in generators "no-continue": "off", // From experience, named exports are almost always desired. I got tired of this rule diff --git a/.github/workflows/cloud-runner-ci-pipeline.yml b/.github/workflows/cloud-runner-ci-pipeline.yml index efe186b7..bd8969eb 100644 --- a/.github/workflows/cloud-runner-ci-pipeline.yml +++ b/.github/workflows/cloud-runner-ci-pipeline.yml @@ -18,42 +18,37 @@ env: GCP_PROJECT: unitykubernetesbuilder GCP_LOG_FILE: ${{ github.workspace }}/cloud-runner-logs.txt AWS_REGION: eu-west-2 - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: eu-west-2 AWS_STACK_NAME: game-ci-team-pipelines CLOUD_RUNNER_BRANCH: ${{ github.ref }} DEBUG: true - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} PROJECT_PATH: test-project UNITY_VERSION: 2019.3.15f1 USE_IL2CPP: false USE_GKE_GCLOUD_AUTH_PLUGIN: true - GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - smokeTests: - name: Smoke Tests + tests: + name: Tests if: github.event.event_type != 'pull_request_target' runs-on: ubuntu-latest strategy: fail-fast: false matrix: test: - #- 'cloud-runner-async-workflow' + - 'cloud-runner-end2end-locking' + - 'cloud-runner-end2end-caching' + - 'cloud-runner-end2end-retaining' - 'cloud-runner-caching' - # - 'cloud-runner-end2end-caching' - # - 'cloud-runner-end2end-retaining' - 'cloud-runner-environment' + - 'cloud-runner-image' - 'cloud-runner-hooks' - 'cloud-runner-local-persistence' - 'cloud-runner-locking-core' - 'cloud-runner-locking-get-locked' - providerStrategy: - #- aws - - local-docker - #- k8s steps: - name: Checkout (default) uses: actions/checkout@v4 @@ -65,58 +60,85 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: eu-west-2 - - uses: google-github-actions/auth@v1 - if: matrix.providerStrategy == 'k8s' - with: - credentials_json: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} - - name: 'Set up Cloud SDK' - if: matrix.providerStrategy == 'k8s' - uses: 'google-github-actions/setup-gcloud@v1.1.0' - - name: Get GKE cluster credentials - if: matrix.providerStrategy == 'k8s' - run: | - export USE_GKE_GCLOUD_AUTH_PLUGIN=True - gcloud components install gke-gcloud-auth-plugin - gcloud container clusters get-credentials $GKE_CLUSTER --zone $GKE_ZONE --project $GKE_PROJECT - run: yarn - run: yarn run test "${{ matrix.test }}" --detectOpenHandles --forceExit --runInBand - timeout-minutes: 35 + timeout-minutes: 60 env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} PROJECT_PATH: test-project TARGET_PLATFORM: StandaloneWindows64 cloudRunnerTests: true versioning: None - CLOUD_RUNNER_CLUSTER: ${{ matrix.providerStrategy }} - tests: - # needs: - # - smokeTests - # - buildTargetTests - name: Integration Tests + KUBE_STORAGE_CLASS: local-path + PROVIDER_STRATEGY: local-docker + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: | + docker volume rm $(docker volume ls -qf dangling=true) + docker rmi $(docker images -q -f dangling=true) + docker rm $(docker ps -aqf status=exited) + docker rmi $(docker images -q) + k8sTests: + name: K8s Tests + if: github.event.event_type != 'pull_request_target' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + test: + # - 'cloud-runner-async-workflow' + - 'cloud-runner-end2end-locking' + - 'cloud-runner-end2end-caching' + - 'cloud-runner-end2end-retaining' + - 'cloud-runner-kubernetes' + - 'cloud-runner-environment' + - 'cloud-runner-github-checks' + steps: + - name: Checkout (default) + uses: actions/checkout@v2 + with: + lfs: false + - run: yarn + - name: actions-k3s + uses: debianmaster/actions-k3s@v1.0.5 + with: + version: 'latest' + - run: yarn run test "${{ matrix.test }}" --detectOpenHandles --forceExit --runInBand + timeout-minutes: 60 + env: + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} + PROJECT_PATH: test-project + TARGET_PLATFORM: StandaloneWindows64 + cloudRunnerTests: true + versioning: None + KUBE_STORAGE_CLASS: local-path + PROVIDER_STRATEGY: k8s + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + awsTests: + name: AWS Tests if: github.event.event_type != 'pull_request_target' runs-on: ubuntu-latest strategy: fail-fast: false matrix: - providerStrategy: - - aws - - local-docker - - k8s test: - - 'cloud-runner-async-workflow' - #- 'cloud-runner-caching' - 'cloud-runner-end2end-locking' - 'cloud-runner-end2end-caching' - 'cloud-runner-end2end-retaining' - 'cloud-runner-environment' - #- 'cloud-runner-hooks' - 'cloud-runner-s3-steps' - #- 'cloud-runner-local-persistence' - #- 'cloud-runner-locking-core' - #- 'cloud-runner-locking-get-locked' steps: - name: Checkout (default) - uses: actions/checkout@v4 + uses: actions/checkout@v2 with: lfs: false - name: Configure AWS Credentials @@ -125,29 +147,24 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: eu-west-2 - - uses: google-github-actions/auth@v1 - if: matrix.providerStrategy == 'k8s' - with: - credentials_json: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} - - name: 'Set up Cloud SDK' - if: matrix.providerStrategy == 'k8s' - uses: 'google-github-actions/setup-gcloud@v1.1.0' - - name: Get GKE cluster credentials - if: matrix.providerStrategy == 'k8s' - run: | - export USE_GKE_GCLOUD_AUTH_PLUGIN=True - gcloud components install gke-gcloud-auth-plugin - gcloud container clusters get-credentials $GKE_CLUSTER --zone $GKE_ZONE --project $GKE_PROJECT - run: yarn - run: yarn run test "${{ matrix.test }}" --detectOpenHandles --forceExit --runInBand timeout-minutes: 60 env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} PROJECT_PATH: test-project TARGET_PLATFORM: StandaloneWindows64 cloudRunnerTests: true versioning: None - PROVIDER_STRATEGY: ${{ matrix.providerStrategy }} + KUBE_STORAGE_CLASS: local-path + PROVIDER_STRATEGY: aws + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + buildTargetTests: name: Local Build Target Tests runs-on: ubuntu-latest @@ -164,7 +181,7 @@ jobs: - StandaloneLinux64 # Build a Linux 64-bit standalone. - WebGL # WebGL. - iOS # Build an iOS player. - - Android # Build an Android .apk. + # - Android # Build an Android .apk. steps: - name: Checkout (default) uses: actions/checkout@v4 @@ -175,7 +192,13 @@ jobs: id: unity-build timeout-minutes: 30 env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: cloudRunnerTests: true versioning: None @@ -188,3 +211,8 @@ jobs: name: ${{ matrix.providerStrategy }} Build (${{ matrix.targetPlatform }}) path: ${{ steps.unity-build.outputs.BUILD_ARTIFACT }} retention-days: 14 + - run: | + docker volume rm $(docker volume ls -qf dangling=true) + docker rmi $(docker images -q -f dangling=true) + docker rm $(docker ps -aqf status=exited) + docker rmi $(docker images -q) diff --git a/action.yml b/action.yml index e0ccba40..09f95e08 100644 --- a/action.yml +++ b/action.yml @@ -186,11 +186,11 @@ inputs: description: '[CloudRunner] Either local, k8s or aws can be used to run builds on a remote cluster. Additional parameters must be configured.' - cloudRunnerCpu: + containerCpu: default: '' required: false description: '[CloudRunner] Amount of CPU time to assign the remote build container' - cloudRunnerMemory: + containerMemory: default: '' required: false description: '[CloudRunner] Amount of memory to assign the remote build container' diff --git a/dist/index.js b/dist/index.js index 261824a1..bde8c763 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index dcf60dbe..c86b6465 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/dist/platforms/ubuntu/steps/activate.sh b/dist/platforms/ubuntu/steps/activate.sh index 9e051249..9566d92d 100755 --- a/dist/platforms/ubuntu/steps/activate.sh +++ b/dist/platforms/ubuntu/steps/activate.sh @@ -1,5 +1,14 @@ #!/usr/bin/env bash +# if blankproject folder doesn't exist create it +if [ ! -d "/BlankProject" ]; then + mkdir /BlankProject +fi +# if blankproject folder doesn't exist create it +if [ ! -d "/BlankProject/Assets" ]; then + mkdir /BlankProject/Assets +fi + if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then # # SERIAL LICENSE MODE diff --git a/package.json b/package.json index 20f041b5..48d3bbaf 100644 --- a/package.json +++ b/package.json @@ -7,14 +7,14 @@ "author": "Webber ", "license": "MIT", "scripts": { - "prepare": "lefthook install && npx husky uninstall -y", + "prepare": "lefthook install", "build": "yarn && tsc && ncc build lib --source-map --license licenses.txt", "lint": "prettier --check \"src/**/*.{js,ts}\" && eslint src/**/*.ts", "format": "prettier --write \"src/**/*.{js,ts}\"", "cli": "yarn ts-node src/index.ts -m cli", - "gcp-secrets-tests": "cross-env providerStrategy=aws cloudRunnerTests=true readInputOverrideCommand=\"gcp-secret-manager\" populateOverride=true readInputFromOverrideList=UNITY_EMAIL,UNITY_SERIAL,UNITY_PASSWORD yarn test -i -t \"cloud runner\"", - "gcp-secrets-cli": "cross-env cloudRunnerTests=true readInputOverrideCommand=\"gcp-secret-manager\" yarn ts-node src/index.ts -m cli --populateOverride true --readInputFromOverrideList UNITY_EMAIL,UNITY_SERIAL,UNITY_PASSWORD", - "aws-secrets-cli": "cross-env cloudRunnerTests=true readInputOverrideCommand=\"aws-secret-manager\" yarn ts-node src/index.ts -m cli --populateOverride true --readInputFromOverrideList UNITY_EMAIL,UNITY_SERIAL,UNITY_PASSWORD", + "gcp-secrets-tests": "cross-env providerStrategy=aws cloudRunnerTests=true inputPullCommand=\"gcp-secret-manager\" populateOverride=true pullInputList=UNITY_EMAIL,UNITY_SERIAL,UNITY_PASSWORD yarn test -i -t \"cloud runner\"", + "gcp-secrets-cli": "cross-env cloudRunnerTests=true USE_IL2CPP=false inputPullCommand=\"gcp-secret-manager\" yarn ts-node src/index.ts -m cli --populateOverride true --pullInputList UNITY_EMAIL,UNITY_SERIAL,UNITY_PASSWORD", + "aws-secrets-cli": "cross-env cloudRunnerTests=true inputPullCommand=\"aws-secret-manager\" yarn ts-node src/index.ts -m cli --populateOverride true --pullInputList UNITY_EMAIL,UNITY_SERIAL,UNITY_PASSWORD", "cli-aws": "cross-env providerStrategy=aws yarn run test-cli", "cli-k8s": "cross-env providerStrategy=k8s yarn run test-cli", "test-cli": "cross-env cloudRunnerTests=true yarn ts-node src/index.ts -m cli --projectPath test-project", @@ -40,9 +40,11 @@ "commander": "^9.0.0", "commander-ts": "^0.2.0", "kubernetes-client": "^9.0.0", + "md5": "^2.3.0", "nanoid": "^3.3.1", "reflect-metadata": "^0.1.13", "semver": "^7.5.2", + "ts-md5": "^1.3.1", "unity-changeset": "^2.0.0", "uuid": "^9.0.0", "yaml": "^2.2.2" @@ -69,7 +71,7 @@ "js-yaml": "^4.1.0", "prettier": "^2.5.1", "ts-jest": "^27.1.3", - "ts-node": "10.4.0", + "ts-node": "10.8.1", "typescript": "4.7.4", "yarn-audit-fix": "^9.3.8" }, diff --git a/scripts/game-ci.bat b/scripts/game-ci.bat new file mode 100644 index 00000000..d727e302 --- /dev/null +++ b/scripts/game-ci.bat @@ -0,0 +1,15 @@ +echo "installing game-ci cli" +if exist %UserProfile%\AppData\LocalLow\game-ci\ ( + echo Installed Updating + git -C %UserProfile%\AppData\LocalLow\game-ci\ fetch + git -C %UserProfile%\AppData\LocalLow\game-ci\ reset --hard + git -C %UserProfile%\AppData\LocalLow\game-ci\ pull + git -C %UserProfile%\AppData\LocalLow\game-ci\ branch +) else ( + echo Not Installed Downloading... + mkdir %UserProfile%\AppData\LocalLow\game-ci\ + git clone https://github.com/game-ci/unity-builder %UserProfile%\AppData\LocalLow\game-ci\ +) + +call yarn --cwd %UserProfile%\AppData\LocalLow\game-ci\ install +call yarn --cwd %UserProfile%\AppData\LocalLow\game-ci\ run gcp-secrets-cli %* --projectPath %cd% --awsStackName game-ci-cli diff --git a/src/index.ts b/src/index.ts index 89db2de3..2d40bd1d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,6 +34,7 @@ async function runMain() { }); } else { await CloudRunner.run(buildParameters, baseImage.toString()); + exitCode = 0; } // Set output diff --git a/src/model/cli/cli.ts b/src/model/cli/cli.ts index a2eed108..739154a6 100644 --- a/src/model/cli/cli.ts +++ b/src/model/cli/cli.ts @@ -10,8 +10,6 @@ import { LfsHashing } from '../cloud-runner/services/utility/lfs-hashing'; import { RemoteClient } from '../cloud-runner/remote-client'; import CloudRunnerOptionsReader from '../cloud-runner/options/cloud-runner-options-reader'; import GitHub from '../github'; -import { CloudRunnerFolders } from '../cloud-runner/options/cloud-runner-folders'; -import { CloudRunnerSystem } from '../cloud-runner/services/core/cloud-runner-system'; import { OptionValues } from 'commander'; import { InputKey } from '../input'; @@ -54,6 +52,7 @@ export class Cli { program.option('--cachePushTo ', 'cache push to caching folder'); program.option('--artifactName ', 'caching artifact name'); program.option('--select