Skip to content

Fix new actions

Fix new actions #91

Workflow file for this run

name: 'PR checks'
on:
pull_request:
types:
- synchronize
- labeled
- opened
- reopened
jobs:
update-goldens:
runs-on: ubuntu-latest
strategy:
matrix:
channel:
- beta
- stable
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# ensures there are no unexpected directories needed
sparse-checkout: |
app
health_data_store
- name: Cache generated health data store
id: cache-generated
uses: actions/cache@v4
with:
path: health_data_store/lib
key: builder-${{ matrix.channel }}-${{ hashFiles('health_data_store/pubspec.yaml', 'health_data_store/lib/*', 'health_data_store/lib/**/*dart') }}
- name: Setup dart
if: steps.cache-generated.outputs.cache-hit != 'true'
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.channel }}
- name: Generate code
if: steps.cache-generated.outputs.cache-hit != 'true'
run: dart run build_runner build
working-directory: health_data_store
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ matrix.channel }}
cache: true
- name: Disable analytics
run:
flutter config --no-analytics --suppress-analytics
- name: Update app dependencies
run: flutter pub get
working-directory: app
# TODO: cache using non-generated dart files in the test dir as key
- name: Generate app mock code
run: flutter pub run build_runner build
working-directory: app
- name: Update goldens
id: gold-upd
run: flutter test --update-goldens --fail-fast --name="\[gold\].*" --dart-define="channel=${{ matrix.channel }}"
working-directory: app
- name: Push golden changes
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#example-of-failure-with-conditions
if: ${{ steps.gold-upd.conclusion == 'success' }}
run: |
if [[ $(git status -s) ]]; then
git config user.name "GitHub Action (update goldens)"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add app/test/**/*.png
git commit -m "Update goldens"
git push
else
echo "no changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}%
test:
if: contains(github.event.pull_request.labels.*.name, 'auto-test')
runs-on: ubuntu-latest
needs: update-goldens # this is guaranteed to fail if goldens need to be updated
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# ensures there are no unexpected directories needed
sparse-checkout: |
app
health_data_store
- name: Cache generated health data store
id: cache-generated
uses: actions/cache@v4
with:
path: health_data_store/lib
key: builder-${{ matrix.channel }}-${{ hashFiles('health_data_store/pubspec.yaml', 'health_data_store/lib/*', 'health_data_store/lib/**/*dart') }}
- name: Setup dart
if: steps.cache-generated.outputs.cache-hit != 'true'
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.channel }}
- name: Generate code
if: steps.cache-generated.outputs.cache-hit != 'true'
run: dart run build_runner build
working-directory: health_data_store
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ matrix.channel }}
cache: true
- name: Disable analytics
run:
flutter config --no-analytics --suppress-analytics
- name: Update app dependencies
run: flutter pub get
working-directory: app
# TODO: cache using non-generated dart files in the test dir as key
- name: Generate app mock code
run: flutter pub run build_runner build
working-directory: app
- name: Run tests
run: flutter test --coverage --dart-define="channel=${{ matrix.channel }}"
working-directory: app
build:
if: contains(github.event.pull_request.labels.*.name, 'auto-build')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# ensures there are no unexpected directories needed
sparse-checkout: |
app
health_data_store
- name: Cache generated health data store
id: cache-generated
uses: actions/cache@v4
with:
path: health_data_store/lib
key: builder-${{ matrix.channel }}-${{ hashFiles('health_data_store/pubspec.yaml', 'health_data_store/lib/*', 'health_data_store/lib/**/*dart') }}
- name: Setup dart
if: steps.cache-generated.outputs.cache-hit != 'true'
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.channel }}
- name: Generate code
if: steps.cache-generated.outputs.cache-hit != 'true'
run: dart run build_runner build
working-directory: health_data_store
- name: Set Up Java
uses: actions/setup-java@v3.12.0
with:
distribution: 'oracle'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ matrix.channel }}
cache: true
- name: Disable analytics
run: flutter config --no-analytics --suppress-analytics
- name: Update app dependencies
run: flutter pub get
working-directory: app
- name: Build
run: flutter build apk --debug --flavor=github
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-results
path: app/build/app/outputs/flutter-apk