Skip to content

Commit ad6a317

Browse files
committed
🎨 Template bootstrap by kettle-jem v1.0.0
1 parent d89a230 commit ad6a317

42 files changed

Lines changed: 262 additions & 160 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/scripts/setup-tree-sitter.sh

Lines changed: 87 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,33 @@ set -e
99
# - Devcontainer: Can run as root (apt-install feature) or non-root (postCreateCommand)
1010
# - Auto-detection: Checks if running as root (id -u = 0), uses sudo if non-root
1111
#
12-
# This script installs ALL tree-sitter grammars for integration testing
12+
# Grammar building is delegated to tsdl (https://github.com/stackmystack/tsdl).
13+
# Configure grammars and versions in parsers.toml at the project root.
1314
#
1415
# Options:
1516
# --sudo: Force use of sudo (optional, auto-detected by default)
1617
# --cli: Install tree-sitter-cli via npm (optional)
1718
# --build: Build and install the tree-sitter C runtime from source when distro packages are missing (optional)
18-
# --workspace PATH: Workspace root path for informational/debugging purposes only (defaults to /workspaces/tree_haver)
19+
# --tsdl-version VERSION: Pin tsdl release version (default: v2.0.0)
20+
# --workspace PATH: Workspace root path for informational/debugging purposes only
1921

2022
SUDO=""
2123
INSTALL_CLI=false
2224
BUILD_FROM_SOURCE=false
25+
TSDL_VERSION="v2.0.0"
2326
WORKSPACE_ROOT="/workspaces/${PWD##*/}"
2427

2528
# Parse arguments properly using while loop
2629
while [[ $# -gt 0 ]]; do
2730
case $1 in
28-
--sudo)
29-
SUDO="sudo"
30-
shift
31-
;;
32-
--cli)
33-
INSTALL_CLI=true
34-
shift
35-
;;
36-
--build)
37-
BUILD_FROM_SOURCE=true
38-
shift
39-
;;
40-
--workspace)
41-
WORKSPACE_ROOT="$2"
42-
shift 2
43-
;;
44-
--workspace=*)
45-
WORKSPACE_ROOT="${1#*=}"
46-
shift
47-
;;
48-
*)
49-
echo "Unknown option: $1" >&2
50-
shift
51-
;;
31+
--sudo) SUDO="sudo"; shift ;;
32+
--cli) INSTALL_CLI=true; shift ;;
33+
--build) BUILD_FROM_SOURCE=true; shift ;;
34+
--tsdl-version) TSDL_VERSION="$2"; shift 2 ;;
35+
--tsdl-version=*) TSDL_VERSION="${1#*=}"; shift ;;
36+
--workspace) WORKSPACE_ROOT="$2"; shift 2 ;;
37+
--workspace=*) WORKSPACE_ROOT="${1#*=}"; shift ;;
38+
*) echo "Unknown option: $1" >&2; shift ;;
5239
esac
5340
done
5441

@@ -62,6 +49,7 @@ echo " Workspace root: $WORKSPACE_ROOT (informational only)"
6249
echo " Using sudo: $([ -n "$SUDO" ] && echo "yes" || echo "no")"
6350
echo " Install CLI: $INSTALL_CLI"
6451
echo " Build from source: $BUILD_FROM_SOURCE"
52+
echo " tsdl version: $TSDL_VERSION"
6553
echo ""
6654

6755
have_cmd() { command -v "$1" >/dev/null 2>&1; }
@@ -74,29 +62,67 @@ have_tree_sitter() {
7462
}
7563

7664
install_tree_sitter_from_source() {
77-
echo "[ubuntu] Attempting to build and install tree-sitter from source..."
65+
echo "[tree-sitter] Building runtime from source..."
7866
tmpdir=$(mktemp -d /tmp/tree-sitter-src-XXXX)
7967
trap 'rm -rf "$tmpdir"' EXIT
8068
git clone --depth 1 https://github.com/tree-sitter/tree-sitter.git "$tmpdir" || return 1
8169
pushd "$tmpdir" >/dev/null || return 1
8270
if ! make; then
83-
echo "[ubuntu] ERROR: 'make' failed while building tree-sitter" >&2
71+
echo "[tree-sitter] ERROR: 'make' failed" >&2
8472
popd >/dev/null
8573
return 1
8674
fi
87-
8875
$SUDO mkdir -p /usr/local/include/tree-sitter
8976
$SUDO cp -r lib/include/* /usr/local/include/tree-sitter/ || true
9077
$SUDO cp -a lib/libtree-sitter.* /usr/local/lib/ 2>/dev/null || true
91-
if have_cmd ldconfig; then
92-
$SUDO ldconfig || true
93-
fi
94-
78+
have_cmd ldconfig && $SUDO ldconfig || true
9579
popd >/dev/null
96-
echo "[ubuntu] tree-sitter built and installed to /usr/local (headers + libs)."
80+
echo "[tree-sitter] Runtime installed to /usr/local."
9781
return 0
9882
}
9983

84+
install_tsdl() {
85+
if have_cmd tsdl; then
86+
echo "[tsdl] Already installed: $(tsdl --version)"
87+
return 0
88+
fi
89+
90+
echo "[tsdl] Installing tsdl ${TSDL_VERSION}..."
91+
local arch
92+
arch="$(uname -m)"
93+
case "$arch" in
94+
x86_64) arch="x64" ;;
95+
aarch64) arch="arm64" ;;
96+
armv7l) arch="arm" ;;
97+
i686) arch="x86" ;;
98+
*) echo "[tsdl] ERROR: Unsupported architecture: $arch" >&2; return 1 ;;
99+
esac
100+
101+
local os
102+
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
103+
case "$os" in
104+
linux) os="linux" ;;
105+
darwin) os="macos" ;;
106+
*) echo "[tsdl] ERROR: Unsupported OS: $os" >&2; return 1 ;;
107+
esac
108+
109+
local url="https://github.com/stackmystack/tsdl/releases/download/${TSDL_VERSION}/tsdl-${os}-${arch}.gz"
110+
local tmpbin
111+
tmpbin=$(mktemp /tmp/tsdl-XXXX)
112+
113+
if ! wget -q "$url" -O "${tmpbin}.gz"; then
114+
echo "[tsdl] ERROR: Failed to download from $url" >&2
115+
return 1
116+
fi
117+
gunzip -f "${tmpbin}.gz"
118+
chmod +x "$tmpbin"
119+
$SUDO mv "$tmpbin" /usr/local/bin/tsdl
120+
echo "[tsdl] Installed: $(tsdl --version)"
121+
}
122+
123+
# --- 1. System dependencies ---
124+
echo "Installing system dependencies..."
125+
100126
echo "Installing tree-sitter system library and dependencies..."
101127
$SUDO apt-get update -y
102128
# libtree-sitter-dev is optional when building from source via --build
@@ -117,39 +143,40 @@ if ! $SUDO apt-get install -y \
117143
libcurl4-openssl-dev \
118144
software-properties-common \
119145
libffi-dev; then
120-
echo "ERROR: apt-get failed to install required packages."
121-
echo "Please check your network, package sources, and re-run this script."
146+
echo "ERROR: apt-get failed to install required packages." >&2
122147
exit 1
123148
fi
124149

125-
# If the user requested a source-build, skip installing libtree-sitter-dev
150+
# --- 2. Tree-sitter runtime ---
126151
if [ "$BUILD_FROM_SOURCE" = true ]; then
127-
echo "[ubuntu] --build specified; skipping distro package 'libtree-sitter-dev' and building tree-sitter from source."
152+
echo "[tree-sitter] --build specified; building runtime from source."
128153
fi
129154

130155
# Ensure tree-sitter is available; if not, attempt to build from source
131156
if ! have_tree_sitter; then
132157
if [ "$BUILD_FROM_SOURCE" = true ]; then
133-
echo "[ubuntu] tree-sitter not found in system paths; attempting to build from source as requested (--build)."
134158
if ! install_tree_sitter_from_source; then
135-
echo "[ubuntu] ERROR: Failed to provide tree-sitter runtime/library. Aborting." >&2
159+
echo "[tree-sitter] ERROR: Failed to build runtime. Aborting." >&2
136160
exit 1
137161
fi
138162
else
139-
echo "[ubuntu] ERROR: tree-sitter runtime (headers/libs) not found."
140-
echo "Install the appropriate distro package (e.g., libtree-sitter-dev) or re-run this script with --build to compile from source."
163+
echo "[tree-sitter] ERROR: Runtime (headers/libs) not found." >&2
164+
echo "Install libtree-sitter-dev or re-run with --build." >&2
141165
exit 1
142166
fi
143167
fi
144168

145-
# Install tree-sitter CLI via npm (optional)
169+
# --- 3. tree-sitter-cli (optional) ---
146170
if [ "$INSTALL_CLI" = true ]; then
147171
echo "Installing tree-sitter-cli via npm..."
148172
$SUDO npm install -g tree-sitter-cli
149173
else
150-
echo "Skipping tree-sitter-cli installation (use --cli flag to install)"
174+
echo "Skipping tree-sitter-cli (use --cli to install)"
151175
fi
152176

177+
# --- 4. Install tsdl and build grammars ---
178+
install_tsdl
179+
153180
# Install all tree-sitter grammars for integration testing
154181
GRAMMARS=("toml" "json" "jsonc" "bash")
155182

@@ -209,7 +236,20 @@ if ! $SUDO ldconfig; then
209236
fi
210237

211238
echo ""
239+
echo "Building tree-sitter grammars via tsdl..."
240+
# Use parsers.toml from the project root if it exists, otherwise build defaults.
241+
# tsdl automatically reads parsers.toml in the current directory.
242+
if [ -f parsers.toml ]; then
243+
echo "[tsdl] Using parsers.toml config"
244+
$SUDO tsdl build --out-dir /usr/local/lib --progress plain
245+
else
246+
echo "[tsdl] No parsers.toml found; building default grammars: toml json bash rbs"
247+
$SUDO tsdl build toml json bash rbs --out-dir /usr/local/lib --progress plain
248+
fi
249+
250+
$SUDO ldconfig || echo "WARNING: ldconfig failed" >&2
212251
echo "tree-sitter setup complete!"
252+
213253
echo ""
214254
echo "Detected library paths:"
215255

@@ -225,9 +265,11 @@ elif [ -f /usr/lib/libtree-sitter.so ]; then
225265
else
226266
echo " WARNING: Could not find libtree-sitter runtime library!"
227267
fi
228-
229268
echo ""
230269
echo "Grammar libraries:"
231270
for grammar in "${GRAMMARS[@]}"; do
232271
echo " TREE_SITTER_${grammar^^}_PATH=/usr/local/lib/libtree-sitter-${grammar}.so"
233272
done
273+
for lib in /usr/local/lib/libtree-sitter-*.so; do
274+
[ -f "$lib" ] && echo " $lib"
275+
done

.github/workflows/auto-assign.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
pull-requests: write
1313
steps:
1414
- name: 'Auto-assign issue'
15-
uses: pozil/auto-assign-issue@v2
15+
uses: pozil/auto-assign-issue@39c06395cbac76e79afc4ad4e5c5c6db6ecfdd2e # v2.2.0
1616
with:
1717
repo-token: ${{ secrets.GITHUB_TOKEN }}
1818
assignees: "pboling"

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v6
41+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v4
45+
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
5353
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5454
# If this step fails, then you should remove it and run the build manually (see below)
5555
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v4
56+
uses: github/codeql-action/autobuild@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
5757

5858
# ℹ️ Command-line programs to run using the OS shell.
5959
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
6767
# make release
6868

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v4
70+
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1

.github/workflows/coverage.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ jobs:
5555

5656
steps:
5757
- name: Checkout
58-
uses: actions/checkout@v6
58+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5959

6060
- name: Setup Ruby & RubyGems
61-
uses: ruby/setup-ruby@v1
61+
uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1.300.0
6262
with:
6363
ruby-version: "${{ matrix.ruby }}"
6464
rubygems: "${{ matrix.rubygems }}"
@@ -89,14 +89,14 @@ jobs:
8989
# Do SaaS coverage uploads first
9090
- name: Upload coverage to Coveralls
9191
if: ${{ !env.ACT }}
92-
uses: coverallsapp/github-action@master
92+
uses: coverallsapp/github-action@0a51d2e0b5417d06e4ecceb534aec87defc53926 # main
9393
with:
9494
github-token: ${{ secrets.GITHUB_TOKEN }}
9595
continue-on-error: ${{ matrix.experimental != 'false' }}
9696

9797
- name: Upload coverage to QLTY
9898
if: ${{ !env.ACT }}
99-
uses: qltysh/qlty-action/coverage@main
99+
uses: qltysh/qlty-action/coverage@a19242102d17e497f437d7466aa01b528537e899 # v2.2.0
100100
with:
101101
token: ${{secrets.QLTY_COVERAGE_TOKEN}}
102102
files: coverage/.resultset.json
@@ -106,7 +106,7 @@ jobs:
106106
# which will hopefully be noticed for the lack of code coverage comments
107107
- name: Upload coverage to CodeCov
108108
if: ${{ !env.ACT }}
109-
uses: codecov/codecov-action@v6
109+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
110110
with:
111111
use_oidc: true
112112
fail_ci_if_error: false # optional (default = false)
@@ -116,7 +116,7 @@ jobs:
116116
# Then PR comments
117117
- name: Code Coverage Summary Report
118118
if: ${{ !env.ACT && github.event_name == 'pull_request' }}
119-
uses: irongut/CodeCoverageSummary@v1.3.0
119+
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
120120
with:
121121
filename: ./coverage/coverage.xml
122122
badge: true
@@ -130,7 +130,7 @@ jobs:
130130
continue-on-error: ${{ matrix.experimental != 'false' }}
131131

132132
- name: Add Coverage PR Comment
133-
uses: marocchino/sticky-pull-request-comment@v3
133+
uses: marocchino/sticky-pull-request-comment@d4d6b0936434b21bc8345ad45a440c5f7d2c40ff # v3.0.3
134134
if: ${{ !env.ACT && github.event_name == 'pull_request' }}
135135
with:
136136
recreate: true

.github/workflows/current.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ jobs:
6464
steps:
6565
- name: Checkout
6666
if: ${{ !env.ACT || (! startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, 'truffleruby')) }}
67-
uses: actions/checkout@v6
67+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6868

6969
- name: Setup Ruby & RubyGems
7070
if: ${{ !env.ACT || (! startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, 'truffleruby')) }}
71-
uses: ruby/setup-ruby@v1
71+
uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1.300.0
7272
with:
7373
ruby-version: ${{ matrix.ruby }}
7474
rubygems: ${{ matrix.rubygems }}

.github/workflows/dep-heads.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ jobs:
6666
steps:
6767
- name: Checkout
6868
if: ${{ !env.ACT || (! startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, 'truffleruby')) }}
69-
uses: actions/checkout@v6
69+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7070

7171
- name: Setup Ruby & RubyGems
7272
if: ${{ !env.ACT || (! startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, 'truffleruby')) }}
73-
uses: ruby/setup-ruby@v1
73+
uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1.300.0
7474
with:
7575
ruby-version: ${{ matrix.ruby }}
7676
rubygems: ${{ matrix.rubygems }}

.github/workflows/dependency-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: 'Checkout Repository'
18-
uses: actions/checkout@v6
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1919
- name: 'Dependency Review'
20-
uses: actions/dependency-review-action@v4
20+
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0

.github/workflows/heads.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ jobs:
6565
steps:
6666
- name: Checkout
6767
if: ${{ !env.ACT || (! startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, 'truffleruby')) }}
68-
uses: actions/checkout@v6
68+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6969

7070
- name: Setup Ruby & RubyGems
7171
if: ${{ !env.ACT || (! startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, 'truffleruby')) }}
72-
uses: ruby/setup-ruby@v1
72+
uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1.300.0
7373
with:
7474
ruby-version: ${{ matrix.ruby }}
7575
rubygems: ${{ matrix.rubygems }}

.github/workflows/jruby-9.1.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ jobs:
4747
steps:
4848
- name: Checkout
4949
if: ${{ !env.ACT }}
50-
uses: actions/checkout@v6
50+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5151

5252
- name: Setup Ruby & RubyGems
5353
if: ${{ !env.ACT }}
54-
uses: ruby/setup-ruby@v1
54+
uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1.300.0
5555
with:
5656
ruby-version: ${{ matrix.ruby }}
5757
rubygems: ${{ matrix.rubygems }}

0 commit comments

Comments
 (0)