Skip to content

Commit

Permalink
Merge branch 'main' into fp/collection-keypath-new
Browse files Browse the repository at this point in the history
  • Loading branch information
papafe authored Jun 12, 2024
2 parents a9b00db + 510a4fa commit 9f97c66
Show file tree
Hide file tree
Showing 23 changed files with 264 additions and 188 deletions.
87 changes: 87 additions & 0 deletions .github/actions/setup-runner/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Setup runner
description: Setup the runner with the necessary tools and dependencies.

inputs:
flutter-version:
description: Flutter version to use.
default: stable
cache-key:
description: Cache key to use for restoring and saving the cache.
default: ${{ hashFiles('**/pubspec.yaml') }}

runs:
using: "composite"
steps:
- name: Setup environment
# By forcing puro (and hence the pub-cache) onto the same drive as the checkout,
# we can avoid symlink issue between local and network drives on windows.
id: setup
shell: bash
run: |
export PURO_ROOT=$(dirname $GITHUB_WORKSPACE)/puro
mkdir -p $PURO_ROOT
echo $PURO_ROOT/bin >> $GITHUB_PATH
echo $PURO_ROOT/shared/pub_cache/bin/ >> $GITHUB_PATH
echo $PURO_ROOT/envs/default/flutter/bin/ >> $GITHUB_PATH
echo PURO_ROOT=$PURO_ROOT >> $GITHUB_ENV
echo PUB_CACHE=$PURO_ROOT/shared/pub_cache >> $GITHUB_ENV
echo MELOS_SDK_PATH=$PURO_ROOT/envs/default/flutter/ >> $GITHUB_ENV
echo "week=$(date +'%Y-%U')" >> $GITHUB_OUTPUT
- name: Restore cache
# TODO: Avoid skipping restore on Windows
# (see https://github.com/pingbird/puro/issues/87)
if: runner.os != 'Windows'
id: restore
uses: actions/cache/restore@v4
with:
path: ${{ env.PURO_ROOT }}
key: setup-runner-${{ runner.os }}-${{ runner.arch }}-${{ steps.setup.outputs.week }}-${{ inputs.cache-key }}
restore-keys: setup-runner-${{ runner.os }}-${{ runner.arch }}-

- name: Install puro (posix)
# See https://puro.dev/
# Skip on any cache hit (partial or full)
if: runner.os != 'Windows' && steps.restore.outputs.cache-matched-key == ''
shell: bash
run: curl -sS -o- https://puro.dev/install.sh | PURO_VERSION="1.4.6" bash

- name: Install puro (windows)
# We always install on windows, as we currently don't restore a cache (see TODO above)
if: runner.os == 'Windows' && steps.restore.outputs.cache-matched-key == ''
shell: pwsh
run: >-
Invoke-WebRequest
-Uri "https://puro.dev/builds/1.4.6/windows-x64/puro.exe"
-OutFile "$Env:PURO_ROOT";
&"$Env:PURO_ROOT\puro.exe" install-puro --promote
- name: Upgrade puro and flutter
shell: bash
run: |
puro upgrade-puro
puro use --global ${{ inputs.flutter-version }}
puro upgrade ${{ inputs.flutter-version }}
puro gc
- name: Activate melos
if: steps.restore.outputs.cache-matched-key == ''
shell: bash
run: puro pub global run melos --version || puro pub global activate melos

- name: Melos bootstrap
shell: bash
run: puro pub global run melos bootstrap

- name: Save cache
# Saving on feature branches will only benefit reruns, so we don't bother.
# Feature branches inherit the cache from the main branch anyway.
# This saves on cache storage.
if: github.ref == 'refs/heads/main' && steps.restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.PURO_ROOT }}
key: ${{ steps.restore.outputs.cache-primary-key }}
54 changes: 10 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,33 +321,23 @@ jobs:
with:
submodules: "recursive"

- name: Setup runner
uses: ./.github/actions/setup-runner

- name: Bump ulimit
run: |
ulimit -n
ulimit -n 10240
- name: Enable ccache
run: echo "PATH=/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH

- name: Fetch artifacts
uses: actions/download-artifact@v4
with:
name: librealm-ios
path: packages/realm_dart/binary/ios

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap
- name: Install dependencies
run: dart pub get

- name: Launch Simulator
uses: futureware-tech/simulator-action@v3
with:
Expand Down Expand Up @@ -431,18 +421,8 @@ jobs:
name: librealm-android
path: packages/realm_dart/binary/android

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap
- name: Install dependencies
run: dart pub get
- name: Setup Runner
uses: ./.github/actions/setup-runner

# Hack to free up space on the runner to ensure we have enough diskspace to run the emulator
- name: Remove unnecessary files (dotnet, etc.)
Expand Down Expand Up @@ -526,15 +506,8 @@ jobs:
with:
submodules: "recursive"

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap
- name: Setup Runner
uses: ./.github/actions/setup-runner

- name: Delete generated files in realm_dart
run: |
Expand Down Expand Up @@ -629,15 +602,8 @@ jobs:
with:
submodules: "recursive"

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap
- name: Setup Runner
uses: ./.github/actions/setup-runner

- name: Compile to wasm
run: flutter build web --wasm -t integration_test/all_tests.dart
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/dart-desktop-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,8 @@ jobs:
name: librealm-${{ steps.runner_os_lowercase.outputs.os }}
path: packages/realm_dart/binary/${{ steps.runner_os_lowercase.outputs.os }}

- name: Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
sdk: stable

- name: Setup Melos
run: |
dart pub global activate melos
melos bootstrap --no-flutter
melos setup
- name: Setup Runner
uses: ./.github/actions/setup-runner

- name: Bump ulimit on macos
run: |
Expand All @@ -85,6 +77,7 @@ jobs:
if: inputs.runner == 'ubuntu-latest'
run: |
sudo apt-get install lcov
melos setup
melos coverage:convert
melos coverage:gather
melos coverage:groom
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/deploy-baas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,8 @@ jobs:
with:
submodules: false

- name: Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
sdk: stable
architecture: 'x64'

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap --no-flutter
- name: Install dependencies
run: dart pub get
- name: Setup Runner
uses: ./.github/actions/setup-runner

- name: Deploy cluster and apps
run: dart run realm_dart deploy-apps --baasaas-api-key ${{ secrets.BAASAAS_API_KEY }} --differentiator ${{ inputs.differentiator }}
15 changes: 2 additions & 13 deletions .github/workflows/flutter-desktop-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,8 @@ jobs:
name: librealm-${{ steps.runner_os_lowercase.outputs.os }}
path: packages/realm_dart/binary/${{ steps.runner_os_lowercase.outputs.os }}

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: ${{ inputs.arch }}

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap
- name: Install dependencies
run: dart pub get
- name: Setup Runner
uses: ./.github/actions/setup-runner

- name: Bump ulimit
run: |
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ jobs:
version: ${{ inputs.version }}
version-suffix: ''

- name : Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
sdk: stable
architecture: 'x64'

- name: Setup Melos
run: dart pub global activate melos
- name: Setup Runner
uses: ./.github/actions/setup-runner

- name: Update pubspec.yaml files
run: REALM_VERSION=${{ steps.update-changelog.outputs.new-version }} melos run update:version:realm
Expand All @@ -46,15 +40,15 @@ jobs:
replace: " s.version$1= '${{ steps.update-changelog.outputs.new-version }}'"
include: '**realm.podspec'

- name: Update libraryVersion in realm_core.dart
- name: Update libraryVersion in realm_library.dart
id: update-libraryVersion
uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0
with:
find: "const libraryVersion = '[^']*';"
replace: "const libraryVersion = '${{ steps.update-changelog.outputs.new-version }}';"
include: 'packages/realm_dart/lib/src/native/realm_core.dart'
include: 'packages/realm_dart/lib/src/handles/native/realm_library.dart'

- name: Make sure we updated libraryVersion in realm_core.dart
- name: Make sure we updated libraryVersion in realm_library.dart
run: |
if [ '${{ steps.update-libraryVersion.outputs.modifiedFiles }}' != '1' ]; then
echo 'Expected exactly one modified file, got ${{ steps.update-libraryVersion.outputs.modifiedFiles }}'
Expand Down
22 changes: 4 additions & 18 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,8 @@ jobs:
echo "version=$pkgVersion$pkgSuffix" >> $GITHUB_OUTPUT
shell: bash

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap
- name: Setup Runner
uses: ./.github/actions/setup-runner

- name: Download all artifacts
uses: dawidd6/action-download-artifact@71072fbb1229e1317f1a8de6b04206afb461bd67 # 3.1.2
Expand Down Expand Up @@ -161,15 +154,8 @@ jobs:
name: release-bundle
path: release

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap
- name: Setup Runner
uses: ./.github/actions/setup-runner

# realm_flutter has symlinks to native binaries which should not be packaged
- name: Cleanup symlinks
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/setup-runner.yml

This file was deleted.

15 changes: 2 additions & 13 deletions .github/workflows/terminate-baas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,8 @@ jobs:
with:
submodules: false

- name: Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
sdk: stable
architecture: 'x64'

- name: Setup Melos
run: |
dart pub global activate melos
dart pub global run melos bootstrap --no-flutter
- name: Install dependencies
run: dart pub get
- name: Setup Runner
uses: ./.github/actions/setup-runner

- name: Terminate baas
run: dart run realm_dart delete-apps --baasaas-api-key ${{ secrets.BAASAAS_API_KEY }} --differentiator ${{ inputs.differentiator }}
Loading

0 comments on commit 9f97c66

Please sign in to comment.