unity-test-runner
unity-test-runner copied to clipboard
What's the "correct way" to provide the test runner with some secrets/credentials?
Context:
-
I am trying to give the unity test runner some secrets. Namely, a username and (plaintext)password
-
The reason is so that my test can authenticate to the live game server in my test, using these credentials.
-
I am using environment variables to store the secrets. It works on a local Ubuntu PC. The test is successful.
On Ubuntu, i can simply
export USERNAME_SECONDLIFE="thevalue"
inside the bash.rc file. And the unity editor will be able to read the env values usingEnvironment.GetEnvironmentVariable( "USERNAME_SECONDLIFE" )
Issue:
However, the unity test runner cannot find such environment variables (Environment.GetEnvironmentVariable() returns null string
).
I have added them into my env @ the test-runner job section:
// https://github.com/alexiscatnip/RaindropViewer/blob/2d895a25fb84e93047f80131a99a2949389ba198/.github/workflows/main.yml
# Test
- name: Run tests
uses: game-ci/unity-test-runner@v2
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
> USERNAME_SECONDLIFE: ${{ secrets.USERNAME_SECONDLIFE }}
> PASSWORD_SECONDLIFE: ${{ secrets.PASSWORD_SECONDLIFE }}
> GRIDFRIENDLYNAME_SECONDLIFE: ${{ secrets.GRIDFRIENDLYNAME_SECONDLIFE }}
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
unityVersion: ${{ matrix.unityVersion }}
Looking at
https://github.com/game-ci/unity-test-runner/blob/3d5d2f58348b293ae1fe6b7cca24deccaf505b2f/src/model/docker.ts
,
I think I can modify the command line string, by adding in my env variables (hard-code...).
But that might be thinking too much inside the box?
By using the shell of the github runner VM, I am able to read the envs.
https://github.com/alexiscatnip/github_action_experiment/tree/main
My present suspicion is 'the envs of the github VM are not inherited by the docker container, and instead must be defined in the CLI arguments as a flag like --env MYENVVAR
"
You are correct in your observation that we're not passing non-specific env variables into the container.
You can use customParameters to pass any parameters into the image and read them from your code.
Here's an example of how to read the variables that you've passed from builder. Effectively the same can be done in your test setup.
Let me know if this sufficiently answers your question.
@webbertakken 👍 thanks so much! I am presently not familiar with building docker (only know how to docker run
).
I will investigate one of these days... For now I just quickly forked the repo and hard-coded my 3 values to pass in; something like -env MY_SECRET_FROM_GITHUB_SECRETS
. It more or less works... :'')