Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts/*.sh text eol=lf
50 changes: 50 additions & 0 deletions .github/actions/sqlite/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: SQLite library
description: >-
Provides the static SQLite library that the native tests link on Linux and Windows, libs/<target>/libsqlite3.a,
which isn't in the repository: from the cache, or built from the sources of the version with scripts/build-sqlite.sh

inputs:
version:
description: The SQLite version, one that scripts/build-sqlite.sh lists
required: true
target:
description: linux or windows
required: true

runs:
using: composite
steps:
# A version's library never changes unless how it is built does, so it is almost always here
- name: Restore SQLite ${{ inputs.version }} from the cache
id: cache
uses: actions/cache@v4
with:
path: libs/${{ inputs.target }}/libsqlite3.a
key: sqlite-${{ inputs.target }}-${{ inputs.version }}-${{ hashFiles('scripts/build-sqlite.sh', '.github/actions/sqlite/action.yml') }}

# zig comes from PyPI, which needs a Python that pip may install into, as that of Ubuntu isn't
- name: Set up Python
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Build SQLite ${{ inputs.version }}
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
env:
ZIG_VERSION: 0.16.0
ZIG: python -m ziglang
SQLITE_VERSION: ${{ inputs.version }}
SQLITE_TARGET: ${{ inputs.target }}
run: |
python -m pip install --quiet "ziglang==$ZIG_VERSION"
bash scripts/build-sqlite.sh "$SQLITE_VERSION" "$SQLITE_TARGET"

- name: Show the SQLite library
shell: bash
env:
SQLITE_TARGET: ${{ inputs.target }}
run: |
ls -l "libs/$SQLITE_TARGET/libsqlite3.a"
if command -v sha256sum > /dev/null 2>&1; then sha256sum "libs/$SQLITE_TARGET/libsqlite3.a"; else shasum -a 256 "libs/$SQLITE_TARGET/libsqlite3.a"; fi
137 changes: 128 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Kotlin/Native's compiler and the dependencies it downloads, which only change with the Kotlin version: keyed by
# it, rather than by the build scripts, whose every change stored another copy of hundreds of megabytes. Without
# restore-keys, so that a new version doesn't keep the files of the one before
- name: Read the Kotlin version
id: kotlin
shell: bash
run: |
# Without the CR of the lines that a checkout on Windows ends with CRLF
version=$(tr -d '\r' < gradle/libs.versions.toml | sed -n 's/^kotlin = "\(.*\)"$/\1/p')
test -n "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Cache Kotlin/Native
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-konan-
key: ${{ runner.os }}-konan-${{ steps.kotlin.outputs.version }}

- name: Build sqllin-driver
run: ./gradlew :sqllin-driver:assemble -PonCICD
Expand Down Expand Up @@ -83,6 +93,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Build SQLite
uses: ./.github/actions/sqlite
with:
version: 3.51.1
target: windows

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

Expand All @@ -95,13 +111,23 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Kotlin/Native's compiler and the dependencies it downloads, which only change with the Kotlin version: keyed by
# it, rather than by the build scripts, whose every change stored another copy of hundreds of megabytes. Without
# restore-keys, so that a new version doesn't keep the files of the one before
- name: Read the Kotlin version
id: kotlin
shell: bash
run: |
# Without the CR of the lines that a checkout on Windows ends with CRLF
version=$(tr -d '\r' < gradle/libs.versions.toml | sed -n 's/^kotlin = "\(.*\)"$/\1/p')
test -n "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Cache Kotlin/Native
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-konan-
key: ${{ runner.os }}-konan-${{ steps.kotlin.outputs.version }}

- name: Build sqllin-driver
run: ./gradlew :sqllin-driver:mingwX64MainKlibrary :sqllin-driver:jvmJar
Expand Down Expand Up @@ -146,6 +172,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Build SQLite
uses: ./.github/actions/sqlite
with:
version: 3.51.1
target: linux

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

Expand All @@ -158,13 +190,23 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Kotlin/Native's compiler and the dependencies it downloads, which only change with the Kotlin version: keyed by
# it, rather than by the build scripts, whose every change stored another copy of hundreds of megabytes. Without
# restore-keys, so that a new version doesn't keep the files of the one before
- name: Read the Kotlin version
id: kotlin
shell: bash
run: |
# Without the CR of the lines that a checkout on Windows ends with CRLF
version=$(tr -d '\r' < gradle/libs.versions.toml | sed -n 's/^kotlin = "\(.*\)"$/\1/p')
test -n "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Cache Kotlin/Native
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-konan-
key: ${{ runner.os }}-konan-${{ steps.kotlin.outputs.version }}

- name: Build sqllin-driver
run: ./gradlew :sqllin-driver:linuxX64MainKlibrary :sqllin-driver:jvmJar
Expand Down Expand Up @@ -204,6 +246,83 @@ jobs:
path: sqllin-dsl-test/build/reports
if: failure()

# The native tests on Linux again, linking the SQLite versions of the Android API levels that no other job runs:
# Robolectric's SQLite is 3.32.2 at its lowest. They tell what those versions of SQLite take, not what Android's
# build of them or its framework does.
test-on-older-sqlite:
name: test-on-sqlite-${{ matrix.sqlite }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
# Android API 24 and 25, 26, 28 and 29, and 30
sqlite: [ '3.9.2', '3.18.2', '3.22.0', '3.28.0' ]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build SQLite
uses: ./.github/actions/sqlite
with:
version: ${{ matrix.sqlite }}
target: linux

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Kotlin/Native's compiler and the dependencies it downloads, which only change with the Kotlin version: keyed by
# it, rather than by the build scripts, whose every change stored another copy of hundreds of megabytes. Without
# restore-keys, so that a new version doesn't keep the files of the one before
- name: Read the Kotlin version
id: kotlin
shell: bash
run: |
# Without the CR of the lines that a checkout on Windows ends with CRLF
version=$(tr -d '\r' < gradle/libs.versions.toml | sed -n 's/^kotlin = "\(.*\)"$/\1/p')
test -n "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Cache Kotlin/Native
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ steps.kotlin.outputs.version }}

- name: Run sqllin-driver Linux X64 Tests on SQLite ${{ matrix.sqlite }}
run: ./gradlew :sqllin-driver:cleanLinuxX64Test :sqllin-driver:linuxX64Test --stacktrace

- name: Run sqllin-dsl Linux X64 Tests on SQLite ${{ matrix.sqlite }}
run: ./gradlew :sqllin-dsl-test:cleanLinuxX64Test :sqllin-dsl-test:linuxX64Test --stacktrace

# The library holds its version as a string, and no test has that string
- name: Check that the tests linked SQLite ${{ matrix.sqlite }}
run: strings -a sqllin-dsl-test/build/bin/linuxX64/debugTest/test.kexe | grep -Fx '${{ matrix.sqlite }}'

- name: Upload sqllin-driver Reports
uses: actions/upload-artifact@v4
with:
name: Test-Reports-SQLite-${{ matrix.sqlite }}-driver
path: sqllin-driver/build/reports
if: failure()

- name: Upload sqllin-dsl Reports
uses: actions/upload-artifact@v4
with:
name: Test-Reports-SQLite-${{ matrix.sqlite }}-dsl
path: sqllin-dsl-test/build/reports
if: failure()

build-android-and-test:
runs-on: ubuntu-latest
timeout-minutes: 60
Expand Down
123 changes: 123 additions & 0 deletions .github/workflows/emulator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Emulator Tests

# The Android tests of sqllin-driver and sqllin-dsl on emulators, which run Android's own build of SQLite under the real
# framework: what neither the native tests on older SQLite versions nor the tests on Robolectric run. They are slow, so
# they only run by hand: from the Actions tab, once this file is on the default branch, or by adding the label
# emulator-test to a pull request, which works before.
#
# The levels each run one path of the Android driver and one version of Android's SQLite:
# - 24: the lowest SQLlin supports, SQLite 3.9, opened without OpenParams
# - 30: OpenParams, and a single connection, SQLite 3.28
# - 34: several connections that read, with the PRAGMAs set on each, SQLite 3.39 or 3.42
# - 37: the latest, SQLite 3.50
#
# There is no cache of the AVDs, as the workflow before Robolectric had: with KVM, an emulator boots in about 30
# seconds, which a snapshot would cut by 20 or so, while each level's would take hundreds of megabytes of the
# repository's cache, which the other workflows use. Most of a run is the build of the test APKs, which the Gradle cache
# shortens instead.

on:
workflow_dispatch:
inputs:
api-levels:
description: 'API levels to run on, separated by commas'
required: true
default: '24,30,34,37'
pull_request:
types: [ labeled ]

permissions:
contents: read

concurrency:
group: emulator-${{ github.ref }}
cancel-in-progress: true

jobs:

levels:
if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'emulator-test'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.levels.outputs.matrix }}
first: ${{ steps.levels.outputs.first }}

steps:
# The packages of API 37 are named android-37.0
- name: List the API levels
id: levels
env:
API_LEVELS: ${{ inputs.api-levels || '24,30,34,37' }}
run: |
matrix=$(echo "$API_LEVELS" | tr -d ' ' | tr ',' '\n' | jq -R -s -c '
split("\n") | map(select(length > 0)) | map(if . == "37" then "37.0" else . end) | {"api-level": .}')
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
echo "first=$(echo "$matrix" | jq -r '."api-level"[0]')" >> "$GITHUB_OUTPUT"
echo "Levels: $matrix"

test-on-emulator:
needs: levels
name: test-on-api-${{ matrix.api-level }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.levels.outputs.matrix) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21

# The cache is read-only on a pull request by default, so that the build of the APKs never reused its outputs.
# Only the job of the first level writes it, so that it is stored once, not once for each level.
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: ${{ matrix.api-level != needs.levels.outputs.first }}

# Before the emulator starts, so that it only runs the tests
- name: Build the test APKs
run: ./gradlew :sqllin-driver:assembleAndroidDeviceTest :sqllin-dsl-test:assembleAndroidDeviceTest

# One Gradle run for both modules, with --continue, so that a failure of one doesn't hide the other's, nor fail
# unnoticed. The first lines show the level and the SQLite of the system image.
- name: Run the tests on API ${{ matrix.api-level }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: default
arch: x86_64
# -no-snapshot-save: the emulator saves a snapshot as it stops otherwise, which nothing reads, as each run
# creates the AVD from scratch
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb shell getprop ro.build.version.sdk
adb shell "sqlite3 :memory: 'SELECT sqlite_version()'" || true
./gradlew :sqllin-driver:connectedAndroidDeviceTest :sqllin-dsl-test:connectedAndroidDeviceTest --continue --stacktrace

- name: Upload the reports
uses: actions/upload-artifact@v4
with:
name: Emulator-Reports-API-${{ matrix.api-level }}
path: |
sqllin-driver/build/reports
sqllin-driver/build/outputs/androidTest-results
sqllin-dsl-test/build/reports
sqllin-dsl-test/build/outputs/androidTest-results
if: always()
16 changes: 13 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Kotlin/Native's compiler and the dependencies it downloads, which only change with the Kotlin version: keyed by
# it, rather than by the build scripts, whose every change stored another copy of hundreds of megabytes. Without
# restore-keys, so that a new version doesn't keep the files of the one before
- name: Read the Kotlin version
id: kotlin
shell: bash
run: |
# Without the CR of the lines that a checkout on Windows ends with CRLF
version=$(tr -d '\r' < gradle/libs.versions.toml | sed -n 's/^kotlin = "\(.*\)"$/\1/p')
test -n "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Cache Kotlin/Native
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-konan-
key: ${{ runner.os }}-konan-${{ steps.kotlin.outputs.version }}

- name: Build sqllin-driver
run: ./gradlew :sqllin-driver:assemble
Expand Down
Loading
Loading