Skip to content

fix(runner): clean claude runner checkouts after every session #431

fix(runner): clean claude runner checkouts after every session

fix(runner): clean claude runner checkouts after every session #431

name: Drupal Contrib Integration Tests
# Creates drupal-contrib workspaces on staging-coder.ddev.com and verifies they
# reach a working state (DDEV running, Drupal installed, module enabled).
#
# Two jobs:
# contrib-plain — matrix of known modules on D11, runs on every
# push to main and nightly
# contrib-issue-fork — single workspace using a real drupal.org contrib issue
# fork, runs on every push to main, PRs, and nightly
#
# Repository variables (optional, set in GitHub → Settings → Variables):
# CONTRIB_TEST_PROJECT - Module machine name for issue fork test (default: token)
# CONTRIB_TEST_ISSUE_FORK - Issue number on drupal.org for that module (no default;
# skip issue-fork job if unset)
# CONTRIB_TEST_DRUPAL_VERSION - Drupal core version for the issue fork test (default: 11).
# NOTE: field_issue_version for contrib modules is the MODULE
# version, not the Drupal core version, so it cannot be used
# to infer the target Drupal version automatically.
#
# 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
# 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, integration-test.yml, and drupal-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 (including
# contrib-plain-gh and contrib-issue-fork-gh, which otherwise run in parallel
# within a single workflow run) calls 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
on:
schedule:
- cron: '0 5 * * *'
push:
branches: [main]
pull_request:
workflow_dispatch:
inputs:
debug_enabled:
description: Enable remote debugging session
type: boolean
required: false
default: false
jobs:
contrib-plain:
name: Contrib ${{ matrix.project }} D${{ matrix.drupal_version }} (plain)
# Disabled: self-hosted sysbox runner; use contrib-plain-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:
- project: token
drupal_version: "11"
- project: pathauto
drupal_version: "11"
- project: skipto
drupal_version: "12"
fail-fast: false
defaults:
run:
shell: bash -euo pipefail {0}
env:
WORKSPACE_NAME: cc-${{ matrix.project }}-d${{ matrix.drupal_version }}-${{ 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
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 drupal-contrib \
--directory drupal-contrib \
--activate=false \
--name ${{ env.WORKSPACE_NAME }} \
--yes \
--variable image_version="$(cat VERSION)" \
--variable workspace_image_registry=index.docker.io/ddev/coder-ddev
- name: Create workspace
run: |
coder create ${{ env.WORKSPACE_NAME }} \
--template drupal-contrib \
--template-version ${{ env.WORKSPACE_NAME }} \
--parameter "vscode_extensions=[]" \
--parameter project_name=${{ matrix.project }} \
--parameter project_type=module \
--parameter drupal_version=${{ matrix.drupal_version }} \
--parameter issue_fork= \
--parameter issue_branch= \
--parameter install_profile=minimal \
--parameter drupal_site_public=false \
--use-parameter-defaults \
--yes
- name: Show provisioner errors if workspace creation failed
if: failure()
run: ./scripts/ci-show-provisioner-errors.sh "${{ env.WORKSPACE_NAME }}" "${{ 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: Verify workspace — project repo cloned
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -d /home/coder/${{ matrix.project }}/.git
- name: Verify workspace — Drupal web root exists
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -f /home/coder/${{ matrix.project }}/web/index.php
- name: Verify workspace — Drush DB connected
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ matrix.project }} ddev drush status --fields=db-status \
| grep -i connected
- name: Dump setup status
if: always()
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- cat /home/coder/SETUP_STATUS.txt || true
echo "--- last 30 lines of setup log ---"
coder ssh ${{ env.WORKSPACE_NAME }} -- tail -30 /tmp/drupal-setup.log || true
- name: Verify workspace — module enabled
run: |
MODULES=$(coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ matrix.project }} ddev drush pm:list --status=enabled --format=list)
echo "--- enabled modules ---"
echo "$MODULES"
echo "--- end ---"
echo "$MODULES" | grep -iw "${{ matrix.project }}"
- name: Verify workspace — PHPUnit functional test runs
# Runs a core test (present in every project's web root) rather than
# a module-specific one, so this step doesn't need to vary per matrix
# entry. Same regression class as drupal-core issue #211: if this
# template ever stopped setting SIMPLETEST_BASE_URL to a value
# reachable from inside the web container, every functional test
# would fail with "You must provide a SIMPLETEST_BASE_URL
# environment variable".
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ matrix.project }} \
ddev phpunit --filter testTitle web/core/modules/system/tests/src/Functional/System/PageTitleTest.php
- 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 — Drupal site externally accessible
run: |
CODER_DOMAIN="${{ vars.TEST_CODER_URL }}"
CODER_DOMAIN="${CODER_DOMAIN#https://}"
SITE_URL="https://drupal-site--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}"
echo "Checking $SITE_URL"
HTTP_STATUS=$(curl -sL --max-time 30 --retry 3 --retry-delay 5 \
-H "Coder-Session-Token: ${TEST_CODER_SESSION_TOKEN}" \
-o /tmp/drupal-response.html \
-w "%{http_code}" \
"$SITE_URL")
echo "HTTP status: $HTTP_STATUS"
if [[ ! "$HTTP_STATUS" =~ ^[23] ]]; then
echo "ERROR: unexpected HTTP status $HTTP_STATUS" >&2
head -50 /tmp/drupal-response.html >&2 || true
exit 1
fi
if ! grep -qi "log in" /tmp/drupal-response.html; then
echo "ERROR: response does not contain 'log in' — Drupal may not have started" >&2
head -50 /tmp/drupal-response.html >&2
exit 1
fi
echo "OK: Drupal site is accessible and shows login page"
# drupal_site_public defaults to false: an anonymous request (no
# session token) must be bounced to Coder's own login, never reach
# Drupal. This is the private-by-default half of issue #204's fix.
ANON_FINAL_URL=$(curl -sL --max-time 30 -o /dev/null -w "%{url_effective}" "$SITE_URL")
echo "Anonymous request final URL: $ANON_FINAL_URL"
if [[ "$ANON_FINAL_URL" != *"/login"* ]]; then
echo "ERROR: anonymous request was not redirected to Coder login — drupal_site_public=false is not private" >&2
exit 1
fi
echo "OK: anonymous request redirected to Coder login (site is private by default)"
- 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 drupal-contrib ${{ env.WORKSPACE_NAME }} --yes || true
contrib-issue-fork:
name: Contrib ${{ vars.CONTRIB_TEST_PROJECT || 'token' }} issue fork
# Disabled: self-hosted sysbox runner; use contrib-issue-fork-gh instead.
# To re-enable: restore `if: ${{ vars.CONTRIB_TEST_ISSUE_FORK != '' && (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
defaults:
run:
shell: bash -euo pipefail {0}
env:
WORKSPACE_NAME: cc-fork-${{ github.run_number }}-${{ github.run_attempt }}
CI: "true"
DDEV_NONINTERACTIVE: "true"
NO_COLOR: "1"
CONTRIB_PROJECT: ${{ vars.CONTRIB_TEST_PROJECT || 'token' }}
ISSUE_FORK: ${{ vars.CONTRIB_TEST_ISSUE_FORK }}
CONTRIB_TEST_DRUPAL_VERSION: ${{ vars.CONTRIB_TEST_DRUPAL_VERSION || '11' }}
ISSUE_BRANCH: ""
ISSUE_NUMBER: ""
ISSUE_FORK_VERSION: ""
steps:
- uses: actions/checkout@v6
- name: Load 1Password secrets
uses: 1password/load-secrets-action@v4
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: Resolve issue branch and Drupal version from issue number
run: |
# Strip project prefix if the variable was set as e.g. "token-2648180" instead of "2648180"
ISSUE_NUMBER="${ISSUE_FORK#${CONTRIB_PROJECT}-}"
FORK_SLUG="${CONTRIB_PROJECT}-${ISSUE_NUMBER}"
# The fork project's own `default_branch` just reflects whatever HEAD
# pointed to when the fork was created (usually the same default
# branch as the parent project, e.g. "8.x-2.x") — it does NOT track
# the actual issue branch. Drupal.org's convention is to name that
# branch "<issue_number>-description", so look for one of those and
# pick the most recently committed match; fall back to the fork's
# default branch if none exists yet (e.g. no work pushed so far).
ISSUE_BRANCH=$(curl -sf \
"https://git.drupalcode.org/api/v4/projects/issue%2F${FORK_SLUG}/repository/branches?per_page=100" \
| jq -r --arg prefix "${ISSUE_NUMBER}-" \
'[.[] | select(.name | startswith($prefix))] | sort_by(.commit.committed_date) | last.name // empty')
if [[ -z "$ISSUE_BRANCH" ]]; then
echo "No '${ISSUE_NUMBER}-*' branch found on ${FORK_SLUG} — falling back to its default branch"
ISSUE_BRANCH=$(curl -sf \
"https://git.drupalcode.org/api/v4/projects/issue%2F${FORK_SLUG}" \
| jq -r '.default_branch')
fi
if [[ -z "$ISSUE_BRANCH" || "$ISSUE_BRANCH" == "null" ]]; then
echo "ERROR: Could not resolve a branch for issue fork ${FORK_SLUG}" >&2
exit 1
fi
# For contrib modules, field_issue_version is the MODULE version (e.g. "8.x-1.x"
# for token module 1.x), not the Drupal core version. We cannot reliably infer
# Drupal core version from it. Default to 11; override via CONTRIB_TEST_DRUPAL_VERSION.
DRUPAL_VERSION="${CONTRIB_TEST_DRUPAL_VERSION:-11}"
echo "Resolved: fork=${FORK_SLUG} branch=$ISSUE_BRANCH drupal_version=$DRUPAL_VERSION"
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> "$GITHUB_ENV"
echo "ISSUE_BRANCH=$ISSUE_BRANCH" >> "$GITHUB_ENV"
echo "ISSUE_FORK_VERSION=$DRUPAL_VERSION" >> "$GITHUB_ENV"
- name: Push template (inactive)
run: |
coder templates push drupal-contrib \
--directory drupal-contrib \
--activate=false \
--name cc-${{ github.run_number }}-${{ github.run_attempt }} \
--yes \
--variable image_version="$(cat VERSION)" \
--variable workspace_image_registry=index.docker.io/ddev/coder-ddev
- name: Create workspace
run: |
coder create ${{ env.WORKSPACE_NAME }} \
--template drupal-contrib \
--template-version cc-${{ github.run_number }}-${{ github.run_attempt }} \
--parameter "vscode_extensions=[]" \
--parameter project_name=${{ env.CONTRIB_PROJECT }} \
--parameter project_type=module \
--parameter drupal_version=${{ env.ISSUE_FORK_VERSION }} \
--parameter issue_fork=${{ env.ISSUE_NUMBER }} \
--parameter issue_branch=${{ env.ISSUE_BRANCH }} \
--parameter install_profile=minimal \
--parameter drupal_site_public=false \
--use-parameter-defaults \
--yes
- name: Show provisioner errors if workspace creation failed
if: failure()
run: ./scripts/ci-show-provisioner-errors.sh "cc-${{ github.run_number }}-${{ github.run_attempt }}" "${{ 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: Verify workspace — project repo cloned
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -d /home/coder/${{ env.CONTRIB_PROJECT }}/.git
- name: Verify workspace — Drupal web root exists
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -f /home/coder/${{ env.CONTRIB_PROJECT }}/web/index.php
- name: Verify workspace — Drush DB connected
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ env.CONTRIB_PROJECT }} ddev drush status --fields=db-status \
| grep -i connected
- name: Dump setup status
if: always()
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- cat /home/coder/SETUP_STATUS.txt || true
echo "--- last 30 lines of setup log ---"
coder ssh ${{ env.WORKSPACE_NAME }} -- tail -30 /tmp/drupal-setup.log || true
- name: Verify workspace — issue branch checked out
run: |
CURRENT=$(coder ssh ${{ env.WORKSPACE_NAME }} -- git -C /home/coder/${{ env.CONTRIB_PROJECT }} branch --show-current | tr -d '\r\n')
echo "Current branch: $CURRENT Expected: ${{ env.ISSUE_BRANCH }}"
[[ "$CURRENT" == "${{ env.ISSUE_BRANCH }}" ]] || { echo "ERROR: wrong branch" >&2; exit 1; }
- 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 — Drupal site externally accessible
run: |
CODER_DOMAIN="${{ vars.TEST_CODER_URL }}"
CODER_DOMAIN="${CODER_DOMAIN#https://}"
SITE_URL="https://drupal-site--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}"
echo "Checking $SITE_URL"
HTTP_STATUS=$(curl -sL --max-time 30 --retry 3 --retry-delay 5 \
-H "Coder-Session-Token: ${TEST_CODER_SESSION_TOKEN}" \
-o /tmp/drupal-response.html \
-w "%{http_code}" \
"$SITE_URL")
echo "HTTP status: $HTTP_STATUS"
if [[ ! "$HTTP_STATUS" =~ ^[23] ]]; then
echo "ERROR: unexpected HTTP status $HTTP_STATUS" >&2
head -50 /tmp/drupal-response.html >&2 || true
exit 1
fi
if ! grep -qi "log in" /tmp/drupal-response.html; then
echo "ERROR: response does not contain 'log in' — Drupal may not have started" >&2
head -50 /tmp/drupal-response.html >&2
exit 1
fi
echo "OK: Drupal site is accessible and shows login page"
# drupal_site_public defaults to false: an anonymous request (no
# session token) must be bounced to Coder's own login, never reach
# Drupal. This is the private-by-default half of issue #204's fix.
ANON_FINAL_URL=$(curl -sL --max-time 30 -o /dev/null -w "%{url_effective}" "$SITE_URL")
echo "Anonymous request final URL: $ANON_FINAL_URL"
if [[ "$ANON_FINAL_URL" != *"/login"* ]]; then
echo "ERROR: anonymous request was not redirected to Coder login — drupal_site_public=false is not private" >&2
exit 1
fi
echo "OK: anonymous request redirected to Coder login (site is private by default)"
- 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 drupal-contrib cc-${{ github.run_number }}-${{ github.run_attempt }} --yes || true
contrib-plain-gh:
name: Contrib ${{ matrix.project }} D${{ matrix.drupal_version }} (plain, GH)
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:
# PRs run a single module (smoke); push-to-main and nightly run the full
# set. Cuts per-PR workspace load on staging. See ci-reap.yml.
# The smoke cell is the D12 one on purpose: it tracks Drupal core HEAD, so
# it is where dependency churn (e.g. core's Guzzle 8 bump) breaks first.
# The D11 cells are stable and covered on push-to-main and nightly.
matrix:
include: ${{ github.event_name == 'pull_request' && fromJSON('[{"project":"skipto","drupal_version":"12"}]') || fromJSON('[{"project":"token","drupal_version":"11"},{"project":"pathauto","drupal_version":"11"},{"project":"skipto","drupal_version":"12"}]') }}
fail-fast: false
defaults:
run:
shell: bash -euo pipefail {0}
env:
WORKSPACE_NAME: gc-${{ matrix.project }}-d${{ matrix.drupal_version }}-${{ 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
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: Push template (inactive)
run: |
coder templates push drupal-contrib \
--directory drupal-contrib \
--activate=false \
--name ${{ env.WORKSPACE_NAME }} \
--yes \
--variable image_version="$(cat VERSION)" \
--variable workspace_image_registry=index.docker.io/ddev/coder-ddev \
--variable github_token=${{ secrets.GITHUB_TOKEN }}
- 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
run: |
coder create ${{ env.WORKSPACE_NAME }} \
--template drupal-contrib \
--template-version ${{ env.WORKSPACE_NAME }} \
--parameter "vscode_extensions=[]" \
--parameter project_name=${{ matrix.project }} \
--parameter project_type=module \
--parameter drupal_version=${{ matrix.drupal_version }} \
--parameter issue_fork= \
--parameter issue_branch= \
--parameter install_profile=minimal \
--parameter drupal_site_public=false \
--use-parameter-defaults \
--yes
- name: Show provisioner errors if workspace creation failed
if: failure()
run: ./scripts/ci-show-provisioner-errors.sh "${{ env.WORKSPACE_NAME }}" "${{ 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: Verify workspace — project repo cloned
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -d /home/coder/${{ matrix.project }}/.git
- name: Verify workspace — Drupal web root exists
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -f /home/coder/${{ matrix.project }}/web/index.php
- name: Verify workspace — Drush DB connected
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ matrix.project }} ddev drush status --fields=db-status \
| grep -i connected
- name: Dump setup status
if: always()
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- cat /home/coder/SETUP_STATUS.txt || true
echo "--- last 30 lines of setup log ---"
coder ssh ${{ env.WORKSPACE_NAME }} -- tail -30 /tmp/drupal-setup.log || true
- name: Verify workspace — module enabled
run: |
MODULES=$(coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ matrix.project }} ddev drush pm:list --status=enabled --format=list)
echo "--- enabled modules ---"
echo "$MODULES"
echo "--- end ---"
echo "$MODULES" | grep -iw "${{ matrix.project }}"
- name: Verify workspace — PHPUnit functional test runs
# Runs a core test (present in every project's web root) rather than
# a module-specific one, so this step doesn't need to vary per matrix
# entry. Same regression class as drupal-core issue #211: if this
# template ever stopped setting SIMPLETEST_BASE_URL to a value
# reachable from inside the web container, every functional test
# would fail with "You must provide a SIMPLETEST_BASE_URL
# environment variable".
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ matrix.project }} \
ddev phpunit --filter testTitle web/core/modules/system/tests/src/Functional/System/PageTitleTest.php
- 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 — Drupal site externally accessible
run: |
CODER_DOMAIN="${{ vars.TEST_CODER_URL }}"
CODER_DOMAIN="${CODER_DOMAIN#https://}"
SITE_URL="https://drupal-site--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}"
echo "Checking $SITE_URL"
HTTP_STATUS=$(curl -sL --max-time 30 --retry 3 --retry-delay 5 \
-H "Coder-Session-Token: ${TEST_CODER_SESSION_TOKEN}" \
-o /tmp/drupal-response.html \
-w "%{http_code}" \
"$SITE_URL")
echo "HTTP status: $HTTP_STATUS"
if [[ ! "$HTTP_STATUS" =~ ^[23] ]]; then
echo "ERROR: unexpected HTTP status $HTTP_STATUS" >&2
head -50 /tmp/drupal-response.html >&2 || true
exit 1
fi
if ! grep -qi "log in" /tmp/drupal-response.html; then
echo "ERROR: response does not contain 'log in' — Drupal may not have started" >&2
head -50 /tmp/drupal-response.html >&2
exit 1
fi
echo "OK: Drupal site is accessible and shows login page"
# drupal_site_public defaults to false: an anonymous request (no
# session token) must be bounced to Coder's own login, never reach
# Drupal. This is the private-by-default half of issue #204's fix.
ANON_FINAL_URL=$(curl -sL --max-time 30 -o /dev/null -w "%{url_effective}" "$SITE_URL")
echo "Anonymous request final URL: $ANON_FINAL_URL"
if [[ "$ANON_FINAL_URL" != *"/login"* ]]; then
echo "ERROR: anonymous request was not redirected to Coder login — drupal_site_public=false is not private" >&2
exit 1
fi
echo "OK: anonymous request redirected to Coder login (site is private by default)"
- name: Enable public sharing and rebuild
# `coder update`/`coder restart` alone silently ignore --parameter
# unless the workspace is otherwise outdated. --always-prompt forces
# every MUTABLE rich parameter to be re-resolved (never pulled from
# the existing build), so every mutable value from the original
# `coder create` must be repeated here — anything left out falls back
# to the template default via --use-parameter-defaults, not its prior
# value. project_name/project_type are immutable, so they must NOT be
# passed here at all — Coder rejects --always-prompt attempting to
# "change" an immutable parameter even to its current value, but
# silently keeps the existing value when it's simply omitted.
run: |
coder restart ${{ env.WORKSPACE_NAME }} --always-prompt --use-parameter-defaults \
--parameter "vscode_extensions=[]" \
--parameter drupal_version=${{ matrix.drupal_version }} \
--parameter issue_fork= \
--parameter issue_branch= \
--parameter install_profile=minimal \
--parameter drupal_site_public=true \
--yes
- name: Verify workspace — agent reconnected after restart
run: coder ssh ${{ env.WORKSPACE_NAME }} --wait=yes -- echo "Agent reconnected"
- name: Verify workspace — Drupal site public when drupal_site_public=true
run: |
CODER_DOMAIN="${{ vars.TEST_CODER_URL }}"
CODER_DOMAIN="${CODER_DOMAIN#https://}"
SITE_URL="https://drupal-site--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}"
echo "Checking $SITE_URL anonymously"
HTTP_STATUS=$(curl -sL --max-time 30 --retry 3 --retry-delay 5 \
-o /tmp/drupal-public-response.html \
-w "%{http_code}" \
"$SITE_URL")
echo "HTTP status: $HTTP_STATUS"
if [[ ! "$HTTP_STATUS" =~ ^2 ]]; then
echo "ERROR: unexpected HTTP status $HTTP_STATUS for a public anonymous request" >&2
head -50 /tmp/drupal-public-response.html >&2 || true
exit 1
fi
if ! grep -qi "drupal" /tmp/drupal-public-response.html; then
echo "ERROR: anonymous response does not look like the Drupal site — drupal_site_public=true did not make it public" >&2
head -50 /tmp/drupal-public-response.html >&2
exit 1
fi
echo "OK: anonymous request reached the public Drupal site (drupal_site_public=true works)"
- 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 drupal-contrib ${{ env.WORKSPACE_NAME }} --yes || true
contrib-issue-fork-gh:
name: Contrib ${{ vars.CONTRIB_TEST_PROJECT || 'token' }} issue fork (GH)
if: ${{ vars.CONTRIB_TEST_ISSUE_FORK != '' && (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
defaults:
run:
shell: bash -euo pipefail {0}
env:
WORKSPACE_NAME: gc-fork-${{ 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"
CONTRIB_PROJECT: ${{ vars.CONTRIB_TEST_PROJECT || 'token' }}
ISSUE_FORK: ${{ vars.CONTRIB_TEST_ISSUE_FORK }}
CONTRIB_TEST_DRUPAL_VERSION: ${{ vars.CONTRIB_TEST_DRUPAL_VERSION || '11' }}
ISSUE_BRANCH: ""
ISSUE_NUMBER: ""
ISSUE_FORK_VERSION: ""
steps:
- uses: actions/checkout@v6
- name: Load 1Password secrets
uses: 1password/load-secrets-action@v4
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: Resolve issue branch from issue number
run: |
ISSUE_NUMBER="${ISSUE_FORK#${CONTRIB_PROJECT}-}"
FORK_SLUG="${CONTRIB_PROJECT}-${ISSUE_NUMBER}"
# See the comment in the sibling "contrib-issue-fork" job: the fork's
# own `default_branch` does not track the actual issue branch, so
# prefer a "<issue_number>-*" branch (Drupal.org's naming
# convention), falling back to the fork's default branch if none
# exists yet.
ISSUE_BRANCH=$(curl -sf \
"https://git.drupalcode.org/api/v4/projects/issue%2F${FORK_SLUG}/repository/branches?per_page=100" \
| jq -r --arg prefix "${ISSUE_NUMBER}-" \
'[.[] | select(.name | startswith($prefix))] | sort_by(.commit.committed_date) | last.name // empty')
if [[ -z "$ISSUE_BRANCH" ]]; then
echo "No '${ISSUE_NUMBER}-*' branch found on ${FORK_SLUG} — falling back to its default branch"
ISSUE_BRANCH=$(curl -sf \
"https://git.drupalcode.org/api/v4/projects/issue%2F${FORK_SLUG}" \
| jq -r '.default_branch')
fi
if [[ -z "$ISSUE_BRANCH" || "$ISSUE_BRANCH" == "null" ]]; then
echo "ERROR: Could not resolve a branch for issue fork ${FORK_SLUG}" >&2
exit 1
fi
DRUPAL_VERSION="${CONTRIB_TEST_DRUPAL_VERSION:-11}"
echo "Resolved: fork=${FORK_SLUG} branch=$ISSUE_BRANCH drupal_version=$DRUPAL_VERSION"
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> "$GITHUB_ENV"
echo "ISSUE_BRANCH=$ISSUE_BRANCH" >> "$GITHUB_ENV"
echo "ISSUE_FORK_VERSION=$DRUPAL_VERSION" >> "$GITHUB_ENV"
- name: Push template (inactive)
run: |
coder templates push drupal-contrib \
--directory drupal-contrib \
--activate=false \
--name gc-${{ github.run_number }}-${{ github.run_attempt }} \
--yes \
--variable image_version="$(cat VERSION)" \
--variable workspace_image_registry=index.docker.io/ddev/coder-ddev \
--variable github_token=${{ secrets.GITHUB_TOKEN }}
- 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
run: |
coder create ${{ env.WORKSPACE_NAME }} \
--template drupal-contrib \
--template-version gc-${{ github.run_number }}-${{ github.run_attempt }} \
--parameter "vscode_extensions=[]" \
--parameter project_name=${{ env.CONTRIB_PROJECT }} \
--parameter project_type=module \
--parameter drupal_version=${{ env.ISSUE_FORK_VERSION }} \
--parameter issue_fork=${{ env.ISSUE_NUMBER }} \
--parameter issue_branch=${{ env.ISSUE_BRANCH }} \
--parameter install_profile=minimal \
--parameter drupal_site_public=false \
--use-parameter-defaults \
--yes
- name: Show provisioner errors if workspace creation failed
if: failure()
run: ./scripts/ci-show-provisioner-errors.sh "gc-${{ github.run_number }}-${{ github.run_attempt }}" "${{ 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: Verify workspace — project repo cloned
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -d /home/coder/${{ env.CONTRIB_PROJECT }}/.git
- name: Verify workspace — Drupal web root exists
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -f /home/coder/${{ env.CONTRIB_PROJECT }}/web/index.php
- name: Verify workspace — Drush DB connected
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ env.CONTRIB_PROJECT }} ddev drush status --fields=db-status \
| grep -i connected
- name: Dump setup status
if: always()
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- cat /home/coder/SETUP_STATUS.txt || true
echo "--- last 30 lines of setup log ---"
coder ssh ${{ env.WORKSPACE_NAME }} -- tail -30 /tmp/drupal-setup.log || true
- name: Verify workspace — issue branch checked out
run: |
CURRENT=$(coder ssh ${{ env.WORKSPACE_NAME }} -- git -C /home/coder/${{ env.CONTRIB_PROJECT }} branch --show-current | tr -d '\r\n')
echo "Current branch: $CURRENT Expected: ${{ env.ISSUE_BRANCH }}"
[[ "$CURRENT" == "${{ env.ISSUE_BRANCH }}" ]] || { echo "ERROR: wrong branch" >&2; exit 1; }
- name: Verify workspace — working tree is clean
run: |
# Catches scaffold-induced dirt (e.g. a stray .gitattributes rewriting
# a tracked file's line endings) that doesn't fail setup but can block
# a later branch checkout. composer.json is expected to carry the
# drush require-dev / allow-plugins edit, so it's excluded.
DIRTY=$(coder ssh ${{ env.WORKSPACE_NAME }} -- git -C /home/coder/${{ env.CONTRIB_PROJECT }} diff --name-only -- . ':!composer.json' | tr -d '\r')
echo "Modified tracked files (excluding composer.json): ${DIRTY:-<none>}"
[[ -z "$DIRTY" ]] || { echo "ERROR: working tree has unexpected modifications" >&2; exit 1; }
- 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 — Drupal site externally accessible
run: |
CODER_DOMAIN="${{ vars.TEST_CODER_URL }}"
CODER_DOMAIN="${CODER_DOMAIN#https://}"
SITE_URL="https://drupal-site--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}"
echo "Checking $SITE_URL"
HTTP_STATUS=$(curl -sL --max-time 30 --retry 3 --retry-delay 5 \
-H "Coder-Session-Token: ${TEST_CODER_SESSION_TOKEN}" \
-o /tmp/drupal-response.html \
-w "%{http_code}" \
"$SITE_URL")
echo "HTTP status: $HTTP_STATUS"
if [[ ! "$HTTP_STATUS" =~ ^[23] ]]; then
echo "ERROR: unexpected HTTP status $HTTP_STATUS" >&2
head -50 /tmp/drupal-response.html >&2 || true
exit 1
fi
if ! grep -qi "log in" /tmp/drupal-response.html; then
echo "ERROR: response does not contain 'log in' — Drupal may not have started" >&2
head -50 /tmp/drupal-response.html >&2
exit 1
fi
echo "OK: Drupal site is accessible and shows login page"
# drupal_site_public defaults to false: an anonymous request (no
# session token) must be bounced to Coder's own login, never reach
# Drupal. This is the private-by-default half of issue #204's fix.
ANON_FINAL_URL=$(curl -sL --max-time 30 -o /dev/null -w "%{url_effective}" "$SITE_URL")
echo "Anonymous request final URL: $ANON_FINAL_URL"
if [[ "$ANON_FINAL_URL" != *"/login"* ]]; then
echo "ERROR: anonymous request was not redirected to Coder login — drupal_site_public=false is not private" >&2
exit 1
fi
echo "OK: anonymous request redirected to Coder login (site is private by default)"
- 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 drupal-contrib gc-${{ github.run_number }}-${{ github.run_attempt }} --yes || true
# Companion to contrib-issue-fork-gh above, but for a project whose issue
# queue has migrated off drupal.org onto GitLab-native issues (see #163
# and #203). The fork/branch lookup works the same way either way (it's
# always GitLab, project-qualified), but the issue title/link lookup does
# not: a drupal.org node ID lookup for a migrated project's issue number
# can silently match an unrelated node (old node IDs get reused), so
# drupal-contrib/template.tf must fall back to GitLab's own issues API.
# This job is what actually exercises that fallback path.
contrib-issue-fork-gitlab-gh:
name: Contrib ${{ vars.CONTRIB_TEST_GITLAB_PROJECT || 'ui_icons' }} issue fork (GitLab-native, GH)
if: ${{ vars.CONTRIB_TEST_GITLAB_ISSUE_FORK != '' && (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
defaults:
run:
shell: bash -euo pipefail {0}
env:
WORKSPACE_NAME: gc-glfork-${{ 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"
CONTRIB_PROJECT: ${{ vars.CONTRIB_TEST_GITLAB_PROJECT || 'ui_icons' }}
ISSUE_FORK: ${{ vars.CONTRIB_TEST_GITLAB_ISSUE_FORK }}
CONTRIB_TEST_DRUPAL_VERSION: ${{ vars.CONTRIB_TEST_GITLAB_DRUPAL_VERSION || '11' }}
ISSUE_BRANCH: ""
ISSUE_NUMBER: ""
ISSUE_FORK_VERSION: ""
steps:
- uses: actions/checkout@v6
- name: Load 1Password secrets
uses: 1password/load-secrets-action@v4
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: Resolve issue branch from issue number
run: |
ISSUE_NUMBER="${ISSUE_FORK#${CONTRIB_PROJECT}-}"
FORK_SLUG="${CONTRIB_PROJECT}-${ISSUE_NUMBER}"
# See the comment in the "contrib-issue-fork" job: the fork's own
# `default_branch` does not track the actual issue branch, so
# prefer a "<issue_number>-*" branch (Drupal.org's naming
# convention), falling back to the fork's default branch if none
# exists yet.
ISSUE_BRANCH=$(curl -sf \
"https://git.drupalcode.org/api/v4/projects/issue%2F${FORK_SLUG}/repository/branches?per_page=100" \
| jq -r --arg prefix "${ISSUE_NUMBER}-" \
'[.[] | select(.name | startswith($prefix))] | sort_by(.commit.committed_date) | last.name // empty')
if [[ -z "$ISSUE_BRANCH" ]]; then
echo "No '${ISSUE_NUMBER}-*' branch found on ${FORK_SLUG} — falling back to its default branch"
ISSUE_BRANCH=$(curl -sf \
"https://git.drupalcode.org/api/v4/projects/issue%2F${FORK_SLUG}" \
| jq -r '.default_branch')
fi
if [[ -z "$ISSUE_BRANCH" || "$ISSUE_BRANCH" == "null" ]]; then
echo "ERROR: Could not resolve a branch for issue fork ${FORK_SLUG}" >&2
exit 1
fi
DRUPAL_VERSION="${CONTRIB_TEST_DRUPAL_VERSION:-11}"
echo "Resolved: fork=${FORK_SLUG} branch=$ISSUE_BRANCH drupal_version=$DRUPAL_VERSION"
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> "$GITHUB_ENV"
echo "ISSUE_BRANCH=$ISSUE_BRANCH" >> "$GITHUB_ENV"
echo "ISSUE_FORK_VERSION=$DRUPAL_VERSION" >> "$GITHUB_ENV"
- name: Push template (inactive)
run: |
coder templates push drupal-contrib \
--directory drupal-contrib \
--activate=false \
--name gc-gl-${{ github.run_number }}-${{ github.run_attempt }} \
--yes \
--variable image_version="$(cat VERSION)" \
--variable workspace_image_registry=index.docker.io/ddev/coder-ddev \
--variable github_token=${{ secrets.GITHUB_TOKEN }}
- 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
run: |
coder create ${{ env.WORKSPACE_NAME }} \
--template drupal-contrib \
--template-version gc-gl-${{ github.run_number }}-${{ github.run_attempt }} \
--parameter "vscode_extensions=[]" \
--parameter project_name=${{ env.CONTRIB_PROJECT }} \
--parameter project_type=module \
--parameter drupal_version=${{ env.ISSUE_FORK_VERSION }} \
--parameter issue_fork=${{ env.ISSUE_NUMBER }} \
--parameter issue_branch=${{ env.ISSUE_BRANCH }} \
--parameter install_profile=minimal \
--parameter drupal_site_public=false \
--use-parameter-defaults \
--yes
- name: Show provisioner errors if workspace creation failed
if: failure()
run: ./scripts/ci-show-provisioner-errors.sh "gc-gl-${{ github.run_number }}-${{ github.run_attempt }}" "${{ 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: Verify workspace — project repo cloned
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -d /home/coder/${{ env.CONTRIB_PROJECT }}/.git
- name: Verify workspace — Drupal web root exists
run: coder ssh ${{ env.WORKSPACE_NAME }} -- test -f /home/coder/${{ env.CONTRIB_PROJECT }}/web/index.php
- name: Verify workspace — Drush DB connected
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- env -C /home/coder/${{ env.CONTRIB_PROJECT }} ddev drush status --fields=db-status \
| grep -i connected
- name: Dump setup status
if: always()
run: |
coder ssh ${{ env.WORKSPACE_NAME }} -- cat /home/coder/SETUP_STATUS.txt || true
echo "--- last 30 lines of setup log ---"
coder ssh ${{ env.WORKSPACE_NAME }} -- tail -30 /tmp/drupal-setup.log || true
- name: Verify workspace — issue branch checked out
run: |
CURRENT=$(coder ssh ${{ env.WORKSPACE_NAME }} -- git -C /home/coder/${{ env.CONTRIB_PROJECT }} branch --show-current | tr -d '\r\n')
echo "Current branch: $CURRENT Expected: ${{ env.ISSUE_BRANCH }}"
[[ "$CURRENT" == "${{ env.ISSUE_BRANCH }}" ]] || { echo "ERROR: wrong branch" >&2; exit 1; }
- name: Verify workspace — working tree is clean
run: |
# Catches scaffold-induced dirt (e.g. a stray .gitattributes rewriting
# a tracked file's line endings) that doesn't fail setup but can block
# a later branch checkout. composer.json is expected to carry the
# drush require-dev / allow-plugins edit, so it's excluded.
DIRTY=$(coder ssh ${{ env.WORKSPACE_NAME }} -- git -C /home/coder/${{ env.CONTRIB_PROJECT }} diff --name-only -- . ':!composer.json' | tr -d '\r')
echo "Modified tracked files (excluding composer.json): ${DIRTY:-<none>}"
[[ -z "$DIRTY" ]] || { echo "ERROR: working tree has unexpected modifications" >&2; exit 1; }
- name: Verify workspace — issue link points at GitLab, not a stale drupal.org node
run: |
# This is the regression test for the fix in drupal-contrib/template.tf:
# a migrated project's old drupal.org node ID can coincidentally exist
# and belong to an unrelated project, so the workspace must not trust
# it blindly — it should fall back to GitLab's issues API instead.
WELCOME=$(coder ssh ${{ env.WORKSPACE_NAME }} -- cat /home/coder/WELCOME.txt)
echo "$WELCOME"
echo "$WELCOME" | grep -qF "git.drupalcode.org/project/${{ env.CONTRIB_PROJECT }}/-/issues/${{ env.ISSUE_NUMBER }}" \
|| { echo "ERROR: WELCOME.txt does not link to the GitLab issue" >&2; exit 1; }
echo "$WELCOME" | grep -qi "drupal.org/project" \
&& { echo "ERROR: WELCOME.txt still links to drupal.org for a GitLab-native issue" >&2; exit 1; }
echo "OK: issue link correctly points at GitLab"
- 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 — Drupal site externally accessible
run: |
CODER_DOMAIN="${{ vars.TEST_CODER_URL }}"
CODER_DOMAIN="${CODER_DOMAIN#https://}"
SITE_URL="https://drupal-site--${{ env.WORKSPACE_NAME }}--${OWNER}.${CODER_DOMAIN}"
echo "Checking $SITE_URL"
HTTP_STATUS=$(curl -sL --max-time 30 --retry 3 --retry-delay 5 \
-H "Coder-Session-Token: ${TEST_CODER_SESSION_TOKEN}" \
-o /tmp/drupal-response.html \
-w "%{http_code}" \
"$SITE_URL")
echo "HTTP status: $HTTP_STATUS"
if [[ ! "$HTTP_STATUS" =~ ^[23] ]]; then
echo "ERROR: unexpected HTTP status $HTTP_STATUS" >&2
head -50 /tmp/drupal-response.html >&2 || true
exit 1
fi
if ! grep -qi "log in" /tmp/drupal-response.html; then
echo "ERROR: response does not contain 'log in' — Drupal may not have started" >&2
head -50 /tmp/drupal-response.html >&2
exit 1
fi
echo "OK: Drupal site is accessible and shows login page"
# drupal_site_public defaults to false: an anonymous request (no
# session token) must be bounced to Coder's own login, never reach
# Drupal. This is the private-by-default half of issue #204's fix.
ANON_FINAL_URL=$(curl -sL --max-time 30 -o /dev/null -w "%{url_effective}" "$SITE_URL")
echo "Anonymous request final URL: $ANON_FINAL_URL"
if [[ "$ANON_FINAL_URL" != *"/login"* ]]; then
echo "ERROR: anonymous request was not redirected to Coder login — drupal_site_public=false is not private" >&2
exit 1
fi
echo "OK: anonymous request redirected to Coder login (site is private by default)"
- 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 drupal-contrib gc-gl-${{ github.run_number }}-${{ github.run_attempt }} --yes || true