Github actions workflow maintenance

This commit is contained in:
Simon Binder 2023-03-11 23:35:52 +01:00
parent c98dcc00e0
commit a6ef3958a5
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
3 changed files with 138 additions and 170 deletions

40
.github/actions/prepare/action.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: Prepare
description: Prepare CI environment to test a component of drift
inputs:
dart_version:
description: Dart version, to restore the dependency cache
required: true
runs:
using: "composite"
steps:
- uses: dart-lang/setup-dart@v1
# Setup sqlite3
- name: Download sqlite3
uses: actions/download-artifact@v3
with:
name: sqlite3
path: /tmp/sqlite/out/
- name: Use downloaded sqlite3
shell: bash
run: |
chmod a+x /tmp/sqlite/out/sqlite3
echo "/tmp/sqlite/out" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV
- name: Check sqlite3 version
run: sqlite3 --version
shell: bash
# Setup Dart packages
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ inputs.dart_version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-${{ inputs.dart_version }}-
dart-dependencies-
- name: Setup melos
run: dart pub global activate melos && dart pub get
shell: bash

View File

@ -6,72 +6,12 @@ env:
PUB_ENVIRONMENT: bot.github
jobs:
# Compile the latest sqlite3 library, which will be used to run tests in drift
# and sqlparser
compile_sqlite3:
strategy:
matrix:
# We only really need this for Ubuntu, but we recommend users run the same
# steps so we better make sure they work on all platforms.
os: [ubuntu-latest, macos-latest, windows-latest]
name: "Compile sqlite3 for tests"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v3
id: cache_build
with:
path: drift/.dart_tool/sqlite3/
key: ${{ runner.os }}-${{ hashFiles('drift/tool/') }}
- name: Download Dart
if: steps.cache_build.outputs.cache-hit != 'true'
uses: dart-lang/setup-dart@v1
- name: Compile sqlite3
if: steps.cache_build.outputs.cache-hit != 'true'
run: |
dart pub global activate melos
dart pub get
melos bootstrap --scope drift
dart run drift/tool/download_sqlite3.dart
- name: Upload built sqlite3 binaries
uses: actions/upload-artifact@v2
# we only need these artifacts on Linux since we run unit tests on Linux only
if: runner.os == 'Linux'
with:
name: sqlite3
path: drift/.dart_tool/sqlite3/
if-no-files-found: error
retention-days: 1
dart_dependencies:
name: Get and cache Dart dependencies
runs-on: ubuntu-latest
outputs:
dart_version: ${{ steps.dart_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Get Dart version
id: dart_version
run: |
version=`cat $DART_HOME/version`
echo "Running on Dart $version"
echo "::set-output name=version::$version"
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ steps.dart_version.outputs.version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-${{ steps.dart_version.outputs.version }}-
dart-dependencies-
- name: Setup melos
run: dart pub global activate melos && dart pub get
- name: Get Dart dependencies
run: melos bootstrap --no-flutter
setup:
uses: ./.github/workflows/setup.yml
docs:
name: "Documentation"
needs: [compile_sqlite3, dart_dependencies]
needs: [setup]
runs-on: ubuntu-latest
defaults:
run:
@ -79,27 +19,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Download sqlite3
uses: actions/download-artifact@v2
- uses: ./.github/actions/prepare
with:
name: sqlite3
path: /tmp/sqlite/out/
- name: Use downloaded sqlite3
run: |
chmod a+x /tmp/sqlite/out/sqlite3
echo "/tmp/sqlite/out" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV
- name: Check sqlite3 version
run: sqlite3 --version
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-
dart-dependencies-
- run: dart pub global activate melos && dart pub get && melos bootstrap --scope drift_docs,drift
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope drift_docs,drift
working-directory: .
- name: Run build
env:
@ -114,7 +37,7 @@ jobs:
- name: Deploy to netlify (Branch)
if: ${{ github.event_name == 'push' }}
uses: nwtgck/actions-netlify@v1.2
uses: nwtgck/actions-netlify@v2
with:
production-branch: latest-release
publish-dir: docs/deploy
@ -127,7 +50,7 @@ jobs:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Deploy to netlify (Pull Request)
if: ${{ github.event_name == 'pull_request' }}
uses: nwtgck/actions-netlify@v1.2
uses: nwtgck/actions-netlify@v2
with:
production-branch: latest-release
publish-dir: docs/deploy
@ -142,7 +65,7 @@ jobs:
drift:
name: "drift package"
needs: [compile_sqlite3, dart_dependencies]
needs: [setup]
runs-on: ubuntu-latest
defaults:
run:
@ -150,27 +73,10 @@ jobs:
steps:
# setup
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Download sqlite3
uses: actions/download-artifact@v2
- uses: ./.github/actions/prepare
with:
name: sqlite3
path: drift/.dart_tool/sqlite3/
- name: Use downloaded sqlite3
run: |
chmod a+x .dart_tool/sqlite3//sqlite3
echo "/tmp/sqlite/out" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV
- name: Check sqlite3 version
run: sqlite3 --version
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-
dart-dependencies-
- run: dart pub global activate melos && dart pub get && melos bootstrap --scope drift
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope drift
working-directory: .
- name: Get dependencies for plugin
run: |
@ -197,7 +103,7 @@ jobs:
drift_dev:
runs-on: ubuntu-latest
needs: [dart_dependencies]
needs: [setup]
timeout-minutes: 10
defaults:
run:
@ -205,15 +111,10 @@ jobs:
steps:
# setup
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- uses: actions/cache@v3
- uses: ./.github/actions/prepare
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-
dart-dependencies-
- run: dart pub global activate melos && dart pub get && melos bootstrap --scope drift_dev
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope drift_dev
working-directory: .
# analysis
- run: dart format -o none --set-exit-if-changed .
@ -224,31 +125,16 @@ jobs:
sqlparser:
runs-on: ubuntu-latest
needs: [compile_sqlite3, dart_dependencies]
needs: [setup]
defaults:
run:
working-directory: sqlparser
steps:
# setup
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
- name: Download sqlite3
uses: actions/download-artifact@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare
with:
name: sqlite3
path: /tmp/sqlite/out/
- name: Use downloaded sqlite3
run: |
chmod a+x /tmp/sqlite/out/sqlite3
echo "/tmp/sqlite/out" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-
dart-dependencies-
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: dart pub upgrade
# analysis
- run: dart format -o none --set-exit-if-changed .
@ -266,7 +152,7 @@ jobs:
misc_integration_tests:
name: "Integration tests"
needs: [compile_sqlite3, dart_dependencies]
needs: [setup]
runs-on: ubuntu-latest
services:
postgres:
@ -282,51 +168,23 @@ jobs:
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Download sqlite3
uses: actions/download-artifact@v2
- uses: ./.github/actions/prepare
with:
name: sqlite3
path: /tmp/sqlite/out/
- name: Use downloaded sqlite3
run: |
chmod a+x /tmp/sqlite/out/sqlite3
echo "/tmp/sqlite/out" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-
- run: dart pub global activate melos && dart pub get && melos bootstrap --no-flutter
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --no-flutter
working-directory: .
- run: tool/misc_integration_test.sh
migration_integration_tests:
name: "Integration tests for migration tooling"
needs: [compile_sqlite3, dart_dependencies]
needs: [setup]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Download sqlite3
uses: actions/download-artifact@v2
- uses: ./.github/actions/prepare
with:
name: sqlite3
path: /tmp/sqlite/out/
- name: Use downloaded sqlite3
run: |
chmod a+x /tmp/sqlite/out/sqlite3
echo "/tmp/sqlite/out" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-
- run: dart pub global activate melos && dart pub get && melos bootstrap --scope migrations_example
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope migrations_example
working-directory: .
- name: Run build
working-directory: examples/migrations_example

70
.github/workflows/setup.yml vendored Normal file
View File

@ -0,0 +1,70 @@
on:
workflow_call:
outputs:
dart_version:
description: Version of the Dart SDK used during the setup run, useful for dependency restoring
value: ${{ jobs.dart_dependencies.outputs.dart_version }}
jobs:
# Compile the latest sqlite3 library, which will be used to run tests in drift
# and sqlparser
compile_sqlite3:
strategy:
matrix:
# We only really need this for Ubuntu, but we recommend users run the same
# steps so we better make sure they work on all platforms.
os: [ubuntu-latest, macos-latest, windows-latest]
name: "Compile sqlite3 for tests"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache_build
with:
path: drift/.dart_tool/sqlite3/
key: ${{ runner.os }}-${{ hashFiles('drift/tool/') }}
- name: Download Dart
if: steps.cache_build.outputs.cache-hit != 'true'
uses: dart-lang/setup-dart@v1
- name: Compile sqlite3
if: steps.cache_build.outputs.cache-hit != 'true'
run: |
dart pub global activate melos
dart pub get
melos bootstrap --scope drift
dart run drift/tool/download_sqlite3.dart
- name: Upload built sqlite3 binaries
uses: actions/upload-artifact@v3
# we only need these artifacts on Linux since we run unit tests on Linux only
if: runner.os == 'Linux'
with:
name: sqlite3
path: drift/.dart_tool/sqlite3/
if-no-files-found: error
retention-days: 1
dart_dependencies:
name: Get and cache Dart dependencies
runs-on: ubuntu-latest
outputs:
dart_version: ${{ steps.dart_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Get Dart version
id: dart_version
run: |
version=`cat $DART_HOME/version`
echo "Running on Dart $version"
echo "version=$version" >> $GITHUB_STATE
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ steps.dart_version.outputs.version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-${{ steps.dart_version.outputs.version }}-
dart-dependencies-
- name: Setup melos
run: dart pub global activate melos && dart pub get
- name: Get Dart dependencies
run: melos bootstrap --no-flutter