chore: update ghcr.io/coder/coder (v2.12.2 -> v2.14.2) #160
This file contains 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" | |
# yamllint disable-line rule:truthy | |
on: | |
pull_request: | |
paths: | |
- 'docker-compose.yaml' | |
- 'templates/**' | |
- '.github/workflows/test-template.yaml' | |
workflow_dispatch: | |
inputs: | |
verbosity: | |
description: 'Log Verbosity' | |
required: true | |
default: "1" | |
type: choice | |
options: | |
- '0' | |
- '1' | |
- '2' | |
- '3' | |
- '4' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
default_verbosity: 0 | |
template_path: templates/docker/homelab-workspace | |
jobs: | |
test-template: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Install sysbox | |
run: | | |
# see: https://github.com/nestybox/sysbox/blob/master/docs/user-guide/install-package.md#installing-sysbox | |
wget --progress=dot:giga https://downloads.nestybox.com/sysbox/releases/v${SYSBOX_VERSION}/sysbox-ce_${SYSBOX_VERSION}-0.linux_amd64.deb -O /tmp/sysbox.deb | |
sudo apt-get install jq | |
sudo apt-get install /tmp/sysbox.deb | |
rm /tmp/sysbox.deb | |
sudo systemctl restart containerd | |
sudo systemctl restart docker | |
sudo systemctl restart sysbox | |
sudo systemctl restart containerd | |
sudo systemctl restart docker | |
sudo systemctl status sysbox | |
env: | |
# renovate: datasource=github-releases depName=nestybox/sysbox | |
SYSBOX_VERSION: "0.6.4" | |
- name: Start local coder instance | |
# yamllint disable-line rule:indentation | |
run: | | |
echo "Launching Coder..." | |
export AVAILABLE_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()') | |
export DOCKER_GROUP=$(grep docker /etc/group | cut -d':' -f3) | |
export CODER_URL="http://127.0.0.1:${AVAILABLE_PORT}" | |
echo "CODER_URL=${CODER_URL}" >> $GITHUB_ENV | |
docker compose up --detach --force-recreate --always-recreate-deps --build | |
echo "Show docker compose status..." | |
docker compose ps | |
while ! nc -z -v -w 1 127.0.0.1 ${AVAILABLE_PORT}; do | |
echo "Waiting for coder port to be ready... sleeping 5s!" | |
sleep 5 | |
docker compose ps | |
done | |
echo "Coder port is up..." | |
echo | |
while ! curl -fsSL ${CODER_URL} > /dev/null; do | |
echo "Waiting for coder service to be ready... sleep 5s!" | |
sleep 5 | |
done | |
echo "Coder service is accepting connections..." | |
echo | |
- name: Login to coder | |
# yamllint disable-line rule:indentation | |
run: | | |
echo "Determining coder version..." | |
export CODER_VERSION=$(curl -fsSL ${CODER_URL}/api/v2/buildinfo | jq -r .version | cut -d'+' -f1 | cut -d'v' -f2) | |
echo "Installing coder CLI..." | |
curl -fsSL https://coder.com/install.sh | sh -s -- --method standalone --version "${CODER_VERSION}" | |
echo | |
echo "Creating Coder admin user..." | |
password=$(openssl rand -base64 16 | tr -d "=+/" | cut -c1-12) | |
coder login --first-user-username=test-user [email protected] --first-user-password=${password} --first-user-trial=false ${CODER_URL} | |
echo "Confirming that admin user was created..." | |
curl -fsSL ${CODER_URL}/api/v2/users/first | |
echo | |
- name: Test - publish template | |
id: publish-template | |
env: | |
TEMPLATE_DIR: ${{ env.template_path }} | |
# yamllint disable-line rule:indentation | |
run: | | |
export TEMPLATE_NAME="test-$(date --utc +%Y%m%d-%H%M%SZ)" | |
echo "TEMPLATE_NAME=${TEMPLATE_NAME}" >> $GITHUB_ENV | |
echo "Publishing template ${TEMPLATE_DIR} as ${TEMPLATE_NAME}..." | |
set -x | |
coder template push \ | |
--directory ${TEMPLATE_DIR} \ | |
--var workspace_image=ubuntu:noble \ | |
--var test_mode=true \ | |
--yes \ | |
${TEMPLATE_NAME} | |
set +x | |
echo | |
echo "Confirming template has been published..." | |
coder templates list --output json > /tmp/templates.json | |
export SELECTED_TEMPLATE=$(cat /tmp/templates.json | jq -r '.[] | select(.Template.name == "'${TEMPLATE_NAME}'")') | |
if [[ -z $SELECTED_TEMPLATE ]]; then | |
echo "Could not find any template published as $TEMPLATE_NAME." | |
exit 1 | |
fi | |
echo "Template has been published successfully." | |
- name: Test - create workspace | |
id: create-workspace | |
run: | | |
export WORKSPACE_NAME="${TEMPLATE_NAME}" | |
echo "WORKSPACE_NAME=${WORKSPACE_NAME}" >> $GITHUB_ENV | |
echo "Create workspace as ${WORKSPACE_NAME}..." | |
set -x | |
coder create --template "${TEMPLATE_NAME}" --yes ${WORKSPACE_NAME} | |
- name: Test - check workspace health | |
id: check-worskpace-health | |
env: | |
verbosity: ${{ (github.event.inputs.verbosity || env.default_verbosity) }} | |
# yamllint disable-line rule:indentation | |
run: | | |
echo "Confirming that workspace is present in some state..." | |
coder list --output json > /tmp/workspaces.json | |
export SELECTED_WORKSPACE=$(cat /tmp/workspaces.json | jq -r '.[] | select(.name == "'${WORKSPACE_NAME}'")') | |
if [[ -z $SELECTED_WORKSPACE ]]; then | |
echo "Could not find any workspace published as ${WORKSPACE_NAME} in any state." | |
exit 1 | |
elif [[ $verbosity -gt 0 ]]; then | |
echo ${SELECTED_WORKSPACE} | jq -r | |
fi | |
echo "Workspace creation has started." | |
echo | |
echo "Waiting for coder agent to be ready..." | |
timeout 30s coder ping ${WORKSPACE_NAME} --num 3 --timeout 2s --wait 5s | |
echo | |
echo "Check if created workspace is healthy" | |
if coder show ${WORKSPACE_NAME} | grep main | grep '✔ healthy' > /dev/null; then | |
echo "Created workspace is healthy." | |
coder show ${WORKSPACE_NAME} | |
echo | |
else | |
echo "Created workspace is in an unhealthy state." | |
exit 1 | |
fi | |
- name: Test - connect to created workspace | |
id: check-workspace-connect | |
run: | | |
echo "Connecting to workspace..." | |
coder config-ssh --yes | |
set -x | |
ssh coder.${WORKSPACE_NAME} ls -al / | |
- name: Debug - workspace creation | |
if: ${{ failure() && (steps.create-workspace.conclusion == 'failure' || steps.check-worskpace-health.conclusion == 'failure') }} | |
run: | | |
echo Container status: | |
docker ps | |
echo | |
echo Coder logs: | |
docker logs -n 100 coder-coder-1 | |
echo | |
echo Container logs: | |
docker logs ${WORKSPACE_NAME} | |
echo | |
echo Workspace status | |
coder show ${WORKSPACE_NAME} | |
- name: Clean up - workspace | |
if: ${{ (success() || failure()) && contains(fromJSON('["success", "failure"]'), steps.create-workspace.conclusion) }} | |
run: | | |
echo "Deleting workspace ${WORKSPACE_NAME}..." | |
coder delete --yes "${WORKSPACE_NAME}" | |
- name: Clean up - template | |
if: ${{ (success() || failure()) && contains(fromJSON('["success", "failure"]'), steps.publish-template.conclusion) }} | |
run: | | |
echo "Deleting template ${TEMPLATE_NAME}..." | |
coder templates delete --yes ${TEMPLATE_NAME} | |
echo |