From 9308a040c93eb99b230a1be45174cdc58ce667f9 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Tue, 12 Sep 2023 02:12:29 +0200 Subject: [PATCH] test --- .github/actions/create-dev-env/action.yml | 15 ++++++++- .../workflows/docker-build-test-upload.yml | 4 ++- aarch64-runner/README.md | 31 +++++++++++++++++++ aarch64-runner/setup.sh | 5 +-- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/.github/actions/create-dev-env/action.yml b/.github/actions/create-dev-env/action.yml index 169d8bcb..07ed5c23 100644 --- a/.github/actions/create-dev-env/action.yml +++ b/.github/actions/create-dev-env/action.yml @@ -15,13 +15,26 @@ runs: # See: https://github.com/actions/setup-python/issues/108 # python3 is manually preinstalled in the arm64 VM self-hosted runner - name: Set Up Python 🐍 + if: ${{ inputs.architecture == 'amd64' }} uses: actions/setup-python@v4 with: python-version: 3.x - if: ${{ inputs.architecture == 'amd64' }} + + - name: System set for macOS runner + if: ${{ inputs.architecture == 'arm64' }} + run: | + export GITHUB_RUNNER_USER=$(whoami) + echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/${GITHUB_RUNNER_USER}/.zprofile + echo 'export PATH="/opt/homebrew/opt/python/libexec/bin:$PATH"' >> /Users/${GITHUB_RUNNER_USER}/.zprofile + echo 'export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"' >> /Users/${GITHUB_RUNNER_USER}/.zprofile + shell: bash - name: Install Dev Dependencies 📦 run: | + echo $(whoami) + echo $(which python) + echo $(python --version) + echo $PATH pip install --upgrade pip pip install --upgrade -r requirements-dev.txt shell: bash diff --git a/.github/workflows/docker-build-test-upload.yml b/.github/workflows/docker-build-test-upload.yml index ae718f6b..15ed6d04 100644 --- a/.github/workflows/docker-build-test-upload.yml +++ b/.github/workflows/docker-build-test-upload.yml @@ -56,7 +56,9 @@ jobs: shell: bash - name: Save image as a tar for later use 💾 - run: docker save ${{ env.OWNER }}/${{ inputs.image }} -o /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar + run: | + mkdir -p /tmp/aiidalab/ + docker save ${{ env.OWNER }}/${{ inputs.image }} -o /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar shell: bash - name: Upload image as artifact 💾 diff --git a/aarch64-runner/README.md b/aarch64-runner/README.md index 9c43ea33..24098994 100644 --- a/aarch64-runner/README.md +++ b/aarch64-runner/README.md @@ -34,6 +34,37 @@ Configure your runner: This will create the plist file for the runner service, it is not able to run it with the non-gui user. As shown in the [issue](https://github.com/actions/runner/issues/1056#issuecomment-1237426462), real services start on boot, not on login so on macOS this means the service needs to be a `LaunchDaemon` and not a `LaunchAgent`. + In case the python path is not correct, change the `runsvc.sh` file to the correct path. + Since we use `colima` as the container runtime, the docker sock is located at `unix://$HOME/.colima/default/docker.sock`. + Change the `runsvc.sh` file to: + + ```bash + #!/bin/bash + + # convert SIGTERM signal to SIGINT + # for more info on how to propagate SIGTERM to a child process see: http://veithen.github.io/2014/11/16/sigterm-propagation.html + trap 'kill -INT $PID' TERM INT + + if [ -f ".path" ]; then + # configure + export PATH=`cat .path` + eval "$(/opt/homebrew/bin/brew shellenv)" + export PATH="/opt/homebrew/opt/python/libexec/bin:$PATH" + export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock + echo ".path=${PATH}" + fi + + nodever=${GITHUB_ACTIONS_RUNNER_FORCED_NODE_VERSION:-node16} + + # insert anything to setup env when running as a service + # run the host process which keep the listener alive + ./externals/$nodever/bin/node ./bin/RunnerService.js & + PID=$! + wait $PID + trap - TERM INT + wait $PID + ``` + ```bash sudo mv /Users/runner-user/Library/LaunchAgents/actions.runner.*.plist /Library/LaunchDaemons/ sudo chown root:wheel /Library/LaunchDaemons/actions.runner.*.plist diff --git a/aarch64-runner/setup.sh b/aarch64-runner/setup.sh index 4b528d60..e7e8fc65 100755 --- a/aarch64-runner/setup.sh +++ b/aarch64-runner/setup.sh @@ -60,11 +60,12 @@ sudo -i -u ${GITHUB_RUNNER_USER} bash << EOF curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh echo "Setting up python3" brew install python -# For Apple Silicon machines, the path are slightly different. +# For Apple Silicon machines, the path are slightly different. # After running brew install python, must ensure your ~/.zprofile uses the correct Homebrew paths: echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/${GITHUB_RUNNER_USER}/.zprofile echo 'export PATH="/opt/homebrew/opt/python/libexec/bin:$PATH"' >> /Users/${GITHUB_RUNNER_USER}/.zprofile -echo "Setting up docker" +echo 'export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"' >> /Users/${GITHUB_RUNNER_USER}/.zprofile +echo "Setting up docker " brew install docker brew install colima EOF