From 0e28e3691f20e005befb36c358f87d0c86c8abef Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 7 Dec 2020 12:28:52 +0100 Subject: [PATCH] Add simple validation CI --- .github/workflows/sqlite.yml | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/sqlite.yml diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml new file mode 100644 index 00000000..4c1aab42 --- /dev/null +++ b/.github/workflows/sqlite.yml @@ -0,0 +1,65 @@ +name: Check SQLite sources + +on: + push: + branches: + - sqlite + pull_request: + branches: + - sqlite + +jobs: + validate: + name: "Validate SQLite sources" + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: "Get SQLite version info" + env: + # See https://sqlite.org/c3ref/c_source_id.html + SQLITE_H: sqlite3.h + VERSION_RE: "^#define SQLITE_VERSION\\>.*\\([0-9]\\+.[0-9]\\+.[0-9]\\+\\).*" + DATE_RE: "^#define SQLITE_SOURCE_ID.*\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\).*" + id: info + run: | + VERSION=$(sed -n "s/${VERSION_RE}/\\1/p" $SQLITE_H) + test -z $VERSION && false + echo "::set-output name=version::$VERSION" + + # ISO 8601 date should have 10 characters: YYYY-MM-DD + DATE=$(sed -n "s/${DATE_RE}/\\1/p" $SQLITE_H) + test ${#DATE} -eq 10 + echo "::set-output name=date::$DATE" + + - name: "Get URL" + id: url + env: + VERSION: ${{ steps.info.outputs.version }} + DATE: ${{ steps.info.outputs.date }} + run: | + YEAR=$(echo $DATE | cut -d '-' -f 1) + MAJOR=$(echo $VERSION | cut -d '.' -f 1) + MINOR=$(echo $VERSION | cut -d '.' -f 2) + PATCH=$(echo $VERSION | cut -d '.' -f 3) + + # See https://sqlite.org/download.html + printf -v ENCODED_VERSION "%d%02d%02d00" $MAJOR $MINOR $PATCH + URL="https://sqlite.org/$YEAR/sqlite-amalgamation-${ENCODED_VERSION}.zip" + echo "::set-output name=url::$URL" + + - name: "Download and validate SQLite amalgamation sources" + env: + URL: ${{ steps.url.outputs.url }} + run: | + curl -sO $URL + + ARCHIVE=$(basename $URL) + unzip -o $ARCHIVE + + DIR=$(basename $ARCHIVE .zip) + for _F in *.[ch]; do + cmp $_F $DIR/$_F && echo "$_F: check" + done -- 2.30.0.rc0.dirty