Repository navigation
fix(runner): clean claude runner checkouts after every session #485
Workflow file for this run
This file contains hidden or 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 | |
| # Creates real workspaces on staging-coder.ddev.com, verifies they start | |
| # correctly, then deletes them. Runs on the self-hosted sysbox runner so | |
| # the Coder provisioner can reach the local Docker/Sysbox environment. | |
| # | |
| # One-time runner setup on staging-coder.ddev.com: | |
| # # Create a dedicated low-privilege user for the runner (do not run as root or admin) | |
| # sudo apt-get install -y unzip # required by actions/checkout and other actions | |
| # sudo useradd -m -s /bin/bash github-runner | |
| # | |
| # # Register N runner instances (one per parallel matrix job — currently 2 templates). | |
| # # TODO: Revisit runner count if more templates or matrix cells are added. | |
| # # Each instance needs its own directory, a unique --name, and its own service. | |
| # # Get a fresh registration token for each from: | |
| # # https://github.com/ddev/coder-ddev/settings/actions/runners/new?arch=x64&os=linux | |
| # # https://docs.github.com/en/actions/how-tos/manage-runners/self-hosted-runners/add-runners | |
| # for N in 1 2 3; do | |
| # sudo -u github-runner mkdir -p /home/github-runner/actions-runner-${N} | |
| # cd /home/github-runner/actions-runner-${N} | |
| # # copy runner binaries here (download once, copy to each dir) or re-download | |
| # sudo -u github-runner ./config.sh \ | |
| # --url https://github.com/ddev/coder-ddev \ | |
| # --token <token> \ | |
| # --name staging-coder-${N} \ | |
| # --labels sysbox | |
| # sudo ./svc.sh install github-runner # creates actions.runner.*.service | |
| # sudo ./svc.sh start | |
| # done | |
| # | |
| # # To remove/re-register one instance: get removal token from GitHub Settings → Actions → Runners → Remove | |
| # cd /home/github-runner/actions-runner-${N} | |
| # sudo ./svc.sh stop && sudo ./svc.sh uninstall | |
| # sudo -u github-runner ./config.sh remove --token <removal-token> | |
| # | |
| # Requires: | |
| # Repository variable: TEST_CODER_URL - https://staging-coder.ddev.com | |
| # Repository secret: OP_SERVICE_ACCOUNT_TOKEN - 1Password service account with read access | |
| # 1Password item: op://test-secrets/TEST_CODER_SESSION_TOKEN/credential | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| on: | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - 'drupal-core/**' | |
| - 'drupal-contrib/**' | |
| pull_request: | |
| paths-ignore: | |
| - 'drupal-core/**' | |
| - 'drupal-contrib/**' | |
| schedule: | |
| - cron: '0 3 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| debug_enabled: | |
| description: Enable remote debugging session | |
| type: boolean | |
| required: false | |
| default: false | |
| # Ref-scoped so a new commit on the same PR (or the same push-to-main queue) | |
| # cancels its own stale run, but never touches another PR's or main's run. | |
| # | |
| # Serialization against other workflows/refs that provision real workspaces on | |
| # the shared staging-coder.ddev.com box is NOT done via a shared job-level | |
| # `concurrency:` group -- a single PR push fires several box-provisioning jobs | |
| # across this file, drupal-integration-test.yml, and | |
| # drupal-contrib-integration-test.yml at nearly the same instant, and GitHub's | |
| # concurrency groups only keep one job running plus one pending; every other | |
| # simultaneous contender gets silently CANCELLED, not queued. Instead, each | |
| # box-touching job below runs scripts/ci-acquire-staging-lock.sh right before | |
| # creating its workspace, which claims one of a fixed number of lock-slot | |
| # workspaces (an atomic Coder-side compare-and-swap on workspace name) and | |
| # waits its turn if all slots are held -- see that script's header comment | |
| # for detail. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| integration-test: | |
| name: Integration test (${{ matrix.template }}) | |
| # Disabled: self-hosted sysbox runner; use integration-test-gh instead. | |
| # To re-enable: restore `if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.repository_owner }}` | |
| if: false | |
| runs-on: [self-hosted, sysbox] | |
| # Long enough to cover queued time behind other box-provisioning jobs | |
| # (see scripts/ci-acquire-staging-lock.sh) plus this job's own runtime. | |
| timeout-minutes: 75 | |
| strategy: | |
| matrix: | |
| include: | |
| - template: freeform | |
| ws_name: ff | |
| extra_vars: "" | |
| extra_params: "" | |
| app_slug: "" | |
| fail-fast: false | |
| defaults: | |
| run: | |
| shell: bash -euo pipefail {0} | |
| env: | |
| CI_TAG: ${{ github.run_number }}-${{ github.run_attempt }} | |
| WORKSPACE_NAME: ci-${{ matrix.ws_name }}-${{ github.run_number }}-${{ github.run_attempt }} | |
| CI: "true" | |
| DDEV_NONINTERACTIVE: "true" | |
| NO_COLOR: "1" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Load 1Password secrets | |
| uses: 1password/load-secrets-action@v4 | |
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.repository_owner }} | |
| with: | |
| export-env: true | |
| env: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
| TEST_CODER_SESSION_TOKEN: "op://test-secrets/TEST_CODER_SESSION_TOKEN/credential" | |
| - name: Login to Coder | |
| if: ${{ env.TEST_CODER_SESSION_TOKEN != '' }} | |
| run: coder login --token "${{ env.TEST_CODER_SESSION_TOKEN }}" "${{ vars.TEST_CODER_URL }}" | |
| - name: Setup upterm session | |
| uses: owenthereal/action-upterm@v1 | |
| with: | |
| limit-access-to-actor: true | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
| - name: Push template (inactive) | |
| run: | | |
| coder templates push ${{ matrix.template }} \ | |
| --directory ${{ matrix.template }} \ | |
| --activate=false \ | |
| --name ci-${{ env.CI_TAG }} \ | |
| --yes \ | |
| --variable image_version="$(cat VERSION)" \ | |
| --variable workspace_image_registry=index.docker.io/ddev/coder-ddev \ | |
| ${{ matrix.extra_vars }} | |
| - name: Create workspace | |
| if: ${{ matrix.template != 'freeform' }} | |
| run: | | |
| coder create ${{ env.WORKSPACE_NAME }} \ | |
| --template ${{ matrix.template }} \ | |
| --template-version ci-${{ env.CI_TAG }} \ | |
| --parameter "vscode_extensions=[]" \ | |
| ${{ matrix.extra_params }} \ | |
| --use-parameter-defaults \ | |
| --yes | |
| - name: Create freeform workspace (with project names) | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| cat > /tmp/freeform-params-${{ env.CI_TAG }}.yaml << EOF | |
| project_names: "ci-site1-${{ env.CI_TAG }},ci-site2-${{ env.CI_TAG }}" | |
| vscode_extensions: "[]" | |
| EOF | |
| coder create ${{ env.WORKSPACE_NAME }} \ | |
| --template ${{ matrix.template }} \ | |
| --template-version ci-${{ env.CI_TAG }} \ | |
| --rich-parameter-file /tmp/freeform-params-${{ env.CI_TAG }}.yaml \ | |
| --use-parameter-defaults \ | |
| --yes | |
| - name: Show provisioner errors if workspace creation failed | |
| if: failure() | |
| run: ./scripts/ci-show-provisioner-errors.sh "ci-${{ env.CI_TAG }}" "${{ env.WORKSPACE_NAME }}" | |
| - name: Verify workspace — agent connected | |
| run: coder ssh ${{ env.WORKSPACE_NAME }} --wait=yes -- echo "Agent connected" | |
| - name: Verify workspace — Docker daemon running | |
| run: coder ssh ${{ env.WORKSPACE_NAME }} -- docker ps | |
| - name: Verify workspace — DDEV installed | |
| run: coder ssh ${{ env.WORKSPACE_NAME }} -- ddev --version | |
| - name: Record expected host directory | |
| run: | | |
| OWNER=$(coder whoami --output json | jq -r 'if type == "array" then .[0].username else .username end') | |
| echo "OWNER=$OWNER" >> "$GITHUB_ENV" | |
| echo "HOST_DIR=/coder-workspaces/${OWNER}-${{ env.WORKSPACE_NAME }}" >> "$GITHUB_ENV" | |
| - name: Verify workspace — DDEV can start a project | |
| if: ${{ matrix.app_slug != '' }} | |
| run: | | |
| # Write start script to runner-local file so we avoid the coder ssh heredoc+PTY hang | |
| cat > /tmp/ci-ddev-start-${{ env.CI_TAG }}.sh << 'EOF' | |
| set -euo pipefail | |
| TESTDIR=/tmp/ci-ddev-${{ env.CI_TAG }} | |
| echo "--- Creating test project in $TESTDIR ---" | |
| mkdir -p "$TESTDIR/web" && cd "$TESTDIR" | |
| ddev config --project-type=php --docroot=web | |
| echo "--- Starting DDEV project ---" | |
| ddev start -y | |
| echo "--- DDEV started ---" | |
| EOF | |
| scp \ | |
| -o StrictHostKeyChecking=no \ | |
| -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| /tmp/ci-ddev-start-${{ env.CI_TAG }}.sh \ | |
| coder@workspace:/tmp/ci-ddev-start-${{ env.CI_TAG }}.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env CI=${{ env.CI }} DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} NO_COLOR=${{ env.NO_COLOR }} \ | |
| bash /tmp/ci-ddev-start-${{ env.CI_TAG }}.sh < /dev/null | |
| - name: Verify workspace — DDEV web externally accessible | |
| if: ${{ matrix.app_slug != '' }} | |
| run: | | |
| CODER_DOMAIN="${{ vars.TEST_CODER_URL }}" | |
| CODER_DOMAIN="${CODER_DOMAIN#https://}" | |
| SITE_URL="https://${{ matrix.app_slug }}--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}" | |
| echo "Checking $SITE_URL" | |
| STATUS=$(curl -s --max-time 30 -o /dev/null -w "%{http_code}" "$SITE_URL") | |
| echo "HTTP status: $STATUS" | |
| [[ "$STATUS" =~ ^[2-4] ]] || { echo "ERROR: unexpected HTTP status $STATUS" >&2; exit 1; } | |
| - name: Cleanup DDEV test project | |
| if: ${{ matrix.app_slug != '' }} | |
| run: | | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- ddev delete ci-ddev-${{ env.CI_TAG }} --omit-snapshot -y < /dev/null || true | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- rm -rf /tmp/ci-ddev-${{ env.CI_TAG }} < /dev/null || true | |
| - name: Inject current-branch DDEV scripts into freeform workspace | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- mkdir -p /home/coder/.ddev/commands/host < /dev/null | |
| for script in coder-routes coder-setup launch; do | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| "image/scripts/.ddev/commands/host/${script}" \ | |
| "coder@workspace:/home/coder/.ddev/commands/host/${script}" | |
| done | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- chmod +x /home/coder/.ddev/commands/host/coder-routes /home/coder/.ddev/commands/host/coder-setup /home/coder/.ddev/commands/host/launch < /dev/null | |
| - name: Start two PHP projects — freeform routing test | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| freeform/scripts/test-freeform-start.sh \ | |
| coder@workspace:/tmp/test-freeform-start.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env CI=${{ env.CI }} DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} NO_COLOR=${{ env.NO_COLOR }} \ | |
| bash /tmp/test-freeform-start.sh "${{ env.CI_TAG }}" < /dev/null | |
| - name: Verify freeform — ddev launch and describe per-project URLs | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| CODER_DOMAIN="${{ vars.TEST_CODER_URL }}" | |
| CODER_DOMAIN="${CODER_DOMAIN#https://}" | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| freeform/scripts/test-freeform-verify.sh \ | |
| coder@workspace:/tmp/test-freeform-verify.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} NO_COLOR=${{ env.NO_COLOR }} \ | |
| bash /tmp/test-freeform-verify.sh \ | |
| "${{ env.CI_TAG }}" "${{ env.WORKSPACE_NAME }}" "${OWNER}" "${CODER_DOMAIN}" \ | |
| < /dev/null | |
| - name: Cleanup freeform PHP projects | |
| if: ${{ always() && matrix.template == 'freeform' }} | |
| run: | | |
| coder show "${{ env.WORKSPACE_NAME }}" > /dev/null 2>&1 || { | |
| echo "Workspace ${{ env.WORKSPACE_NAME }} not found — skipping DDEV cleanup" | |
| exit 0 | |
| } | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| freeform/scripts/test-freeform-cleanup.sh \ | |
| coder@workspace:/tmp/test-freeform-cleanup.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} \ | |
| bash /tmp/test-freeform-cleanup.sh "${{ env.CI_TAG }}" < /dev/null | |
| - name: Delete workspace | |
| if: always() | |
| run: coder delete ${{ env.WORKSPACE_NAME }} --yes || true | |
| - name: Verify host directory removed | |
| if: always() | |
| run: | | |
| if [[ -z "${HOST_DIR:-}" ]]; then | |
| echo "HOST_DIR not set — workspace may not have been created, skipping" | |
| exit 0 | |
| fi | |
| if [[ -d "$HOST_DIR" ]]; then | |
| echo "ERROR: Host directory was not removed by destroy provisioner: $HOST_DIR" >&2 | |
| ls -la "$HOST_DIR" >&2 || true | |
| exit 1 | |
| fi | |
| echo "OK: host directory removed: $HOST_DIR" | |
| - name: Archive CI template version | |
| if: always() | |
| run: coder templates versions archive ${{ matrix.template }} ci-${{ env.CI_TAG }} --yes || true | |
| integration-test-gh: | |
| name: Integration test GH (${{ matrix.template }}) | |
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.repository_owner }} | |
| runs-on: ubuntu-latest | |
| # Long enough to cover queued time behind other box-provisioning jobs | |
| # (see scripts/ci-acquire-staging-lock.sh) plus this job's own runtime. | |
| timeout-minutes: 75 | |
| strategy: | |
| matrix: | |
| include: | |
| - template: freeform | |
| ws_name: ff | |
| extra_vars: "" | |
| extra_params: "" | |
| app_slug: "" | |
| fail-fast: false | |
| defaults: | |
| run: | |
| shell: bash -euo pipefail {0} | |
| env: | |
| CI_TAG: ${{ github.run_number }}-${{ github.run_attempt }} | |
| WORKSPACE_NAME: gh-${{ matrix.ws_name }}-${{ github.event.pull_request.number && format('pr{0}', github.event.pull_request.number) || github.ref_name == 'main' && 'main' || format('x{0}', github.run_number) }}-${{ github.run_number }}-${{ github.run_attempt }} | |
| CI: "true" | |
| DDEV_NONINTERACTIVE: "true" | |
| NO_COLOR: "1" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Load 1Password secrets | |
| uses: 1password/load-secrets-action@v4 | |
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.repository_owner }} | |
| with: | |
| export-env: true | |
| env: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
| TEST_CODER_SESSION_TOKEN: "op://test-secrets/TEST_CODER_SESSION_TOKEN/credential" | |
| - uses: coder/setup-action@v1 | |
| with: | |
| access_url: ${{ vars.TEST_CODER_URL }} | |
| coder_session_token: ${{ env.TEST_CODER_SESSION_TOKEN }} | |
| - name: Setup upterm session | |
| uses: owenthereal/action-upterm@v1 | |
| with: | |
| limit-access-to-actor: true | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
| - name: Push template (inactive) | |
| run: | | |
| coder templates push ${{ matrix.template }} \ | |
| --directory ${{ matrix.template }} \ | |
| --activate=false \ | |
| --name ci-gh-${{ env.CI_TAG }} \ | |
| --yes \ | |
| --variable image_version="$(cat VERSION)" \ | |
| --variable workspace_image_registry=index.docker.io/ddev/coder-ddev \ | |
| ${{ matrix.extra_vars }} | |
| - name: Reap predecessor workspaces (cancelled prior runs of this cell) | |
| run: ./scripts/ci-reap-family.sh "${WORKSPACE_NAME%-*-*}-" "$WORKSPACE_NAME" | |
| - name: Acquire staging box lock | |
| run: ./scripts/ci-acquire-staging-lock.sh | |
| env: | |
| CI_LOCK_SLOTS: ${{ vars.CI_LOCK_SLOTS }} | |
| - name: Create workspace | |
| if: ${{ matrix.template != 'freeform' }} | |
| run: | | |
| coder create ${{ env.WORKSPACE_NAME }} \ | |
| --template ${{ matrix.template }} \ | |
| --template-version ci-gh-${{ env.CI_TAG }} \ | |
| --parameter "vscode_extensions=[]" \ | |
| ${{ matrix.extra_params }} \ | |
| --use-parameter-defaults \ | |
| --yes | |
| - name: Create freeform workspace (with project names) | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| cat > /tmp/freeform-params-gh-${{ env.CI_TAG }}.yaml << EOF | |
| project_names: "ci-site1-${{ env.CI_TAG }},ci-site2-${{ env.CI_TAG }}" | |
| vscode_extensions: "[]" | |
| EOF | |
| coder create ${{ env.WORKSPACE_NAME }} \ | |
| --template ${{ matrix.template }} \ | |
| --template-version ci-gh-${{ env.CI_TAG }} \ | |
| --rich-parameter-file /tmp/freeform-params-gh-${{ env.CI_TAG }}.yaml \ | |
| --use-parameter-defaults \ | |
| --yes | |
| - name: Show provisioner errors if workspace creation failed | |
| if: failure() | |
| run: ./scripts/ci-show-provisioner-errors.sh "ci-gh-${{ env.CI_TAG }}" "${{ env.WORKSPACE_NAME }}" | |
| - name: Verify workspace — agent connected | |
| run: coder ssh ${{ env.WORKSPACE_NAME }} --wait=yes -- echo "Agent connected" | |
| - name: Verify workspace — Docker daemon running | |
| run: coder ssh ${{ env.WORKSPACE_NAME }} -- docker ps | |
| - name: Verify workspace — DDEV installed | |
| run: coder ssh ${{ env.WORKSPACE_NAME }} -- ddev --version | |
| - name: Record owner | |
| run: | | |
| OWNER=$(coder whoami --output json | jq -r 'if type == "array" then .[0].username else .username end') | |
| echo "OWNER=$OWNER" >> "$GITHUB_ENV" | |
| - name: Verify workspace — DDEV can start a project | |
| if: ${{ matrix.app_slug != '' }} | |
| run: | | |
| cat > /tmp/ci-ddev-start-gh-${{ env.CI_TAG }}.sh << 'EOF' | |
| set -euo pipefail | |
| TESTDIR=/tmp/ci-ddev-gh-${{ env.CI_TAG }} | |
| mkdir -p "$TESTDIR/web" && cd "$TESTDIR" | |
| ddev config --project-type=php --docroot=web | |
| ddev start -y | |
| EOF | |
| scp \ | |
| -o StrictHostKeyChecking=no \ | |
| -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| /tmp/ci-ddev-start-gh-${{ env.CI_TAG }}.sh \ | |
| coder@workspace:/tmp/ci-ddev-start-gh-${{ env.CI_TAG }}.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env CI=${{ env.CI }} DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} NO_COLOR=${{ env.NO_COLOR }} \ | |
| bash /tmp/ci-ddev-start-gh-${{ env.CI_TAG }}.sh < /dev/null | |
| - name: Verify workspace — DDEV web externally accessible | |
| if: ${{ matrix.app_slug != '' }} | |
| run: | | |
| CODER_DOMAIN="${{ vars.TEST_CODER_URL }}" | |
| CODER_DOMAIN="${CODER_DOMAIN#https://}" | |
| SITE_URL="https://${{ matrix.app_slug }}--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}" | |
| echo "Checking $SITE_URL" | |
| STATUS=$(curl -s --max-time 30 -o /dev/null -w "%{http_code}" "$SITE_URL") | |
| echo "HTTP status: $STATUS" | |
| [[ "$STATUS" =~ ^[2-4] ]] || { echo "ERROR: unexpected HTTP status $STATUS" >&2; exit 1; } | |
| - name: Cleanup DDEV test project | |
| if: ${{ matrix.app_slug != '' }} | |
| run: | | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- ddev delete ci-ddev-gh-${{ env.CI_TAG }} --omit-snapshot -y < /dev/null || true | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- rm -rf /tmp/ci-ddev-gh-${{ env.CI_TAG }} < /dev/null || true | |
| - name: Inject current-branch DDEV scripts into freeform workspace | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- mkdir -p /home/coder/.ddev/commands/host < /dev/null | |
| for script in coder-routes coder-setup launch; do | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| "image/scripts/.ddev/commands/host/${script}" \ | |
| "coder@workspace:/home/coder/.ddev/commands/host/${script}" | |
| done | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- chmod +x /home/coder/.ddev/commands/host/coder-routes /home/coder/.ddev/commands/host/coder-setup /home/coder/.ddev/commands/host/launch < /dev/null | |
| - name: Start two PHP projects — freeform routing test | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| freeform/scripts/test-freeform-start.sh \ | |
| coder@workspace:/tmp/test-freeform-start.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env CI=${{ env.CI }} DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} NO_COLOR=${{ env.NO_COLOR }} \ | |
| bash /tmp/test-freeform-start.sh "${{ env.CI_TAG }}" < /dev/null | |
| - name: Verify freeform — ddev launch and describe per-project URLs | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| CODER_DOMAIN="${{ vars.TEST_CODER_URL }}" | |
| CODER_DOMAIN="${CODER_DOMAIN#https://}" | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| freeform/scripts/test-freeform-verify.sh \ | |
| coder@workspace:/tmp/test-freeform-verify.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} NO_COLOR=${{ env.NO_COLOR }} \ | |
| bash /tmp/test-freeform-verify.sh \ | |
| "${{ env.CI_TAG }}" "${{ env.WORKSPACE_NAME }}" "${OWNER}" "${CODER_DOMAIN}" \ | |
| < /dev/null | |
| - name: Verify freeform sharing — private by default | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| CODER_DOMAIN="${{ vars.TEST_CODER_URL }}" | |
| CODER_DOMAIN="${CODER_DOMAIN#https://}" | |
| SITE_URL="https://ci-site1-${{ env.CI_TAG }}--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}" | |
| FINAL_URL=$(curl -sL --max-time 30 -o /dev/null -w "%{url_effective}" "$SITE_URL") | |
| echo "Anonymous request final URL: $FINAL_URL" | |
| if [[ "$FINAL_URL" != *"/login"* ]]; then | |
| echo "ERROR: anonymous request was not redirected to Coder login — share_projects=false is not private" >&2 | |
| exit 1 | |
| fi | |
| echo "OK: anonymous request redirected to Coder login (freeform sites are private by default)" | |
| - name: Install test ~/.coder-startup.sh user hook (freeform) | |
| if: ${{ matrix.template == 'freeform' }} | |
| # Checked after the restart below: the hook must run on workspace start | |
| # without blocking it. | |
| run: | | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| freeform/scripts/test-freeform-startup-hook.sh \ | |
| coder@workspace:/home/coder/test-freeform-startup-hook.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| bash /home/coder/test-freeform-startup-hook.sh install < /dev/null | |
| - name: Enable public sharing and rebuild (freeform) | |
| if: ${{ matrix.template == 'freeform' }} | |
| # `coder update`/`coder restart` alone silently ignore --parameter | |
| # unless the workspace is otherwise outdated. --always-prompt forces | |
| # every rich parameter to be re-resolved (never pulled from the | |
| # existing build), so every value from the original `coder create` | |
| # (project_names, vscode_extensions) must be repeated here. Uses | |
| # --rich-parameter-file, not inline --parameter, because project_names | |
| # is a comma-separated value and coder's --parameter flag itself | |
| # splits on commas (same reason the original "Create freeform | |
| # workspace" step above uses a file instead of --parameter). | |
| run: | | |
| cat > /tmp/freeform-share-gh-${{ env.CI_TAG }}.yaml << EOF | |
| project_names: "ci-site1-${{ env.CI_TAG }},ci-site2-${{ env.CI_TAG }}" | |
| vscode_extensions: "[]" | |
| share_projects: "true" | |
| EOF | |
| coder restart ${{ env.WORKSPACE_NAME }} --always-prompt --use-parameter-defaults \ | |
| --rich-parameter-file /tmp/freeform-share-gh-${{ env.CI_TAG }}.yaml \ | |
| --yes | |
| - name: Verify workspace — agent reconnected after restart | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: coder ssh ${{ env.WORKSPACE_NAME }} --wait=yes -- echo "Agent reconnected" | |
| - name: Verify ~/.coder-startup.sh user hook ran on restart (freeform) | |
| if: ${{ matrix.template == 'freeform' }} | |
| # The script was copied to /home/coder (persistent) before the restart. | |
| run: | | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| bash /home/coder/test-freeform-startup-hook.sh verify < /dev/null | |
| - name: Recreate freeform test projects after rebuild | |
| if: ${{ matrix.template == 'freeform' }} | |
| # test-freeform-start.sh puts projects under /tmp, which is wiped | |
| # when the container is recreated by the restart above — the DDEV | |
| # projects (and ddev-router) must be brought up again from scratch. | |
| run: | | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| freeform/scripts/test-freeform-start.sh \ | |
| coder@workspace:/tmp/test-freeform-start.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env CI=${{ env.CI }} DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} NO_COLOR=${{ env.NO_COLOR }} \ | |
| bash /tmp/test-freeform-start.sh "${{ env.CI_TAG }}" < /dev/null | |
| - name: Verify freeform sharing — public when share_projects=true | |
| if: ${{ matrix.template == 'freeform' }} | |
| run: | | |
| CODER_DOMAIN="${{ vars.TEST_CODER_URL }}" | |
| CODER_DOMAIN="${CODER_DOMAIN#https://}" | |
| SITE_URL="https://ci-site1-${{ env.CI_TAG }}--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}" | |
| FINAL_URL=$(curl -sL --max-time 30 --retry 3 --retry-delay 5 -o /dev/null -w "%{url_effective}" "$SITE_URL") | |
| echo "Anonymous request final URL: $FINAL_URL" | |
| if [[ "$FINAL_URL" == *"/login"* ]]; then | |
| echo "ERROR: anonymous request was redirected to Coder login — share_projects=true did not make the site public" >&2 | |
| exit 1 | |
| fi | |
| echo "OK: anonymous request was not redirected to Coder login (share_projects=true works)" | |
| - name: Cleanup freeform PHP projects | |
| if: ${{ always() && matrix.template == 'freeform' }} | |
| run: | | |
| coder show "${{ env.WORKSPACE_NAME }}" > /dev/null 2>&1 || { | |
| echo "Workspace ${{ env.WORKSPACE_NAME }} not found — skipping DDEV cleanup" | |
| exit 0 | |
| } | |
| scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
| -o ProxyCommand="coder ssh --stdio ${{ env.WORKSPACE_NAME }}" \ | |
| freeform/scripts/test-freeform-cleanup.sh \ | |
| coder@workspace:/tmp/test-freeform-cleanup.sh | |
| coder ssh ${{ env.WORKSPACE_NAME }} -- \ | |
| env DDEV_NONINTERACTIVE=${{ env.DDEV_NONINTERACTIVE }} \ | |
| bash /tmp/test-freeform-cleanup.sh "${{ env.CI_TAG }}" < /dev/null | |
| - name: Delete workspace | |
| if: always() | |
| run: coder delete ${{ env.WORKSPACE_NAME }} --yes || true | |
| - name: Release staging box lock | |
| if: always() | |
| run: ./scripts/ci-release-staging-lock.sh | |
| - name: Archive CI template version | |
| if: always() | |
| run: coder templates versions archive ${{ matrix.template }} ci-gh-${{ env.CI_TAG }} --yes || true |