Skip to content

Commit 2f9b748

Browse files
JonZeollaclaude
andcommitted
fix: fail on missing buildx, use docker wrapper, and fix get_epoch.sh
Revert the graceful buildx skip — missing buildx is a real failure. Move WSL+Docker setup before task init and create a docker wrapper script that routes all docker commands through WSL, so task init and task build work transparently. Also use task build instead of manual docker commands. Fix get_epoch.sh to use bash directly (uv run can't execute .sh files on Windows). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent afd5b02 commit 2f9b748

2 files changed

Lines changed: 33 additions & 35 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,31 @@ jobs:
217217
}
218218
219219
Write-Host "Windows smoke test passed: project generated and verified successfully"
220+
- name: Setup WSL with Docker
221+
shell: bash
222+
run: |
223+
wsl --install -d Ubuntu-24.04 --no-launch
224+
wsl -d Ubuntu-24.04 -u root -- bash -ec "
225+
apt-get update -qq
226+
apt-get install -y -qq curl ca-certificates >/dev/null
227+
curl -fsSL https://get.docker.com | sh -s -- --quiet
228+
service docker start
229+
"
230+
231+
# Create a docker wrapper so Task commands use WSL's Docker.
232+
# Pass --cd with the converted CWD so docker build contexts resolve.
233+
mkdir -p "$HOME/bin"
234+
cat > "$HOME/bin/docker" << 'WRAPPER'
235+
#!/bin/bash
236+
# Convert Windows CWD to WSL /mnt/ path
237+
win_cwd="$(pwd -W 2>/dev/null || pwd)"
238+
drive="$(echo "${win_cwd:0:1}" | tr '[:upper:]' '[:lower:]')"
239+
rest="${win_cwd:3}"
240+
wsl_cwd="/mnt/$drive/$(echo "$rest" | tr '\\' '/')"
241+
exec wsl -d Ubuntu-24.04 -u root --cd "$wsl_cwd" -- docker "$@"
242+
WRAPPER
243+
chmod +x "$HOME/bin/docker"
244+
echo "$HOME/bin" >> "$GITHUB_PATH"
220245
- name: Initialize generated project
221246
shell: bash
222247
run: |
@@ -229,37 +254,16 @@ jobs:
229254
run: |
230255
cd "$RUNNER_TEMP/replace-me"
231256
task -v unit-test
232-
- name: Setup WSL with Docker
233-
shell: bash
234-
run: |
235-
wsl --install -d Ubuntu-24.04 --no-launch
236-
wsl -d Ubuntu-24.04 -u root -- bash -ec "
237-
apt-get update -qq
238-
apt-get install -y -qq curl ca-certificates >/dev/null
239-
curl -fsSL https://get.docker.com | sh -s -- --quiet
240-
service docker start
241-
docker buildx create --use
242-
"
243257
- name: Build Docker image
244-
shell: pwsh
258+
shell: bash
245259
run: |
246-
# Convert Windows path to WSL path (e.g. D:\a\_temp → /mnt/d/a/_temp)
247-
$drive = "$env:RUNNER_TEMP"[0].ToString().ToLower()
248-
$rest = "$env:RUNNER_TEMP".Substring(3).Replace('\', '/')
249-
$wslProject = "/mnt/$drive/$rest/replace-me"
250-
Write-Host "Building from WSL path: $wslProject"
251-
wsl -d Ubuntu-24.04 -u root --cd $wslProject -- docker buildx build `
252-
--platform linux/amd64 `
253-
--pull --load `
254-
--build-arg NAME=replace_me `
255-
--build-arg "DESCRIPTION=A brief description of the project" `
256-
--build-arg COMMIT_HASH=smoke-test `
257-
-t zenable-io/replace-me:latest .
260+
cd "$RUNNER_TEMP/replace-me"
261+
task -v build
258262
- name: Verify Docker image
259-
shell: pwsh
263+
shell: bash
260264
run: |
261-
wsl -d Ubuntu-24.04 -u root -- docker run --rm --entrypoint python3 `
262-
zenable-io/replace-me:latest `
265+
docker run --rm --entrypoint python3 \
266+
zenable-io/replace-me:latest \
263267
-c "from replace_me import __version__; print(__version__)"
264268
- name: Verify zenable CLI
265269
shell: bash

{{cookiecutter.project_name|replace(" ", "")}}/Taskfile.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,7 @@ tasks:
6060
# This fixes an "ERROR: Multiple platforms feature is currently not supported for docker driver" pipeline error
6161
# Only create our multiplatform builder if it doesn't already exist; otherwise list information about the one that exists
6262
# It suppresses the inspect output when it's not running in a GitHub Action
63-
# Skip gracefully if docker buildx is not available (e.g. Windows without buildx plugin)
64-
- |
65-
if ! docker buildx version > /dev/null 2>&1; then
66-
echo "docker buildx not available, skipping multiplatform setup"
67-
exit 0
68-
fi
69-
docker buildx inspect multiplatform {{ '{{if ne .GITHUB_ACTIONS "true"}}' }}>/dev/null{{ '{{end}}' }} || docker buildx create --name multiplatform --driver docker-container --use
63+
- docker buildx inspect multiplatform {{ '{{if ne .GITHUB_ACTIONS "true"}}' }}>/dev/null{{ '{{end}}' }} || docker buildx create --name multiplatform --driver docker-container --use
7064

7165
init:
7266
desc: Initialize the repo for local use; intended to be run after git clone
@@ -94,7 +88,7 @@ tasks:
9488
TIMESTAMP:
9589
sh: '{{ '{{.RUN_SCRIPT}}' }} {{ '{{.SCRIPTS_DIR}}' }}/get_rfc3339_timestamp.py'
9690
EPOCH:
97-
sh: '{{ '{{.RUN_SCRIPT}}' }} {{ '{{.SCRIPTS_DIR}}' }}/get_epoch.sh'
91+
sh: 'bash {{ '{{.SCRIPTS_DIR}}' }}/get_epoch.sh'
9892
COMMIT_HASH:
9993
sh: git rev-parse HEAD
10094
BUILD_PLATFORM: '{{ '{{if eq .PLATFORM "all"}}' }}{{ '{{.SUPPORTED_PLATFORMS}}' }}{{ '{{else if .PLATFORM}}' }}{{ '{{.PLATFORM}}' }}{{ '{{else}}' }}{{ '{{.LOCAL_PLATFORM}}' }}{{ '{{end}}' }}'

0 commit comments

Comments
 (0)