Skip to content

Commit 0e28e36

Browse files
author
Erlend E. Aasland
committed
Add simple validation CI
1 parent b04e151 commit 0e28e36

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/sqlite.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Check SQLite sources
2+
3+
on:
4+
push:
5+
branches:
6+
- sqlite
7+
pull_request:
8+
branches:
9+
- sqlite
10+
11+
jobs:
12+
validate:
13+
name: "Validate SQLite sources"
14+
runs-on: ubuntu-20.04
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 1
19+
20+
- name: "Get SQLite version info"
21+
env:
22+
# See https://sqlite.org/c3ref/c_source_id.html
23+
SQLITE_H: sqlite3.h
24+
VERSION_RE: "^#define SQLITE_VERSION\\>.*\\([0-9]\\+.[0-9]\\+.[0-9]\\+\\).*"
25+
DATE_RE: "^#define SQLITE_SOURCE_ID.*\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\).*"
26+
id: info
27+
run: |
28+
VERSION=$(sed -n "s/${VERSION_RE}/\\1/p" $SQLITE_H)
29+
test -z $VERSION && false
30+
echo "::set-output name=version::$VERSION"
31+
32+
# ISO 8601 date should have 10 characters: YYYY-MM-DD
33+
DATE=$(sed -n "s/${DATE_RE}/\\1/p" $SQLITE_H)
34+
test ${#DATE} -eq 10 || false
35+
echo "::set-output name=date::$DATE"
36+
37+
- name: "Get URL"
38+
id: url
39+
env:
40+
VERSION: ${{ steps.info.outputs.version }}
41+
DATE: ${{ steps.info.outputs.date }}
42+
run: |
43+
YEAR=$(echo $DATE | cut -d '-' -f 1)
44+
MAJOR=$(echo $VERSION | cut -d '.' -f 1)
45+
MINOR=$(echo $VERSION | cut -d '.' -f 2)
46+
PATCH=$(echo $VERSION | cut -d '.' -f 3)
47+
48+
# See https://sqlite.org/download.html
49+
printf -v ENCODED_VERSION "%d%02d%02d00" $MAJOR $MINOR $PATCH
50+
URL="https://sqlite.org/$YEAR/sqlite-amalgamation-${ENCODED_VERSION}.zip"
51+
echo "::set-output name=url::$URL"
52+
53+
- name: "Download and validate SQLite amalgamation sources"
54+
env:
55+
URL: ${{ steps.url.outputs.url }}
56+
run: |
57+
curl -sO $URL
58+
59+
ARCHIVE=$(basename $URL)
60+
unzip -o $ARCHIVE
61+
62+
DIR=$(basename $ARCHIVE .zip)
63+
for _F in *.[ch]; do
64+
cmp $_F $DIR/$_F && echo "$_F: check"
65+
done

0 commit comments

Comments
 (0)