Run Integration Test for commit 6ef4377b12994a12bc457269472f88b6929756f5 #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration Tests | |
run-name: Run Integration Test for commit ${{ github.sha }} | |
on: | |
push: | |
branches: | |
- ci/* | |
workflow_dispatch: | |
inputs: | |
LL_URL: | |
description: Use a custom url for tests | |
type: string | |
jobs: | |
ping-environment: | |
name: Ping the configured environment | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Checkout this repository | |
uses: actions/checkout@v4 | |
- name: Configure variables | |
run: | | |
if [ ${{ vars.LL_USE_STAGE }} == 'true' ]; then echo "LOOTLOCKER_URL=${{ SECRETS.LOOTLOCKER_API_STAGE_URL }}" >> $GITHUB_ENV; else echo "LOOTLOCKER_URL=${{ SECRETS.LOOTLOCKER_API_PRODUCTION_URL }}" >> $GITHUB_ENV; fi | |
if [ ${{ vars.LL_USE_STAGE }} == 'true' ]; then echo "LOOTLOCKER_API_KEY=${{ SECRETS.INTEGRATION_TESTS_STAGE_API_KEY }}" >> $GITHUB_ENV; else echo "LOOTLOCKER_API_KEY=${{ SECRETS.INTEGRATION_TESTS_PRODUCTION_API_KEY }}" >> $GITHUB_ENV; fi | |
if [ ${{ vars.LL_USE_STAGE }} == 'true' ]; then echo "LOOTLOCKER_DOMAIN_KEY=${{ SECRETS.INTEGRATION_TESTS_STAGE_DOMAIN_KEY }}" >> $GITHUB_ENV; else echo "LOOTLOCKER_DOMAIN_KEY=${{ SECRETS.INTEGRATION_TESTS_PRODUCTION_DOMAIN_KEY }}" >> $GITHUB_ENV; fi | |
if [ ${{ vars.LL_USE_STAGE }} == 'true' ]; then echo "TARGET_ENVIRONMENT=STAGE" >> $GITHUB_ENV; else echo "TARGET_ENVIRONMENT=PRODUCTION" >> $GITHUB_ENV; fi | |
git log -1 --pretty=format:"%s" | |
- name: Setup Tailscale | |
if: ${{ vars.LL_USE_STAGE == 'true' }} | |
uses: tailscale/github-action@v2 | |
with: | |
oauth-client-id: ${{ SECRETS.CI_TS_OAUTH_CLIENT_ID }} | |
oauth-secret: ${{ SECRETS.CI_TS_OAUTH_SECRET }} | |
tags: tag:ci | |
- name: Login as guest in ${{ ENV.TARGET_ENVIRONMENT }} environment | |
run: | | |
curl -X POST "${{ ENV.LOOTLOCKER_URL }}/game/v2/session/guest" -H "Content-Type: application/json" -d "{\"game_key\": \"${{ ENV.LOOTLOCKER_API_KEY }}\", \"game_version\": \"0.10.0.0\" }" | |
run-integration-tests: | |
name: Run the integration tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
testMode: | |
- playmode | |
unityVersion: | |
- 2019.4.40f1 | |
- 2020.3.48f1 | |
- 2021.3.39f1 | |
- 2022.3.34f1 | |
- 2023.2.20f1 | |
- 6000.0.7f1 | |
jsonLibrary: | |
- zerodep | |
- newtonsoft | |
steps: | |
- name: Configure variables | |
run: | | |
if [[ ${{ github.event_name == 'workflow_dispatch' }} == true ]]; then echo "LOOTLOCKER_URL=${{ INPUTS.LL_URL }}" >> $GITHUB_ENV; elif [ ${{ vars.LL_USE_STAGE }} == 'true' ]; then echo "LOOTLOCKER_URL=${{ SECRETS.LOOTLOCKER_API_STAGE_URL }}" >> $GITHUB_ENV; else echo "LOOTLOCKER_URL=${{ SECRETS.LOOTLOCKER_API_PRODUCTION_URL }}" >> $GITHUB_ENV; fi; fi | |
if [[ ${{ github.event_name == 'workflow_dispatch' }} == true ]]; then echo "TARGET_ENVIRONMENT=CUSTOM" >> $GITHUB_ENV; elif [ ${{ vars.LL_USE_STAGE }} == 'true' ]; then echo "TARGET_ENVIRONMENT=STAGE" >> $GITHUB_ENV; else echo "TARGET_ENVIRONMENT=PRODUCTION" >> $GITHUB_ENV; fi; fi | |
echo ${{ ENV.LOOTLOCKER_URL }} | |
- name: Checkout this repository | |
uses: actions/checkout@v4 | |
with: | |
path: ./sdk | |
- name: Make tests available in SDK repo | |
run: mv sdk/Tests~ sdk/Tests | |
- name: Create Test Project | |
run: | | |
mkdir TestProject | |
mkdir TestProject/Packages | |
echo $'{\n "dependencies": {\n "com.lootlocker.lootlockersdk": "file:../../sdk"\n },\n "testables": ["com.lootlocker.lootlockersdk"]\n}' >> TestProject/Packages/manifest.json | |
mkdir TestProject/Assets/ | |
cp -r sdk/Samples~/LootLockerExamples TestProject/Assets/ | |
- name: Set the project to use zerodep json | |
if: ${{ matrix.jsonLibrary == 'newtonsoft' }} | |
run: | | |
mkdir TestProject/ProjectSettings | |
echo $'%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!129 &1\nPlayerSettings:\n scriptingDefineSymbols:\n 1: LOOTLOCKER_COMMANDLINE_SETTINGS' >> TestProject/ProjectSettings/ProjectSettings.asset | |
- name: Set the project to use Newtonsoft json | |
if: ${{ matrix.jsonLibrary == 'newtonsoft' }} | |
run: | | |
mkdir TestProject/ProjectSettings | |
echo $'%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!129 &1\nPlayerSettings:\n scriptingDefineSymbols:\n 1: LOOTLOCKER_USE_NEWTONSOFTJSON;LOOTLOCKER_COMMANDLINE_SETTINGS' >> TestProject/ProjectSettings/ProjectSettings.asset | |
- name: Cache Libraries | |
if: ${{ matrix.jsonLibrary == 'nope' }} | |
uses: actions/cache@v4 | |
with: | |
path: tests~/Library | |
key: Library-${{ matrix.unityVersion }}-${{ matrix.testMode }}-${{ matrix.jsonLibrary }} | |
restore-keys: Library- | |
- name: Run tests in ${{ matrix.unityVersion }} ${{ matrix.testMode }} towards ${{ ENV.TARGET_ENVIRONMENT }} with json library ${{ matrix.jsonLibrary }} | |
if: ${{ matrix.jsonLibrary == 'nope' }} | |
uses: game-ci/unity-test-runner@v4 | |
id: tests | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
projectPath: TestProject/ | |
testMode: ${{ matrix.testMode }} | |
unityVersion: ${{ matrix.unityVersion }} | |
checkName: ${{ matrix.unityVersion }}-${{ matrix.testMode }}-${{ matrix.jsonLibrary }} Test Results | |
artifactsPath: ${{ matrix.unityVersion }}-${{ matrix.testMode }}-${{ matrix.jsonLibrary }}-artifacts | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
customParameters: -lootlockerurl ${{ ENV.LOOTLOCKER_URL }} | |
# scriptingDefineSymbols: | |
#1: NO_LOOTLOCKER_USE_NEWTONSOFTJSON;LOOTLOCKER_TARGET_STAGE_ENV |