|
| 1 | +name: Test remote run features |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ "main", "dev" ] |
| 6 | + paths: |
| 7 | + - '.github/workflows/test-remote-run.yml' |
| 8 | + - 'automation/script/remote_run.py' |
| 9 | + - 'script/remote-run-commands/**' |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + test_remote_run: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set up Python |
| 22 | + uses: actions/setup-python@v3 |
| 23 | + with: |
| 24 | + python-version: "3.12" |
| 25 | + |
| 26 | + - name: Install mlcflow and pull repo |
| 27 | + env: |
| 28 | + REPO: ${{ github.event.pull_request.head.repo.html_url }} |
| 29 | + BRANCH: ${{ github.event.pull_request.head.ref }} |
| 30 | + run: | |
| 31 | + pip install mlcflow |
| 32 | + mlc pull repo "$REPO" --branch="$BRANCH" |
| 33 | +
|
| 34 | + - name: Set up SSH to localhost |
| 35 | + run: | |
| 36 | + ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" |
| 37 | + cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys |
| 38 | + chmod 600 ~/.ssh/authorized_keys |
| 39 | + ssh-keyscan -H localhost >> ~/.ssh/known_hosts |
| 40 | + # Verify SSH to localhost works |
| 41 | + ssh -o BatchMode=yes localhost "echo SSH_OK" |
| 42 | +
|
| 43 | + - name: Test remote pre_run_cmds and post_run_cmds |
| 44 | + run: | |
| 45 | + mlcr remote,run,cmds,ssh \ |
| 46 | + --host=localhost \ |
| 47 | + --ssh_key_file=~/.ssh/id_ed25519 \ |
| 48 | + --run_cmds,="echo MAIN_CMD_RAN" \ |
| 49 | + --pre_run_cmds,="echo PRE_RUN_EXECUTED > /tmp/pre_run_test.txt" \ |
| 50 | + --post_run_cmds,="echo POST_RUN_EXECUTED > /tmp/post_run_test.txt" |
| 51 | +
|
| 52 | + # Verify pre_run_cmds executed |
| 53 | + test -f /tmp/pre_run_test.txt |
| 54 | + grep -q "PRE_RUN_EXECUTED" /tmp/pre_run_test.txt |
| 55 | + echo "pre_run_cmds: PASSED" |
| 56 | +
|
| 57 | + # Verify post_run_cmds executed |
| 58 | + test -f /tmp/post_run_test.txt |
| 59 | + grep -q "POST_RUN_EXECUTED" /tmp/post_run_test.txt |
| 60 | + echo "post_run_cmds: PASSED" |
| 61 | +
|
| 62 | + - name: Test remote_pre_run_cmds via remote_run |
| 63 | + run: | |
| 64 | + mlcr detect,os \ |
| 65 | + --remote_host=localhost \ |
| 66 | + --remote_ssh_key_file=~/.ssh/id_ed25519 \ |
| 67 | + --remote_pre_run_cmds,="echo REMOTE_PRE_RAN > /tmp/remote_pre_test.txt" \ |
| 68 | + --remote_post_run_cmds,="echo REMOTE_POST_RAN > /tmp/remote_post_test.txt" |
| 69 | +
|
| 70 | + test -f /tmp/remote_pre_test.txt |
| 71 | + grep -q "REMOTE_PRE_RAN" /tmp/remote_pre_test.txt |
| 72 | + echo "remote_pre_run_cmds via remote_run: PASSED" |
| 73 | +
|
| 74 | + test -f /tmp/remote_post_test.txt |
| 75 | + grep -q "REMOTE_POST_RAN" /tmp/remote_post_test.txt |
| 76 | + echo "remote_post_run_cmds via remote_run: PASSED" |
| 77 | +
|
| 78 | + - name: Test remote_copy_mlc_repos with custom MLC_REPOS path |
| 79 | + run: | |
| 80 | + # Use a random-ish path for MLC_REPOS on the "remote" |
| 81 | + export CUSTOM_REPOS_PATH="/tmp/custom-mlc-repos-$(date +%s)" |
| 82 | + mkdir -p "$CUSTOM_REPOS_PATH" |
| 83 | +
|
| 84 | + # Create a dummy repo to copy |
| 85 | + mkdir -p ~/MLC/repos/test-dummy-repo |
| 86 | + echo "DUMMY_CONTENT" > ~/MLC/repos/test-dummy-repo/marker.txt |
| 87 | +
|
| 88 | + mlcr detect,os \ |
| 89 | + --remote_host=localhost \ |
| 90 | + --remote_ssh_key_file=~/.ssh/id_ed25519 \ |
| 91 | + --remote_copy_mlc_repos,=test-dummy-repo |
| 92 | +
|
| 93 | + # Verify the repo was copied to MLC/repos (default rsync target) |
| 94 | + test -f ~/MLC/repos/test-dummy-repo/marker.txt |
| 95 | + echo "remote_copy_mlc_repos: PASSED" |
0 commit comments