Commit 469c93a
Changed files (3)
.github
workflows
.github/workflows/app-CI.yml
@@ -61,27 +61,3 @@ jobs:
- name: Run tests
run: flutter test --coverage --dart-define="channel=${{ matrix.channel }}"
working-directory: app
- - name: Update goldens
- id: gold-upd
- if: failure()
- run: flutter test --update-goldens --fail-fast --name="\[gold\].*" --dart-define="channel=${{ matrix.channel }}"
- working-directory: app
- - name: PR 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: ${{ failure() && steps.gold-upd.conclusion == 'success' }}
- run: |
- git config user.name "GitHub Action (update goldens)"
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
-
- git checkout -B action-update-goldens
- export STATUS=$(git status)
- git commit -am "Update goldens"
- git push --set-upstream origin action-update-goldens
-
- gh pr create \
- --base main \
- --head action-update-goldens \
- --title "Update goldens" \
- --body "$STATUS"
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
.github/workflows/labeler.yml
@@ -0,0 +1,33 @@
+name: Label PRs & Issues
+description: Allows external contributors to add labels to add labels to issues and PRs.
+# Note for maintainers: Don't add labels that can be abused
+
+on:
+ issue_comment:
+ types: [ created ]
+
+jobs:
+ build:
+ if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/build') }}
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ steps:
+ - run: gh issue edit "$NUMBER" --add-label "$LABELS"
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPO: ${{ github.repository }}
+ NUMBER: ${{ github.event.issue.number }}
+ LABELS: auto-build
+ test:
+ if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test') }}
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ steps:
+ - run: gh issue edit "$NUMBER" --add-label "$LABELS"
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPO: ${{ github.repository }}
+ NUMBER: ${{ github.event.issue.number }}
+ LABELS: auto-test
.github/workflows/pr.yml
@@ -1,61 +1,163 @@
-name: PRs
-
+name: 'PR checks'
on:
- issue_comment:
- types: [ created ]
-
-env:
- FLUTTER_CHANNEL: 'beta'
- DART_SDK: 'beta'
+ 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
+ # Golden tests don't need mocks if they ever do this would be a good oportunity to
+ # introduce test mock testign
+ - name: Update goldens
+ id: gold-upd
+ run: flutter test --update-goldens --fail-fast --name="\[gold\].*" --dart-define="channel=${{ matrix.channel }}"
+ working-directory: app
+ - name: PR 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: |
+ 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
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}%
+ test:
+ if: contains(github.event.pull_request.labels.*.name, 'auto-test')
+ 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: 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: Generate app mock code # no efficient caching possible
+ 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: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/build') }}
+ if: contains(github.event.pull_request.labels.*.name, 'auto-build')
runs-on: ubuntu-latest
-
steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- sparse-checkout: |
- app
- health_data_store
- - name: Checkout PR
- run: gh pr checkout ${{ github.event.issue.number }}
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Cache generated health data store
- id: cache-generated
- uses: actions/cache@v4
- with:
- path: health_data_store/lib
- key: builder-${{ 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: ${{ env.DART_SDK }}
- - 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: ${{ env.FLUTTER_CHANNEL }}
- cache: true
- - name: Disable analytics
- run: flutter config --no-analytics --suppress-analytics
- - name: Setup java
- uses: actions/setup-java@v2
- with:
- java-version: "17"
- distribution: "temurin"
- cache: 'gradle'
- - name: Build apk
- run: flutter build apk --flavor github --debug
- working-directory: app
- - uses: actions/upload-artifact@v4
- with:
- name: build-results
- path: app/build/app/outputs/flutter-apk
+ - 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: Upload artifacts
+ uses: actions/upload-artifact@v4
+ with:
+ name: build-results
+ path: app/build/app/outputs/flutter-apk
+ - name: Build
+ run: flutter build apk --debug --flavor=github