diff --git a/.github/workflows/build-smoke-test.yml b/.github/workflows/build-smoke-test.yml new file mode 100644 index 00000000..558e4f9e --- /dev/null +++ b/.github/workflows/build-smoke-test.yml @@ -0,0 +1,138 @@ +name: Build Smoke Test +run-name: build-smoke-test +on: + pull_request: + branches: # Made towards the following + - main + - dev* + types: # Only on the following activity + - opened + - synchronize # Changes to the branch like new commits, ammends, etc. + push: + branches: # Made towards the following + - main + tags: + - v** + workflow_dispatch: {} + +jobs: + build-smoke-test: + name: Build smoke test + runs-on: [ubuntu-latest] + #runs-on: [k8s] + #container: + # image: ubuntu-latest + env: + LL_USE_STAGE: false + strategy: + fail-fast: false + matrix: + testMode: + - playmode + unityVersion: + - 2019.4.40f1 + - 2020.3.48f1 + - 2021.3.32f1 + - 2022.3.14f1 + - 2023.2.1f1 + targetPlatform: + - StandaloneLinux64 + - WebGL + steps: + - name: Setup commandline dependencies (if on self-hosted runner) + if: ${{ env.LL_USE_STAGE == 'true' }} + run: | + apt update + apt-get install -y git + git config --global --add safe.directory unity-sdk + git config --global --add safe.directory unity-sdk-smoketest-project + apt-get install -y jq + apt-get install -y sed + apt-get install -y docker + apt-get install -y curl + apt-get update + apt-get install ca-certificates curl gnupg + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + chmod a+r /etc/apt/keyrings/docker.gpg + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + tee /etc/apt/sources.list.d/docker.list > /dev/null + apt-get update + apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + - name: Select stage keys + if: ${{ env.LL_USE_STAGE == 'true' }} + run: | + echo "JOB_API_KEY=${{ SECRETS.SMOKE_TEST_LL_API_KEY }}" >> $GITHUB_ENV + echo "JOB_DOMAIN_KEY=${{ SECRETS.SMOKE_TEST_LL_DOMAIN_KEY }}" >> $GITHUB_ENV + - name: Select prod keys + if: ${{ env.LL_USE_STAGE == 'false' }} + run: | + echo "JOB_API_KEY=${{ SECRETS.LOOTLOCKER_API_KEY }}" >> $GITHUB_ENV + echo "JOB_DOMAIN_KEY=${{ SECRETS.LOOTLOCKER_DOMAIN_KEY }}" >> $GITHUB_ENV + - name: Checkout unity-sdk repository + uses: actions/checkout@v3 + with: + path: unity-sdk + - name: Checkout unity-sdk-smoketest-project repository + uses: actions/checkout@v3 + with: + repository: lootlocker/unity-sdk-smoketest-project + path: unity-sdk-smoketest-project + token: ${{ SECRETS.LL_PERSONAL_ACCESS_TOKEN }} + - name: Set package reference to local unity-sdk + run: | + echo "Updating unity-sdk-smoketest-project/Packages/manifest.json to use lootlocker sdk at relative path (from manifest) ../../unity-sdk" + jq ".\"dependencies\".\"com.lootlocker.lootlockersdk\"=\"file:../../unity-sdk\"" "unity-sdk-smoketest-project/Packages/manifest.json" > "unity-sdk-smoketest-project/Packages/tempmanifest.json" + rm "unity-sdk-smoketest-project/Packages/manifest.json" + mv "unity-sdk-smoketest-project/Packages/tempmanifest.json" "unity-sdk-smoketest-project/Packages/manifest.json" + - name: Configure LootLocker to take keys by commandline + run: | + sed -i 's/NO_LOOTLOCKER_COMMANDLINE_SETTINGS/LOOTLOCKER_COMMANDLINE_SETTINGS/' unity-sdk-smoketest-project/ProjectSettings/ProjectSettings.asset + - name: Configure LootLocker to target stage environment + if: ${{ env.LL_USE_STAGE == 'true' }} + run: | + sed -i 's/NO_LOOTLOCKER_TARGET_STAGE_ENV/LOOTLOCKER_TARGET_STAGE_ENV/' unity-sdk-smoketest-project/ProjectSettings/ProjectSettings.asset + - name: Commit all changes to allow building + run: | + git config --global user.email "fake@email.com" + git config --global user.name "Fake Name" + cd unity-sdk-smoketest-project + git add -A + git commit -m "Temporary changes for build" + - uses: actions/cache@v3 + with: + path: unity-sdk-smoketest-project/Library + key: ${{ matrix.targetPlatform }}-Library-unity-sdk-smoketest-project + restore-keys: | + ${{ matrix.targetPlatform }}-Library-unity-sdk-smoketest-project + Library- + - name: Run Smoke Tests ${{ matrix.unityVersion }}-${{ matrix.testMode }}-${{ matrix.targetPlatform }} + id: build-smoke-tests-gameci + uses: game-ci/unity-builder@v4 + env: + UNITY_LICENSE: ${{ SECRETS.UNITY_LICENSE }} + UNITY_EMAIL: ${{ SECRETS.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ SECRETS.UNITY_PASSWORD }} + with: + unityVersion: ${{ matrix.unityVersion }} + targetPlatform: ${{ matrix.targetPlatform }} + buildsPath: builds + buildName: smokeTest + projectPath: unity-sdk-smoketest-project + customParameters: -apikey ${{ ENV.JOB_API_KEY }} -domainkey ${{ ENV.JOB_DOMAIN_KEY }} + - name: Run the built game (valid for Linux) + if: ${{ matrix.targetPlatform == 'StandaloneLinux64' }} + run: | + sudo chmod 777 ./builds + sudo chmod 777 ./builds/${{ matrix.targetPlatform }}/ + sudo chmod 777 ./builds/${{ matrix.targetPlatform }}/* + ./builds/${{ matrix.targetPlatform }}/smokeTest -batchmode -nographics -apikey ${{ ENV.JOB_API_KEY }} -domainkey ${{ ENV.JOB_DOMAIN_KEY }} + while [ ! -f "./builds/${{ matrix.targetPlatform }}/smokeTest_Data/LLActorOutput.txt" ]; do sleep 10; ls -als ./builds/${{ matrix.targetPlatform }}/smokeTest_Data/; done + - name: Test the output of the run (valid for Linux) + if: ${{ matrix.targetPlatform == 'StandaloneLinux64' }} + run: | + cat ./builds/${{ matrix.targetPlatform }}/smokeTest_Data/LLActorOutput.txt + grep -q "Run Succeeded" ./builds/${{ matrix.targetPlatform }}/smokeTest_Data/LLActorOutput.txt + exit $? diff --git a/.github/workflows/editor-smoke-test.yml b/.github/workflows/editor-smoke-test.yml new file mode 100644 index 00000000..4817ccc1 --- /dev/null +++ b/.github/workflows/editor-smoke-test.yml @@ -0,0 +1,115 @@ +name: Editor Smoke Test +run-name: editor-smoke-test +on: + pull_request: + branches: # Made towards the following + - main + - dev* + types: # Only on the following activity + - opened + - synchronize # Changes to the branch like new commits, ammends, etc. + push: + branches: # Made towards the following + - main + tags: + - v** + workflow_dispatch: {} + +jobs: + editor-smoke-test: + name: Editor smoke test + runs-on: [ubuntu-latest] + #runs-on: [k8s] + #container: + # image: ubuntu-latest + env: + LL_USE_STAGE: false + strategy: + fail-fast: false + matrix: + testMode: + - playmode + unityVersion: + - 2019.4.40f1 + - 2020.3.48f1 + - 2021.3.32f1 + - 2022.3.14f1 + - 2023.2.1f1 + steps: + - name: Setup commandline dependencies (if on self-hosted runner) + if: ${{ env.LL_USE_STAGE == 'true' }} + run: | + apt update + apt-get install -y git + git config --global --add safe.directory unity-sdk + git config --global --add safe.directory unity-sdk-smoketest-project + apt-get install -y jq + apt-get install -y sed + apt-get install -y docker + apt-get install -y curl + apt-get update + apt-get install ca-certificates curl gnupg + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + chmod a+r /etc/apt/keyrings/docker.gpg + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + tee /etc/apt/sources.list.d/docker.list > /dev/null + apt-get update + apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + - name: Select stage keys + if: ${{ env.LL_USE_STAGE == 'true' }} + run: | + echo "JOB_API_KEY=${{ SECRETS.SMOKE_TEST_LL_API_KEY }}" >> $GITHUB_ENV + echo "JOB_DOMAIN_KEY=${{ SECRETS.SMOKE_TEST_LL_DOMAIN_KEY }}" >> $GITHUB_ENV + - name: Select prod keys + if: ${{ env.LL_USE_STAGE == 'false' }} + run: | + echo "JOB_API_KEY=${{ SECRETS.LOOTLOCKER_API_KEY }}" >> $GITHUB_ENV + echo "JOB_DOMAIN_KEY=${{ SECRETS.LOOTLOCKER_DOMAIN_KEY }}" >> $GITHUB_ENV + - name: Checkout unity-sdk repository + uses: actions/checkout@v3 + with: + path: unity-sdk + - name: Checkout unity-sdk-smoketest-project repository + uses: actions/checkout@v3 + with: + repository: lootlocker/unity-sdk-smoketest-project + path: unity-sdk-smoketest-project + token: ${{ SECRETS.LL_PERSONAL_ACCESS_TOKEN }} + - name: Set package reference to local unity-sdk + run: | + echo "Updating unity-sdk-smoketest-project/Packages/manifest.json to use lootlocker sdk at relative path (from manifest) ../../unity-sdk" + jq ".\"dependencies\".\"com.lootlocker.lootlockersdk\"=\"file:../../unity-sdk\"" "unity-sdk-smoketest-project/Packages/manifest.json" > "unity-sdk-smoketest-project/Packages/tempmanifest.json" + rm "unity-sdk-smoketest-project/Packages/manifest.json" + mv "unity-sdk-smoketest-project/Packages/tempmanifest.json" "unity-sdk-smoketest-project/Packages/manifest.json" + - name: Configure LootLocker to take keys by commandline + run: | + sed -i 's/NO_LOOTLOCKER_COMMANDLINE_SETTINGS/LOOTLOCKER_COMMANDLINE_SETTINGS/' unity-sdk-smoketest-project/ProjectSettings/ProjectSettings.asset + - name: Configure LootLocker to target stage environment + if: ${{ env.LL_USE_STAGE == 'true' }} + run: | + sed -i 's/NO_LOOTLOCKER_TARGET_STAGE_ENV/LOOTLOCKER_TARGET_STAGE_ENV/' unity-sdk-smoketest-project/ProjectSettings/ProjectSettings.asset + - uses: actions/cache@v3 + with: + path: unity-sdk-smoketest-project/Library + key: ${{ matrix.targetPlatform }}-Library-unity-sdk-smoketest-project + restore-keys: | + ${{ matrix.targetPlatform }}-Library-unity-sdk-smoketest-project + Library- + - name: Run Smoke Tests ${{ matrix.unityVersion }}-${{ matrix.testMode }} + id: editor-smoke-tests-gameci + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ SECRETS.UNITY_LICENSE }} + UNITY_EMAIL: ${{ SECRETS.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ SECRETS.UNITY_PASSWORD }} + with: + testMode: ${{ matrix.testMode }} + checkName: ${{ matrix.unityVersion }}-${{ matrix.testMode }} Test Results + artifactsPath: editor-smoke-tests-gameci-${{ matrix.unityVersion }}-${{ matrix.testMode }}-artifacts + projectPath: unity-sdk-smoketest-project + unityVersion: ${{ matrix.unityVersion }} + githubToken: ${{ SECRETS.GITHUB_TOKEN }} + customParameters: -apikey ${{ ENV.JOB_API_KEY }} -domainkey ${{ ENV.JOB_DOMAIN_KEY }} \ No newline at end of file diff --git a/.github/workflows/package-sdk.yml b/.github/workflows/package-sdk.yml new file mode 100644 index 00000000..c6517793 --- /dev/null +++ b/.github/workflows/package-sdk.yml @@ -0,0 +1,105 @@ +name: Package SDK +run-name: package-sdk +on: + push: + branches: # Made towards the following + - main + - dev + tags: + - v** + workflow_dispatch: {} + +jobs: + package-sdk: + name: Package SDK + runs-on: [ubuntu-latest] + #runs-on: [k8s] + #container: + # image: ubuntu-latest + env: + LL_USE_STAGE: false + strategy: + fail-fast: false + matrix: + unityVersion: + - 2019.4.40f1 + - 2020.3.48f1 + - 2021.3.32f1 + - 2022.3.14f1 + - 2023.2.1f1 + steps: + - name: Setup commandline dependencies (if on self-hosted runner) + if: ${{ env.LL_USE_STAGE == 'true' }} + run: | + apt update + apt-get install -y git + git config --global --add safe.directory unity-sdk + git config --global --add safe.directory unity-sdk-packager + apt-get install -y jq + apt-get install -y sed + apt-get install -y docker + apt-get install -y curl + apt-get update + apt-get install ca-certificates curl gnupg + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + chmod a+r /etc/apt/keyrings/docker.gpg + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + tee /etc/apt/sources.list.d/docker.list > /dev/null + apt-get update + apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + - name: Checkout unity-sdk repository + uses: actions/checkout@v3 + with: + path: unity-sdk + - name: Checkout unity-sdk-packager-project repository + uses: actions/checkout@v3 + with: + repository: lootlocker/unity-sdk-packager + path: unity-sdk-packager + token: ${{ SECRETS.LL_PERSONAL_ACCESS_TOKEN }} + - name: Add LootLockerSDK as asset folder + run: | + cp -r unity-sdk unity-sdk-packager/Assets/LootLockerSDK + - uses: actions/cache@v3 + with: + path: unity-sdk-packager/Library + key: ${{ matrix.targetPlatform }}-Library-unity-sdk-packager + restore-keys: | + ${{ matrix.targetPlatform }}-Library-unity-sdk-packager + Library- + - name: Compile and run all sample scenes ${{ matrix.unityVersion }} + id: run-sdk-samples + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ SECRETS.UNITY_LICENSE }} + UNITY_EMAIL: ${{ SECRETS.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ SECRETS.UNITY_PASSWORD }} + with: + testMode: editmode + checkName: Sample Scene ${{ matrix.unityVersion }} Test Results + artifactsPath: run-sdk-samples-${{ matrix.unityVersion }}-artifacts + projectPath: unity-sdk-packager + unityVersion: ${{ matrix.unityVersion }} + githubToken: ${{ SECRETS.GITHUB_TOKEN }} + - name: Package SDK for ${{ matrix.unityVersion }} + id: package-sdk-gameci + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ SECRETS.UNITY_LICENSE }} + UNITY_EMAIL: ${{ SECRETS.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ SECRETS.UNITY_PASSWORD }} + with: + testMode: playmode + checkName: SDK Packaging ${{ matrix.unityVersion }} Test Results + artifactsPath: package-sdk-${{ matrix.unityVersion }}-artifacts + projectPath: unity-sdk-packager + unityVersion: ${{ matrix.unityVersion }} + githubToken: ${{ SECRETS.GITHUB_TOKEN }} + - name: Expose packaged SDK as artifact + uses: actions/upload-artifact@v3 + with: + name: LootLockerSDK-${{ matrix.unityVersion }}.zip + path: unity-sdk-packager/LootLockerSDK*.unitypackage \ No newline at end of file diff --git a/.github/workflows/selfhosted-poc.yml b/.github/workflows/selfhosted-poc.yml new file mode 100644 index 00000000..66e89fd2 --- /dev/null +++ b/.github/workflows/selfhosted-poc.yml @@ -0,0 +1,35 @@ +name: Selfhosted Runner Proof of Concept +run-name: selfhosted-poc +on: + workflow_dispatch: {} + +jobs: + ping-stage-test: + name: Ping stage backend + runs-on: [k8s] + container: + image: ubuntu:22.04 + steps: + - name: Setup git + run: | + apt update + apt-get install -y git + git config --global --add safe.directory /__w/unity-sdk/unity-sdk + + - name: Setup curl + run: | + apt update + apt-get install -y curl + + - name: Checkout this repository + uses: actions/checkout@v3 + + - name: Cat package.json + run: cat package.json + + - name: Check branch + run: git branch + + - name: Ping stage + run: | + curl -X POST "${{ SECRETS.LL_STAGE_URL }}/game/v2/session/guest" -H "Content-Type: application/json" -d "{\"game_key\": \"dev_dc52acb52a8b49be81761e709f1df9fd\", \"game_version\": \"0.10.0.0\", \"player_identifier\": \"k8s-runner-guest\"}" diff --git a/Runtime/Game/Resources/LootLockerConfig.cs b/Runtime/Game/Resources/LootLockerConfig.cs index 4a3b684e..28b4a91b 100644 --- a/Runtime/Game/Resources/LootLockerConfig.cs +++ b/Runtime/Game/Resources/LootLockerConfig.cs @@ -23,6 +23,7 @@ public static LootLockerConfig Get() if (settingsInstance != null) { settingsInstance.ConstructUrls(); + settingsInstance?.CheckForSettingOverrides(); return settingsInstance; } @@ -60,9 +61,37 @@ public static LootLockerConfig Get() } #endif settingsInstance?.ConstructUrls(); + settingsInstance?.CheckForSettingOverrides(); return settingsInstance; } + private void CheckForSettingOverrides() + { +#if LOOTLOCKER_COMMANDLINE_SETTINGS + string[] args = System.Environment.GetCommandLineArgs(); + string _apiKey = null; + string _domainKey = null; + for (int i = 0; i < args.Length; i++) + { + if (args[i] == "-apikey") + { + _apiKey = args[i + 1]; + } + else if (args[i] == "-domainkey") + { + _domainKey = args[i + 1]; + } + } + + if (string.IsNullOrEmpty(_apiKey) || string.IsNullOrEmpty(_domainKey)) + { + return; + } + apiKey = _apiKey; + domainKey = _domainKey; +#endif + } + #if UNITY_EDITOR [InitializeOnLoadMethod] static void CreateConfigFile()