Skip to content

Commit e9d5356

Browse files
authored
Feature/build script (#78)
* feat(build): Add build script for WASM plugin and propagate changes to target dirs (feature/build-script) * build: add test-build job to ci-done workflow (feature/build-script)
1 parent f4d2e5a commit e9d5356

4 files changed

Lines changed: 70 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,26 @@ jobs:
173173
run: |
174174
uv run nox -s asyncpg_check
175175
176+
test-build:
177+
runs-on: ubuntu-latest
178+
179+
steps:
180+
- name: Checkout repository
181+
uses: actions/checkout@v4
182+
183+
- name: Set up Go
184+
uses: actions/setup-go@v5
185+
with:
186+
go-version: '1.24.1'
187+
188+
- name: Make build script executable
189+
run: chmod +x scripts/build/build.sh
190+
191+
- name: Run build.sh
192+
run: ./scripts/build/build.sh
193+
176194
ci-done:
177-
needs: [ test,upload-coverage, asyncpg, pyright, ruff ]
195+
needs: [ test,upload-coverage, asyncpg, pyright, ruff, test-build ]
178196
if: always() && !cancelled()
179197

180198
runs-on: ubuntu-latest

.idea/runConfigurations/Build.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

scripts/build/build.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# ──────────────────────────────
5+
# 1) CONFIGURATION
6+
# ──────────────────────────────
7+
TARGET_DIRS=("test/driver_asyncpg")
8+
SQLC_CONFIG_NAMES=("sqlc.yaml")
9+
10+
# ──────────────────────────────
11+
# 2) BUILD THE WASM PLUGIN
12+
# ──────────────────────────────
13+
echo "=== Building the Go WASM plugin ================================="
14+
export GOOS=wasip1
15+
export GOARCH=wasm
16+
go build -o sqlc-gen-better-python.wasm plugin/main.go
17+
18+
# ──────────────────────────────
19+
# 3) CALCULATE SHA‑256
20+
# ──────────────────────────────
21+
SHA256_HASH=$(sha256sum sqlc-gen-better-python.wasm | awk '{print $1}')
22+
echo "SHA-256: $SHA256_HASH"
23+
24+
# ──────────────────────────────
25+
# 4) UPDATE ROOT yaml
26+
# ──────────────────────────────
27+
echo "Patching root sqlc.yaml..."
28+
sed -i -E "s/(sha256: )\S+/\1$SHA256_HASH/" sqlc.yaml
29+
30+
# ──────────────────────────────
31+
# 5) PROPAGATE TO TARGET FOLDERS
32+
# ──────────────────────────────
33+
for dir in "${TARGET_DIRS[@]}"; do
34+
echo "--------------------------------------------------------------"
35+
echo " Processing $dir"
36+
mkdir -p "$dir"
37+
38+
cp -f sqlc-gen-better-python.wasm "$dir/"
39+
40+
for file in "${SQLC_CONFIG_NAMES[@]}"; do
41+
if [[ -f "$dir/$file" ]]; then
42+
echo " Patching $dir/$file"
43+
sed -i -E "s/(sha256: )\S+/\1$SHA256_HASH/" "$dir/$file"
44+
else
45+
echo " Warning: $dir/$file not found"
46+
fi
47+
done
48+
done
49+
50+
echo "=== All done - every sqlc.yaml now has SHA-256 $SHA256_HASH ======"

0 commit comments

Comments
 (0)