Skip to content

Add Taskfile.yaml and CI workflow#2

Merged
philpennock merged 6 commits intomainfrom
claude/add-taskfile-and-gh-actions-6mflx
Mar 13, 2026
Merged

Add Taskfile.yaml and CI workflow#2
philpennock merged 6 commits intomainfrom
claude/add-taskfile-and-gh-actions-6mflx

Conversation

@philpennock
Copy link
Copy Markdown
Collaborator

I wanted CI tests for protecting merges to main, so asked Claude to write, using Taskfile.

My "bright idea" of task install:$editor_name for editors where we could drop in a single file or not do complicated edits resulted in: 0 editors in task, they all require edits which couldn't be safely made.

But this has advanced things to where the README docs actually work for dev, not just for install, and made the process more robust, removing an npx layer which just created problems.

Phil's Claude AI Account and others added 5 commits March 13, 2026 16:00
Taskfile provides tasks for building, testing, generating, and
system-installing the grammar, plus ci: targets for automated checks.

Editor install tasks are intentionally omitted — all supported editors
require editing user config files, which cannot be done safely or
idempotently by automation.  See docs/editors/ for manual instructions.

The GitHub Actions workflow runs the tree-sitter test corpus and example
parsing on push/PR to main, and validates workflow files with zizmor.
All action references are pinned to commit SHAs per security best
practice.

https://claude.ai/code/session_01B9bVHXAhzTQ1kzF9CDj8nq
tree-sitter-cli 0.25.x has native addon issues with Node 24+.
Add .tool-versions pinning nodejs 22.16.0 for asdf/mise users,
a _check-node internal task that gates generate/test targets on
Node >=22 <24, and point the CI workflow at .tool-versions instead
of hardcoding lts/*.

https://claude.ai/code/session_01B9bVHXAhzTQ1kzF9CDj8nq
The tree-sitter-cli package downloads its binary via a postinstall
script.  Without an explicit npm ci step, npx finds the package but
the binary is missing, causing ENOENT.  Add an internal _npm-deps
task (with source/generates caching) as a dependency of generate,
test, and test:parse-examples.

https://claude.ai/code/session_01B9bVHXAhzTQ1kzF9CDj8nq
The tree-sitter-cli npm wrapper downloads a platform-specific binary as
a postinstall step.  When that download fails silently the binary is
missing and every `npx tree-sitter` invocation fails with ENOENT.

Instead, require tree-sitter to be installed via `cargo install
tree-sitter-cli` (or any other method that puts it in $PATH).  The
Taskfile now checks for both node and tree-sitter before running tasks.

Changes:
- Taskfile.yaml: remove TS_NPX var, rename _check-node → _check-tools,
  add tree-sitter precondition, use bare `tree-sitter` in all commands
- package.json: remove tree-sitter-cli devDependency
- README.md / docs/editors/vscode.md: replace npx invocations with bare
  tree-sitter commands

https://claude.ai/code/session_01B9bVHXAhzTQ1kzF9CDj8nq
Now that tree-sitter-cli is no longer an npm devDependency, the CI
runner needs the binary installed separately. Use the official
tree-sitter/setup-action (CLI only, no lib needed).

https://claude.ai/code/session_01B9bVHXAhzTQ1kzF9CDj8nq
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Taskfile-driven developer workflow and adds GitHub Actions CI for tests, while shifting from npx tree-sitter ... to invoking the tree-sitter CLI directly.

Changes:

  • Add Taskfile.yaml with build/test/CI tasks and tool precondition checks.
  • Add GitHub Actions workflow to run tests and validate workflows with zizmor.
  • Remove tree-sitter-cli from npm devDependencies and update docs/README to stop using npx tree-sitter.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
package.json Removes tree-sitter-cli from devDependencies (impacts how tree-sitter is provided).
package-lock.json Lockfile updates reflecting removal of tree-sitter-cli.
README.md Updates Quick Start commands to call tree-sitter directly.
docs/editors/vscode.md Updates WASM build command to call tree-sitter directly.
Taskfile.yaml Adds task automation for generate/build/test/CI checks with preconditions.
.tool-versions Pins Node.js version for consistent dev/CI environments.
.gitignore Ignores Task’s working directory .task/.
.github/workflows/ci.yaml Adds CI workflow running Taskfile targets and zizmor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

desc: Validate GitHub Actions workflows with zizmor
preconditions:
- sh: command -v zizmor
msg: "zizmor is not installed — pip install zizmor"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The means for a human to install are not those that the CI system should use.

I will push an update which switches GH Actions to use the zizmorcore/zizmor-action action instead.

with:
node-version-file: .tool-versions
cache: npm
- run: npm ci
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No: the Taskfile is used by humans, not just by the GH Actions setup, as humans might want to debug what's going on. The GH Actions step does the install as a separate isolation step for better isolation of what's going on, and should ensure that the subsequent task invocation effectively no-ops the npm ci invocation -- all downloads will already be present.

The duplicated invocation, as long as it does not delete and re-download, is absolutely fine.

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- run: pipx run zizmor --format plain .github/workflows/
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above: switching to the official Action instead.

},
"devDependencies": {
"tree-sitter-cli": "^0.25.3",
"prebuildify": "^6.0.1"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO. The tree-sitter-cli dep is broken; instead we (1) install tree-sitter in the GH workflow, and (2) have the _check-tools Task check that the tool is installed.

This removal was deliberate and improves reliability and reproducibility.

Comment on lines 24 to +35
```bash
# Install dependencies
npm install

# Generate the parser
npx tree-sitter generate
tree-sitter generate

# Run tests
npx tree-sitter test
tree-sitter test

# Parse a file
npx tree-sitter parse examples/basic.conf
tree-sitter parse examples/basic.conf
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair: I will make such a change locally, better.

Comment on lines 14 to 20
git clone https://github.com/synadia-labs/treesitter-nats-server.git
```
3. Build the WASM module:
```bash
cd tree-sitter-nats-server-conf
npx tree-sitter build --wasm
tree-sitter build --wasm
```
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address with my own phrasing.

msg: "node is not installed — install Node.js 22 LTS (see .tool-versions)"
- sh: |
major=$(node -p "process.versions.node.split(\".\")[0]")
test "$major" -ge 22 -a "$major" -lt 24
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO: this is taskfile.dev which uses mvdan.cc/sh/v3 to embed an interpreter which implements much of bash. Part of the point here is to avoid the chaos of a bazillion different sh implementations with incompatible subsets of functionality, and instead have a reliable sh.

The task sh: implementation handles this fine and does not need work-arounds.

We now install zizmor via the official `zizmorcore/zizmor-action` action,
properly pinned.

Update various docs around how the tree-sitter command is installed.

Testing the vscode steps created a .wasm file which was not being gitignored,
so update `.gitignore` with patterns to match all build artifacts and not
assume a sane user/global gitignore.
@philpennock philpennock added this pull request to the merge queue Mar 13, 2026
@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Merged via the queue into main with commit de4641d Mar 13, 2026
3 checks passed
@philpennock philpennock deleted the claude/add-taskfile-and-gh-actions-6mflx branch March 13, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants