-
Notifications
You must be signed in to change notification settings - Fork 1
Add cross-platform template render checks in CI #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Render source templates for the current platform" | ||
| # | ||
| # The single entrypoint for template rendering: the hk render-templates hook and | ||
| # the CI legs all call this. It renders each template through chezmoi for the | ||
| # host OS (scripts/lint-templates.sh), so it self-selects via `chezmoi ignored` | ||
| # — a Windows runner checks the Windows templates, a Termux host the android | ||
| # ones, etc. Given file arguments it renders just those (the hook passes changed | ||
| # files); with none it renders every source template (CI). | ||
| set -euo pipefail | ||
|
|
||
| # Run from the repo root regardless of caller cwd, and without git: the android | ||
| # leg renders inside a container where the worktree's .git is an unmounted host | ||
| # path, and only cwd-relative paths below are portable there. $0 is this task | ||
| # file (…/mise-tasks/test/templates), so two levels up is the root. | ||
| cd "$(dirname "$0")/../.." | ||
|
|
||
| if [ "$#" -gt 0 ]; then | ||
| sh scripts/lint-templates.sh "$@" | ||
| else | ||
| # Every chezmoi source template lives under the chezmoi root (home/). `-exec … | ||
| # +` batches them into one invocation and propagates a non-zero render exit; | ||
| # portable where bash arrays / `mapfile` (bash 3.2 on macOS) are not. | ||
| find home -type f -name '*.tmpl' -exec sh scripts/lint-templates.sh {} + | ||
| fi |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Render templates in a Termux (android) environment" | ||
| # | ||
| # android has no hosted CI runner and chezmoi's `.chezmoi.os` comes from GOOS | ||
| # (unfakeable), so the android templates can only be rendered by a real Termux | ||
| # userland. On a Termux device that's native; elsewhere we borrow one from | ||
| # termux/termux-docker. Either way the render itself is the shared test:templates | ||
| # engine, so this leg checks exactly what every other platform's leg does. | ||
| set -euo pipefail | ||
|
|
||
| if [ "$(uname -o 2>/dev/null)" = "Android" ]; then | ||
| exec mise run test:templates | ||
| else | ||
| exec bash scripts/docker-run.sh scripts/render-templates-termux.sh | ||
| fi |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Run a Termux-side script inside termux/termux-docker on a non-Termux host — | ||
| # the dev-host / CI entrypoint the `test:templates-android` mise task dispatches | ||
| # to (on a Termux device that task runs natively). The image arch is matched to | ||
| # the host so it runs natively — no QEMU — on both x86_64 CI runners and Apple | ||
| # Silicon. chezmoi reports `.chezmoi.os == android` from any Termux arch, so | ||
| # unlike claude-code-termux (which forces aarch64 for its .deb) we never need a | ||
| # fixed arch or binfmt emulation. Requires Docker (Docker Desktop on | ||
| # Windows/macOS, or dockerd). | ||
| # | ||
| # scripts/docker-run.sh <script-path-relative-to-repo-root> | ||
| set -euo pipefail | ||
|
|
||
| if [ "$#" -eq 0 ]; then | ||
| echo "usage: scripts/docker-run.sh <script>" >&2 | ||
| exit 2 | ||
| fi | ||
| script="$1" | ||
| root=$(git -C "$(dirname "$0")" rev-parse --show-toplevel) | ||
|
|
||
| case "$(uname -m)" in | ||
| aarch64 | arm64) tag=aarch64 ;; | ||
| *) tag=x86_64 ;; | ||
| esac | ||
|
|
||
| echo "==> Running $script in termux-docker:$tag…" | ||
| # --privileged: termux-docker's entrypoint does namespace/mount setup and the | ||
| # image expects Android-runtime syscalls. MSYS_NO_PATHCONV stops Git Bash on | ||
| # Windows mangling the bind-mount path. The source is mounted read-only — the | ||
| # render only reads it and writes to the container's own tmp. | ||
| MSYS_NO_PATHCONV=1 docker run --rm --privileged \ | ||
| -v "$root:/src:ro" \ | ||
| "termux/termux-docker:$tag" \ | ||
| bash "/src/$script" |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Container-side half of the test:templates-android task: provision chezmoi on a | ||
| # fresh termux/termux-docker, then hand off to the shared render engine | ||
| # (mise-tasks/test/templates), so the android leg renders through exactly the | ||
| # same path as every other platform. Runs INSIDE the container (or on a real | ||
| # Termux device, where chezmoi already exists and the install is a no-op). The | ||
| # render is git-free — the read-only bind mount's .git may be an unmounted host | ||
| # path — so only chezmoi is installed. | ||
| set -euo pipefail | ||
|
|
||
| if ! command -v chezmoi >/dev/null; then | ||
| pkg update -y >/dev/null # seed the apt mirror on a fresh image | ||
| pkg install -y chezmoi >/dev/null | ||
| fi | ||
|
|
||
| exec bash "$(cd "$(dirname "$0")/.." && pwd)/mise-tasks/test/templates" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.