game-ci / docker

Series of CI-specialised docker images for Unity.
https://hub.docker.com/u/unityci
MIT License
392 stars 121 forks source link

docker: invalid reference format: repository name must be lowercase. #235

Closed artibex closed 6 months ago

artibex commented 6 months ago

Bug description I can't build or test using this docker container because of some kind of format issue?

building and testing fails due to the following error:

docker: invalid reference format: repository name must be lowercase. See 'docker run --help'. Error: The process '/usr/bin/docker' failed with exit code 125

How to reproduce

Use following github action:

      # Build
      - name: Build project
        uses: game-ci/unity-builder@v4
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          buildName: paradogx-win
          projectPath: unity
          targetPlatform: StandaloneWindows

Expected behavior Building and Testing

Additional details

Run game-ci/unity-test-runner@v4
/usr/bin/docker run --workdir /github/workspace --cidfile /home/runner/work/_temp/container___game-ci_unity-test-runner --rm --env UNITY_EMAIL=*** --env UNITY_PASSWORD=*** --env UNITY_SERIAL=*** --env UNITY_VERSION=[20](https://github.com/artibex/paradogx-private/actions/runs/7403600890/job/20143770675#step:7:21)[22](https://github.com/artibex/paradogx-private/actions/runs/7403600890/job/20143770675#step:7:23).3.15f1 --env PROJECT_PATH=unity --env COVERAGE_OPTIONS=generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;dontClear --env COVERAGE_RESULTS_PATH=CodeCoverage --env ARTIFACTS_PATH=artifacts --env PACKAGE_MODE=false --env RUN_AS_HOST_USER=false --env GITHUB_REF=refs/heads/development --env GITHUB_SHA=a44198843c482973aabc0d7d57a983de73e02881 --env GITHUB_REPOSITORY=artibex/paradogx-private --env GITHUB_ACTOR=artibex --env GITHUB_WORKFLOW=Unity Build --env GITHUB_EVENT_NAME=push --env GITHUB_ACTION=__game-ci_unity-test-runner --env GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json --env RUNNER_OS=Linux --env RUNNER_TOOL_CACHE=/opt/hostedtoolcache --env RUNNER_TEMP=/home/runner/work/_temp --env RUNNER_WORKSPACE=/home/runner/work/paradogx-private              --env GIT_CONFIG_EXTENSIONS             --env TEST_PLATFORMS=playmode;editmode;COMBINE_RESULTS             --env GITHUB_WORKSPACE=/github/workspace                          --volume /home/runner/work/_temp/_github_home:/root:z             --volume /home/runner/work/_temp/_github_workflow:/github/workflow:z             --volume /home/runner/work/paradogx-private/paradogx-private:/github/workspace:z             --volume /home/runner/work/_actions/game-ci/unity-test-runner/v4/dist/test-standalone-scripts:/UnityStandaloneScripts:z             --volume /home/runner/work/_actions/game-ci/unity-test-runner/v4/dist/platforms/ubuntu:/steps:z             --volume /home/runner/work/_actions/game-ci/unity-test-runner/v4/dist/unity-config:/usr/share/unity3d/config/:z             --volume /home/runner/work/_actions/game-ci/unity-test-runner/v4/dist/BlankProject:/BlankProject:z             --cpus=2             --memory=6575m                                                                 --env USE_EXIT_CODE=false             unityci/editor:ubuntu-2022.3.15f1-linux-il2cpp-3             /bin/bash -c /steps/entrypoint.sh
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.
Error: The process '/usr/bin/docker' failed with exit code 125

Complete main.yml:

name: Unity Build

on: [push, pull_request]

jobs:
  build:
    name: Build my project ✨
    runs-on: ubuntu-latest
    steps:
      # Checkout (without LFS)
      - name: Checkout repository
        uses: actions/checkout@v4

      # Git LFS
      - name: Create LFS file list
        run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id

      - name: Restore LFS cache
        uses: actions/cache@v3
        id: lfs-cache
        with:
          path: .git/lfs
          key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}

      - name: Git LFS Pull
        run: |
          git lfs pull
          git add .
          git reset --hard

      # Cache
      - uses: actions/cache@v3
        with:
          path: Library
          key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
          restore-keys: |
            Library-

      # Test
      - name: Run tests
        uses: game-ci/unity-test-runner@v4
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          projectPath: unity
          githubToken: ${{ secrets.GITHUB_TOKEN }}

      # Build
      - name: Build project
        uses: game-ci/unity-builder@v4
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          buildName: paradogx-win
          projectPath: unity
          targetPlatform: StandaloneWindows

      # Output
      - uses: actions/upload-artifact@v3
        with:
          name: Build
          path: build
GabLeRoux commented 6 months ago

I took a quick look at this based on shared information. It might be useful to see complete run log. The error message docker: invalid reference format: repository name must be lowercase indicates that there's an issue with the format of the Docker image name being used in the GitHub Actions workflow.

unityci/editor:ubuntu-2022.3.15f1-linux-il2cpp-3 from the Additional details section seems to be a valid docker image name and it is available on docker hub.

Now by looking at the actual output and formatting it properly, I think there's something wrong where the version is deteremined. I don't know what is causing this or if it's a bad copy paste manipulation somewhere, but here's the formatted command:

/usr/bin/docker run \
  --workdir /github/workspace \
  --cidfile /home/runner/work/_temp/container___game-ci_unity-test-runner \
  --rm \
  --env UNITY_EMAIL=*** \
  --env UNITY_PASSWORD=*** \
  --env UNITY_SERIAL=*** \
  --env UNITY_VERSION=[20](https://github.com/artibex/paradogx-private/actions/runs/7403600890/job/20143770675#step:7:21)[22](https://github.com/artibex/paradogx-private/actions/runs/7403600890/job/20143770675#step:7:23).3.15f1 \
  --env PROJECT_PATH=unity \
  --env COVERAGE_OPTIONS=generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;dontClear \
  --env COVERAGE_RESULTS_PATH=CodeCoverage \
  --env ARTIFACTS_PATH=artifacts \
  --env PACKAGE_MODE=false \
  --env RUN_AS_HOST_USER=false \
  --env GITHUB_REF=refs/heads/development \
  --env GITHUB_SHA=a44198843c482973aabc0d7d57a983de73e02881 \
  --env GITHUB_REPOSITORY=artibex/paradogx-private \
  --env GITHUB_ACTOR=artibex \
  --env GITHUB_WORKFLOW=Unity Build \
  --env GITHUB_EVENT_NAME=push \
  --env GITHUB_ACTION=__game-ci_unity-test-runner \
  --env GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json \
  --env RUNNER_OS=Linux \
  --env RUNNER_TOOL_CACHE=/opt/hostedtoolcache \
  --env RUNNER_TEMP=/home/runner/work/_temp \
  --env RUNNER_WORKSPACE=/home/runner/work/paradogx-private \
  --env GIT_CONFIG_EXTENSIONS \
  --env TEST_PLATFORMS=playmode;editmode;COMBINE_RESULTS \
  --env GITHUB_WORKSPACE=/github/workspace \
  --volume /home/runner/work/_temp/_github_home:/root:z \
  --volume /home/runner/work/_temp/_github_workflow:/github/workflow:z \
  --volume /home/runner/work/paradogx-private/paradogx-private:/github/workspace:z \
  --volume /home/runner/work/_actions/game-ci/unity-test-runner/v4/dist/test-standalone-scripts:/UnityStandaloneScripts:z \
  --volume /home/runner/work/_actions/game-ci/unity-test-runner/v4/dist/platforms/ubuntu:/steps:z \
  --volume /home/runner/work/_actions/game-ci/unity-test-runner/v4/dist/unity-config:/usr/share/unity3d/config/:z \
  --volume /home/runner/work/_actions/game-ci/unity-test-runner/v4/dist/BlankProject:/BlankProject:z \
  --cpus=2 \
  --memory=6575m \
  --env USE_EXIT_CODE=false \
  unityci/editor:ubuntu-2022.3.15f1-linux-il2cpp-3 \
  /bin/bash -c /steps/entrypoint.sh

The line here seems weird (but I might also be wrong):

  --env UNITY_VERSION=[20](https://github.com/artibex/paradogx-private/actions/runs/7403600890/job/20143770675#step:7:21)[22](https://github.com/artibex/paradogx-private/actions/runs/7403600890/job/20143770675#step:7:23).3.15f1 \

I find it weird that there are links to workflow jobs in the middle of the UNITY_VERSION in there. It could also be a problem with how the logs were copy pasted in above issue description.

The test runner (and the unity builder action) uses the file located in ./ProjectSettings/ProjectVersion.txt (or actually unity/ProjectSettings/ProjectVersion.txt, because you have projectPath: unity) to determine which Unity version to use. Then it builds the name of the image to use inside the action. In your case, 2022.3.15f1.

I'll create a blank project with that same version and try your workflow in a public project to see if this can be reproduced.

edit: tried it here: https://github.com/GabLeRoux/unity-game-ci-v4-test-activation/pull/1 and I got a different problem where the tests never ended. Not sure why. But I did not encounter the issue you shared.

artibex commented 6 months ago

First of all, thank you so much for your quick response!

I used the template from the getting started section from game.ci

I added my Unity licence, email and password as a secret and I adjusted the "projectPath", "buildName" and "targetPlattform"

Template:

name: Actions 😎

on: [push, pull_request]

jobs:
  build:
    name: Build my project ✨
    runs-on: ubuntu-latest
    steps:
      # Checkout (without LFS)
      - name: Checkout repository
        uses: actions/checkout@v4

      # Git LFS
      - name: Create LFS file list
        run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id

      - name: Restore LFS cache
        uses: actions/cache@v3
        id: lfs-cache
        with:
          path: .git/lfs
          key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}

      - name: Git LFS Pull
        run: |
          git lfs pull
          git add .
          git reset --hard

      # Cache
      - uses: actions/cache@v3
        with:
          path: Library
          key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
          restore-keys: |
            Library-

      # Test
      - name: Run tests
        uses: game-ci/unity-test-runner@v4
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}

      # Build
      - name: Build project
        uses: game-ci/unity-builder@v4
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          targetPlatform: WebGL

      # Output
      - uses: actions/upload-artifact@v3
        with:
          name: Build
          path: build

The env variable for the Unity Version of the docker run command is strange indeed, just to make sure I will upgrade my unity project on a second branch to 2023 and check if the issue changes.

EDIT: It does not change, seme error. Perhaps it has something to do with the folder structure? EDIT2: Hardcoding the unity version also leads to the same error

artibex commented 6 months ago

I FOUND THE ISSUE:

GabLeRoux commented 6 months ago

Interesting, didn't know this was still a problem. I remember having troubles a few years ago when I had special characters such as ! in my password which led to problems in shell scripts. It might be worth mentionning this in the docs near UNITY_PASSWORD.

I wonder if we could spot the places where password is used / passed to docker and figure out the best way to avoid troubles with special characters. 🤔

Anyway, thanks a lot for the feedback!