blob: 3059c5ba7b042f2373152470850da6b6b62db675 [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@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
path: current_repo/
submodules: ${{ inputs.checkout_submodules }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
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@65eb853c7ba17dde3be364c3d2858773e7144260
with:
sdk: ${{ inputs.sdk }}
- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-cache-
- uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2
if: ${{ inputs.flutter_packages != '' }}
with:
channel: ${{ inputs.channel }}
cache: true
- 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 (internal)
if: ${{ !inputs.local_debug && github.repository == 'dart-lang/ecosystem' }}
run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/ --git-ref ${{ github.head_ref || github.ref_name }}
- name: Install firehose (external)
if: ${{ !inputs.local_debug && github.repository != 'dart-lang/ecosystem' }}
run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/
- 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 }}
INPUTS_CHECK: ${{ inputs.check }}
INPUTS_FAIL_ON: ${{ inputs.fail_on }}
INPUTS_WARN_ON: ${{ inputs.warn_on }}
INPUTS_FLUTTER_PACKAGES: ${{ inputs.flutter_packages }}
INPUTS_IGNORE_PACKAGES: ${{ inputs.ignore_packages }}
INPUTS_IGNORE_LICENSE: ${{ inputs.ignore_license }}
INPUTS_IGNORE_CHANGELOG: ${{ inputs.ignore_changelog }}
INPUTS_IGNORE_COVERAGE: ${{ inputs.ignore_coverage }}
INPUTS_IGNORE_BREAKING: ${{ inputs.ignore_breaking }}
INPUTS_IGNORE_LEAKING: ${{ inputs.ignore_leaking }}
INPUTS_IGNORE_DONOTSUBMIT: ${{ inputs.ignore_donotsubmit }}
INPUTS_IGNORE_UNUSEDDEPENDENCIES: ${{ inputs.ignore_unuseddependencies }}
INPUTS_EXPERIMENTS: ${{ inputs.experiments }}
INPUTS_HEALTH_YAML_NAME: ${{ inputs.health_yaml_name }}
INPUTS_LICENSE: ${{ inputs.license }}
INPUTS_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 "${INPUTS_LICENSE}" \
--license_test_string "${INPUTS_LICENSE_TEST_STRING}"
- name: Ensure comment file exists
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 }}
env:
INPUTS_CHECK: ${{ inputs.check }}
- 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@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
with:
name: comment-${{ inputs.check }}
path: current_repo/output/comment-${{ inputs.check }}.md