blob: 7d5dfc496b558bf1182c58bd0e1aec53c8cd0d67 [file] [edit]
# A CI configuration to check PR health.
name: Health:Base
# The workflow doing the checks for `health.yaml`. Not meant to be used externally.
on:
workflow_call:
inputs:
sdk:
default: "stable"
required: false
type: string
channel:
default: "stable"
required: false
type: string
check:
type: string
required: true
fail_on:
default: "changelog,do-not-submit"
type: string
required: false
warn_on:
default: "license,coverage,breaking,leaking,unused-dependencies"
type: string
required: false
local_debug:
default: false
type: boolean
required: false
upload_coverage:
default: true
type: boolean
required: false
coverage_web:
default: false
type: boolean
required: false
flutter_packages:
default: '""'
required: false
type: string
ignore_license:
default: '""'
required: false
type: string
ignore_changelog:
default: '""'
required: false
type: string
ignore_coverage:
default: '""'
required: false
type: string
ignore_breaking:
default: '""'
required: false
type: string
ignore_leaking:
default: '""'
required: false
type: string
ignore_donotsubmit:
default: '""'
required: false
type: string
ignore_unuseddependencies:
default: '""'
required: false
type: string
ignore_packages:
default: '""'
required: false
type: string
checkout_submodules:
default: false
required: false
type: boolean
experiments:
default: '""'
type: string
required: false
health_yaml_name:
default: '""'
type: string
required: false
license:
default: '""'
required: false
type: string
license_test_string:
default: '""'
required: false
type: string
jobs:
health:
name: run ${{ inputs.check }} health check
# These permissions are required for us to create comments on PRs.
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
with:
path: current_repo/
submodules: ${{ inputs.checkout_submodules }}
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
with:
ref: ${{ github.event.pull_request.base.ref }}
path: base_repo/
submodules: ${{ inputs.checkout_submodules }}
if: ${{ inputs.check == 'coverage' || inputs.check == 'breaking' }}
- run: mkdir -p current_repo/output/
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
sdk: ${{ inputs.sdk }}
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
if: ${{ inputs.flutter_packages != '' }}
with:
channel: ${{ inputs.channel }}
- name: Check Dart installs whereis
run: whereis dart
- name: Check Dart installs which
run: which dart
- name: Install coverage
run: dart pub global activate coverage
if: ${{ inputs.check == 'coverage' }}
- name: Install firehose
run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/
if: ${{ !inputs.local_debug }}
- name: Install local firehose
run: dart pub global activate --source path current_repo/pkgs/firehose/
if: ${{ inputs.local_debug }}
- name: Fetch labels
id: fetch-labels
run: |
labels=$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels | map(.name) | join(",")')
echo "Found labels: $labels"
echo "labels=$labels" >> "$GITHUB_OUTPUT"
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
- name: Check PR health
id: healthstep
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.number }}
PR_LABELS: ${{ steps.fetch-labels.outputs.labels }}
INPUT_LICENSE: ${{ inputs.license }}
INPUT_LICENSE_TEST_STRING: ${{ inputs.license_test_string }}
run: |
cd current_repo/
dart pub global run firehose:health \
--check ${{ inputs.check }} \
${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} \
--fail_on ${{ inputs.fail_on }} \
--warn_on ${{ inputs.warn_on }} \
--flutter_packages ${{ inputs.flutter_packages }} \
--ignore_packages ${{ inputs.ignore_packages }} \
--ignore_license ${{ inputs.ignore_license }} \
--ignore_changelog ${{ inputs.ignore_changelog }} \
--ignore_coverage ${{ inputs.ignore_coverage }} \
--ignore_breaking ${{ inputs.ignore_breaking }} \
--ignore_leaking ${{ inputs.ignore_leaking }} \
--ignore_donotsubmit ${{ inputs.ignore_donotsubmit }} \
--ignore_unuseddependencies ${{ inputs.ignore_unuseddependencies }} \
--experiments ${{ inputs.experiments }} \
--health_yaml_name ${{ inputs.health_yaml_name }} \
--no-local \
--license "$INPUT_LICENSE" \
--license_test_string "$INPUT_LICENSE_TEST_STRING"
- run: test -f current_repo/output/comment-${{ inputs.check }}.md || echo $'The ${{ inputs.check }} workflow has encountered an exception and did not complete.' >> current_repo/output/comment-${{ inputs.check }}.md
if: ${{ '$action_state' == 1 }}
- name: Upload coverage to Coveralls
if: ${{ inputs.upload_coverage && inputs.check == 'coverage' }}
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e
with:
format: lcov
base-path: current_repo/
compare-sha: ${{ github.event.pull_request.base.ref }}
allow-empty: true
- name: Upload markdown
if: success() || failure()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
with:
name: comment-${{ inputs.check }}
path: current_repo/output/comment-${{ inputs.check }}.md