Skip to content

Commit 36fb89b

Browse files
authored
.github,update-sqlite.sh: add CI check to verify updates (#146)
To make it easier to review version bumps, add some automation that verifies the cgosqlite folder updates, leaving reviewers with just the trivial bits to review manually. Updates #cleanup Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
1 parent 2882ea9 commit 36fb89b

4 files changed

Lines changed: 52 additions & 5 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: check-sqlite-update
2+
3+
# Re-runs update-sqlite.sh against the URL recorded in version-url.txt and
4+
# checks that it reproduces exactly what is checked in.
5+
6+
on:
7+
pull_request:
8+
paths:
9+
- check-sqlite-update.yml
10+
- version-url.txt
11+
- update-sqlite.sh
12+
- cgosqlite/**
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
reproducible:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
22+
23+
- name: Run update-sqlite.sh
24+
run: ./update-sqlite.sh
25+
26+
- name: Check the working tree is unchanged
27+
run: |
28+
if [[ -n "$(git status --porcelain)" ]]; then
29+
echo "::error::update-sqlite.sh did not reproduce the checked-in files"
30+
git status --porcelain
31+
git diff --stat
32+
echo "::error::Please update version-url.txt and/or run update-sqlite.sh and commit the changes."
33+
exit 1
34+
fi

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Work in progress. Nothing to see here.
55
## Updating SQLite
66

77
The script `update-sqlite.sh` at the top of the repository partially automates
8-
this process. It expects a SQLite amalgamation URL as the first argument:
8+
this process. It accepts a SQLite amalgamation URL as the first argument, or
9+
otherwise uses the URL recorded in [version-url.txt](./version-url.txt):
910

1011
```
1112
./update-sqlite.sh https://sqlite.org/2024/sqlite-amalgamation-3460100.zip

‎update-sqlite.sh‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
#!/bin/bash
22

3+
repodir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
35
usage() {
46
echo "$0 [sqlite-amalgamation-url]"
57
echo
68
echo "Lookup the URL to a SQLite amalgamation zip on https://sqlite.org"
79
echo "Pass that URL to this tool, e.g."
810
echo " $0 https://sqlite.org/2024/sqlite-amalgamation-3460100.zip"
11+
echo
12+
echo "With no argument, re-runs against the URL already recorded in"
13+
echo "version-url.txt, which should leave the tree unchanged. CI does"
14+
echo "this to prove the vendored files are exactly the script's output."
915
}
1016

1117
fatal() {
@@ -14,7 +20,13 @@ fatal() {
1420
}
1521

1622
case "$1" in
17-
https://sqlite.org/*) ;;
23+
https://sqlite.org/*)
24+
url="$1"
25+
;;
26+
"")
27+
url=$(tr -d '[:space:]' < "$repodir/version-url.txt") || exit 1
28+
echo "$url"
29+
;;
1830
-h|--help|help)
1931
usage
2032
exit
@@ -25,17 +37,16 @@ case "$1" in
2537
;;
2638
esac
2739

28-
cd "$( dirname "${BASH_SOURCE[0]}" )"/cgosqlite || fatal "Not in correct directory"
40+
cd "$repodir/cgosqlite" || fatal "Not in correct directory"
2941

30-
url="$1"
3142
filename=$(basename "$url")
3243
dirname=$(basename -s .zip "$filename")
3344
[[ -n "$filename" ]] || fatal "Could not extract filename from $url"
3445
[[ -n "$dirname" ]] || fatal "Could not extract dirname from $filename"
3546

3647
trap "rm -rf ./${filename} ./${dirname}" EXIT
3748

38-
curl -O "$1" || fatal "Download of $url failed"
49+
curl -O "$url" || fatal "Download of $url failed"
3950
[[ -f "$filename" ]] || fatal "File $filename not found after download"
4051
unzip "$filename" || fatal "Unzip of $filename failed"
4152
[[ -d "$dirname" ]] || fatal "Directory $dirname missing after unzip"

‎version-url.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://sqlite.org/2026/sqlite-amalgamation-3530100.zip

0 commit comments

Comments
 (0)