ci: split release publishing from PR validation #516
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
| --- | |
| # yamllint disable rule:line-length | |
| name: test template | |
| on: | |
| pull_request: | |
| paths: | |
| - .github/compose/** | |
| - .github/workflows/test-template.yaml | |
| - templates/kubernetes/homelab-workspace/** | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| CODER_URL: http://localhost:7080 | |
| TEMPLATE_NAME: homelab-workspace-test | |
| WORKSPACE_NAME: template-test | |
| jobs: | |
| integration: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: Start local Coder | |
| env: | |
| COMPOSE_FILE: .github/compose/coder-template-test.yaml | |
| CODER_KUBECONFIG: ${{ runner.temp }}/kubeconfig | |
| KUBECONFIG_CONTENT: ${{ secrets.SANDBOX_TALOS_KUBECONFIG }} | |
| shell: bash | |
| run: | | |
| umask 077 | |
| printf '%s' "${KUBECONFIG_CONTENT}" > "${CODER_KUBECONFIG}" | |
| export CODER_KUBECONFIG | |
| docker compose -f "${COMPOSE_FILE}" up --detach database | |
| docker compose -f "${COMPOSE_FILE}" run --rm coder server create-admin-user \ | |
| --username ci --email ci@example.invalid --password ci-password | |
| docker compose -f "${COMPOSE_FILE}" up --detach coder | |
| - name: Wait for Coder and verify workspace routing | |
| shell: bash | |
| run: | | |
| # With no access URL, Coder creates its public development tunnel. The | |
| # test-cluster workspace reaches that URL while this runner keeps using localhost. | |
| timeout 5m bash -c "until curl --fail --silent --show-error \"${CODER_URL}/api/v2/buildinfo\" > /dev/null; do sleep 2; done" | |
| - name: Install and log in to Coder CLI | |
| shell: bash | |
| run: | | |
| source .github/compose/.env | |
| curl --fail --silent --show-error https://coder.com/install.sh | sh -s -- --method standalone --version "${CODER_VERSION}" | |
| export CODER_SESSION_TOKEN | |
| CODER_SESSION_TOKEN="$(curl --fail --silent --show-error -X POST "${CODER_URL}/api/v2/users/login" \ | |
| -H 'Content-Type: application/json' \ | |
| --data '{"email":"ci@example.invalid","password":"ci-password"}' | jq --raw-output .session_token)" | |
| test -n "${CODER_SESSION_TOKEN}" && test "${CODER_SESSION_TOKEN}" != null | |
| coder login --use-token-as-session "${CODER_URL}" | |
| - name: Publish template and start workspace | |
| shell: bash | |
| run: | | |
| RELEASE_TAG="$(gh release view --repo "${{ github.repository }}" --json tagName --jq .tagName)" | |
| WORKSPACE_IMAGE="ghcr.io/ppat/coder-workspace:${RELEASE_TAG}" | |
| coder template push --directory templates/kubernetes/homelab-workspace \ | |
| --var "workspace_image=${WORKSPACE_IMAGE}" --var test_mode=true \ | |
| --name "${{ github.sha }}" --yes "${TEMPLATE_NAME}" | |
| coder create "${WORKSPACE_NAME}" --template "${TEMPLATE_NAME}" --yes | |
| coder ping "${WORKSPACE_NAME}" | |
| coder ssh "${WORKSPACE_NAME}" -- env | |
| - name: Show Coder logs on failure | |
| if: failure() | |
| env: | |
| CODER_KUBECONFIG: ${{ runner.temp }}/kubeconfig | |
| run: docker compose -f .github/compose/coder-template-test.yaml logs | |
| - name: Stop local Coder | |
| if: always() | |
| env: | |
| CODER_KUBECONFIG: ${{ runner.temp }}/kubeconfig | |
| run: docker compose -f .github/compose/coder-template-test.yaml down --volumes |