-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add workflow to add labels for non-admins * Auto-update goldens on PRs that change them * Implement PR builds * Upload build artifacts
- Loading branch information
Showing
3 changed files
with
190 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |