ci: prime sqlite cache before tests
This commit is contained in:
Vendored
+49
-39
@@ -97,6 +97,55 @@ PY
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
"$FLUTTER_ROOT/bin/flutter" config --no-analytics
|
"$FLUTTER_ROOT/bin/flutter" config --no-analytics
|
||||||
"$FLUTTER_ROOT/bin/flutter" pub get
|
"$FLUTTER_ROOT/bin/flutter" pub get
|
||||||
|
'''
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
|
# sqlite3 native hooks use a workspace-local cache, which cleanWs
|
||||||
|
# removes. Prime it from a verified node-local cache so a transient
|
||||||
|
# GitHub connection failure cannot block tests or the Gradle build.
|
||||||
|
sqlite_package_dir=$(python3 - <<'PY'
|
||||||
|
import json, pathlib, urllib.parse
|
||||||
|
config = json.loads(pathlib.Path('.dart_tool/package_config.json').read_text(encoding='utf-8'))
|
||||||
|
package = next(item for item in config['packages'] if item['name'] == 'sqlite3')
|
||||||
|
uri = urllib.parse.urlparse(package['rootUri'])
|
||||||
|
if uri.scheme != 'file':
|
||||||
|
raise SystemExit(f"unexpected sqlite3 package URI: {package['rootUri']}")
|
||||||
|
print(pathlib.Path(urllib.parse.unquote(uri.path)).resolve())
|
||||||
|
PY
|
||||||
|
)
|
||||||
|
sqlite_release=$(basename "$sqlite_package_dir")
|
||||||
|
|
||||||
|
prime_sqlcipher() {
|
||||||
|
sqlite_asset="$1"
|
||||||
|
sqlite_hash=$(sed -n "s/.*'$sqlite_asset': '\\([0-9a-f]\\{64\\}\\)'.*/\\1/p" \
|
||||||
|
"$sqlite_package_dir/lib/src/hook/asset_hashes.dart")
|
||||||
|
test "${#sqlite_hash}" -eq 64
|
||||||
|
|
||||||
|
sqlite_cache_dir="/home/nanxunai/.cache/jizhang/sqlite3/$sqlite_hash"
|
||||||
|
sqlite_cache_file="$sqlite_cache_dir/libsqlcipher.so"
|
||||||
|
sqlite_cache_tmp="$sqlite_cache_file.tmp"
|
||||||
|
mkdir -p "$sqlite_cache_dir"
|
||||||
|
if ! printf '%s %s\n' "$sqlite_hash" "$sqlite_cache_file" | sha256sum -c -; then
|
||||||
|
rm -f "$sqlite_cache_tmp"
|
||||||
|
curl --fail --location --retry 8 --retry-all-errors --retry-delay 3 \
|
||||||
|
--connect-timeout 20 --max-time 600 \
|
||||||
|
--output "$sqlite_cache_tmp" \
|
||||||
|
"https://github.com/simolus3/sqlite3.dart/releases/download/$sqlite_release/$sqlite_asset"
|
||||||
|
printf '%s %s\n' "$sqlite_hash" "$sqlite_cache_tmp" | sha256sum -c -
|
||||||
|
mv -f "$sqlite_cache_tmp" "$sqlite_cache_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sqlite_hash_prefix=$(printf '%.8s' "$sqlite_hash")
|
||||||
|
sqlite_hook_dir=".dart_tool/hooks_runner/shared/sqlite3/build/download-$sqlite_hash_prefix"
|
||||||
|
mkdir -p "$sqlite_hook_dir"
|
||||||
|
cp "$sqlite_cache_file" "$sqlite_hook_dir/libsqlcipher.so"
|
||||||
|
}
|
||||||
|
|
||||||
|
prime_sqlcipher libsqlcipher.x64.linux.so
|
||||||
|
prime_sqlcipher libsqlcipher.arm64.android.so
|
||||||
|
'''
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
# Keep warnings/errors fatal while allowing the repository's existing
|
# Keep warnings/errors fatal while allowing the repository's existing
|
||||||
# informational style lints to be cleaned up independently.
|
# informational style lints to be cleaned up independently.
|
||||||
"$FLUTTER_ROOT/bin/flutter" analyze --no-pub --no-fatal-infos
|
"$FLUTTER_ROOT/bin/flutter" analyze --no-pub --no-fatal-infos
|
||||||
@@ -111,45 +160,6 @@ PY
|
|||||||
stage('Build arm64 Internal Release') {
|
stage('Build arm64 Internal Release') {
|
||||||
steps {
|
steps {
|
||||||
dir('frontend') {
|
dir('frontend') {
|
||||||
sh '''
|
|
||||||
set -euo pipefail
|
|
||||||
# sqlite3 native hooks use a workspace-local cache, which cleanWs
|
|
||||||
# removes. Prime it from a verified node-local cache so a transient
|
|
||||||
# GitHub connection failure cannot waste an entire Gradle build.
|
|
||||||
sqlite_package_dir=$(python3 - <<'PY'
|
|
||||||
import json, pathlib, urllib.parse
|
|
||||||
config = json.loads(pathlib.Path('.dart_tool/package_config.json').read_text(encoding='utf-8'))
|
|
||||||
package = next(item for item in config['packages'] if item['name'] == 'sqlite3')
|
|
||||||
uri = urllib.parse.urlparse(package['rootUri'])
|
|
||||||
if uri.scheme != 'file':
|
|
||||||
raise SystemExit(f"unexpected sqlite3 package URI: {package['rootUri']}")
|
|
||||||
print(pathlib.Path(urllib.parse.unquote(uri.path)).resolve())
|
|
||||||
PY
|
|
||||||
)
|
|
||||||
sqlite_asset='libsqlcipher.arm64.android.so'
|
|
||||||
sqlite_hash=$(sed -n "s/.*'$sqlite_asset': '\\([0-9a-f]\\{64\\}\\)'.*/\\1/p" \
|
|
||||||
"$sqlite_package_dir/lib/src/hook/asset_hashes.dart")
|
|
||||||
test "${#sqlite_hash}" -eq 64
|
|
||||||
|
|
||||||
sqlite_cache_dir="/home/nanxunai/.cache/jizhang/sqlite3/$sqlite_hash"
|
|
||||||
sqlite_cache_file="$sqlite_cache_dir/libsqlcipher.so"
|
|
||||||
sqlite_cache_tmp="$sqlite_cache_file.tmp"
|
|
||||||
mkdir -p "$sqlite_cache_dir"
|
|
||||||
if ! printf '%s %s\n' "$sqlite_hash" "$sqlite_cache_file" | sha256sum -c -; then
|
|
||||||
rm -f "$sqlite_cache_tmp"
|
|
||||||
sqlite_release=$(basename "$sqlite_package_dir")
|
|
||||||
curl --fail --location --retry 8 --retry-all-errors --retry-delay 3 \
|
|
||||||
--connect-timeout 20 --max-time 600 \
|
|
||||||
--output "$sqlite_cache_tmp" \
|
|
||||||
"https://github.com/simolus3/sqlite3.dart/releases/download/$sqlite_release/$sqlite_asset"
|
|
||||||
printf '%s %s\n' "$sqlite_hash" "$sqlite_cache_tmp" | sha256sum -c -
|
|
||||||
mv -f "$sqlite_cache_tmp" "$sqlite_cache_file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sqlite_hook_dir=".dart_tool/hooks_runner/shared/sqlite3/build/download-${sqlite_hash:0:8}"
|
|
||||||
mkdir -p "$sqlite_hook_dir"
|
|
||||||
cp "$sqlite_cache_file" "$sqlite_hook_dir/libsqlcipher.so"
|
|
||||||
'''
|
|
||||||
retry(3) {
|
retry(3) {
|
||||||
sh '''
|
sh '''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|||||||
Reference in New Issue
Block a user