| # A CI configuration to check PR health. Check the docs at https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose#health. |
| |
| name: Health |
| |
| # Callers of this workflow should use it as follows: |
| # |
| # name: Health |
| # on: |
| # pull_request: |
| # branches: [ main ] |
| # types: [opened, synchronize, reopened, labeled, unlabeled] |
| # jobs: |
| # health: |
| # uses: dart-lang/ecosystem/.github/workflows/health.yaml@main |
| |
| |
| # Or with options: |
| # |
| # jobs: |
| # health: |
| # uses: dart-lang/ecosystem/.github/workflows/health.yaml@main |
| # with: |
| # sdk: beta |
| # checks: "changelog,license,coverage,breaking,do-not-submit,leaking,unused-dependencies" |
| # fail_on: "changelog,do-not-submit" |
| # warn_on: "license,coverage,breaking,leaking" |
| # coverage_web: false |
| # upload_coverage: false |
| # flutter_packages: "pkgs/my_flutter_package" |
| # ignore_license: "**.g.dart" |
| # ignore_changelog: "" |
| # ignore_coverage: "**.mock.dart,**.g.dart" |
| # ignore_breaking: "" |
| # ignore_leaking: "" |
| # ignore_donotsubmit: "" |
| # ignore_packages: "pkgs/helper_package" |
| # checkout_submodules: false |
| # experiments: "native-assets" |
| # license: "// Copyright %YEAR% ..." |
| # license_test_string: "// Copyright (c)" |
| |
| on: |
| workflow_call: |
| inputs: |
| # Callers may optionally specify the version of the SDK to use when running the |
| # health check. This can be useful if your package has a very recent minimum SDK |
| # constraint. This is done via the `sdk` input parameter. Note that this |
| # parameter is not required; it defaults to `stable` - using the most recent |
| # stable release of the Dart SDK. |
| sdk: |
| description: >- |
| The Dart SDK version, either a semver or one of `dev`, `stable` etc. |
| default: "stable" |
| required: false |
| type: string |
| channel: |
| description: >- |
| The channel, or a specific version from a channel, to install |
| ('2.19.0','stable', 'beta', 'dev'). Using one of the three channels |
| will give you the latest version published to that channel. |
| default: "stable" |
| required: false |
| type: string |
| checks: |
| description: What to check for in the PR health check - any subset of "changelog,license,coverage,breaking,do-not-submit,leaking,unused-dependencies" |
| default: "changelog,license,coverage,breaking,do-not-submit,leaking,unused-dependencies" |
| type: string |
| required: false |
| fail_on: |
| description: Which checks should lead to failure - any subset of "changelog,license,coverage,breaking,do-not-submit,leaking,unused-dependencies" |
| default: "changelog,do-not-submit" |
| type: string |
| required: false |
| warn_on: |
| description: Which checks should not fail, but only warn - any subset of "changelog,license,coverage,breaking,do-not-submit,leaking,unused-dependencies" |
| default: "license,coverage,breaking,leaking,unused-dependencies" |
| type: string |
| required: false |
| local_debug: |
| description: Whether to use a local copy of package:firehose - only for debug |
| default: false |
| type: boolean |
| required: false |
| upload_coverage: |
| description: Whether to upload the coverage to coveralls |
| default: true |
| type: boolean |
| required: false |
| coverage_web: |
| description: Whether to run `dart test -p chrome` for coverage |
| default: false |
| type: boolean |
| required: false |
| flutter_packages: |
| description: List of packages depending on Flutter. |
| default: "" |
| required: false |
| type: string |
| ignore_license: |
| description: A glob describing which files to ignore for the license check. |
| default: '' |
| required: false |
| type: string |
| ignore_changelog: |
| description: A glob describing which files to ignore for the changelog check. |
| default: '' |
| required: false |
| type: string |
| ignore_coverage: |
| description: A glob describing which files to ignore for the coverage check. |
| default: '' |
| required: false |
| type: string |
| ignore_breaking: |
| description: A glob describing which packages to ignore for the breaking changes check. |
| default: '' |
| required: false |
| type: string |
| ignore_leaking: |
| description: A glob describing which files to ignore for the leaking check. |
| default: '' |
| required: false |
| type: string |
| ignore_donotsubmit: |
| description: A glob describing which files to ignore for the do-not-submit check. |
| default: '' |
| required: false |
| type: string |
| ignore_unuseddependencies: |
| description: A glob describing which packages to ignore for the unused dependencies check. |
| default: '' |
| required: false |
| type: string |
| ignore_packages: |
| description: A glob describing which packages to ignore for all checks. |
| default: '' |
| required: false |
| type: string |
| checkout_submodules: |
| description: Whether to checkout submodules of git repositories. |
| default: false |
| required: false |
| type: boolean |
| experiments: |
| description: Which experiments should be enabled for Dart. |
| default: '' |
| type: string |
| required: false |
| health_yaml_name: |
| description: The name of the workflow file. |
| default: '' |
| type: string |
| required: false |
| license: |
| description: The license string to insert if missing. %YEAR% will be replaced with the current year |
| default: '' |
| required: false |
| type: string |
| license_test_string: |
| description: A file containing this string will be considered having a license. |
| default: '' |
| required: false |
| type: string |
| |
| jobs: |
| signal-rerun: |
| runs-on: ubuntu-latest |
| permissions: |
| pull-requests: write |
| # Because this workflow is called by other workflows, we need to make sure |
| # we only run this when the PR is in the current repo. |
| if: github.event.pull_request.head.repo.full_name == github.repository |
| steps: |
| - uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260 |
| - name: Install firehose (internal) |
| if: 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: github.repository != 'dart-lang/ecosystem' |
| run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/ |
| - name: Find Comment |
| id: fc |
| run: | |
| COMMENT_ID=$(dart pub global run firehose:comment find --issue ${{ github.event.number }} --author github-actions[bot] --body-includes "## PR Health") |
| echo "comment-id=$COMMENT_ID" >> "$GITHUB_OUTPUT" |
| |
| - name: Update comment |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 |
| if: steps.fc.outputs.comment-id != 0 |
| with: |
| github-token: ${{ secrets.GITHUB_TOKEN }} |
| script: | |
| await github.rest.issues.updateComment({ |
| owner: context.repo.owner, |
| repo: context.repo.repo, |
| comment_id: ${{ steps.fc.outputs.comment-id }}, |
| body: '## PR Health ⚠️\n\nHealth checks are rerunning. These details are out-of-date.' |
| }); |
| |
| changelog: |
| if: ${{ contains(inputs.checks, 'changelog') }} |
| uses: ./.github/workflows/health_base.yaml |
| with: |
| sdk: ${{ inputs.sdk }} |
| check: changelog |
| fail_on: ${{ inputs.fail_on }} |
| warn_on: ${{ inputs.warn_on }} |
| local_debug: ${{ inputs.local_debug }} |
| flutter_packages: ${{ inputs.flutter_packages }} |
| ignore_changelog: ${{ inputs.ignore_changelog }} |
| ignore_packages: ${{ inputs.ignore_packages }} |
| checkout_submodules: ${{ inputs.checkout_submodules }} |
| health_yaml_name: ${{ inputs.health_yaml_name }} |
| |
| license: |
| if: ${{ contains(inputs.checks, 'license') }} |
| uses: ./.github/workflows/health_base.yaml |
| with: |
| sdk: ${{ inputs.sdk }} |
| check: license |
| fail_on: ${{ inputs.fail_on }} |
| warn_on: ${{ inputs.warn_on }} |
| local_debug: ${{ inputs.local_debug }} |
| flutter_packages: ${{ inputs.flutter_packages }} |
| ignore_license: ${{ inputs.ignore_license }} |
| ignore_packages: ${{ inputs.ignore_packages }} |
| checkout_submodules: ${{ inputs.checkout_submodules }} |
| health_yaml_name: ${{ inputs.health_yaml_name }} |
| license: ${{ inputs.license }} |
| license_test_string: ${{ inputs.license_test_string }} |
| |
| coverage: |
| if: ${{ contains(inputs.checks, 'coverage') }} |
| uses: ./.github/workflows/health_base.yaml |
| with: |
| sdk: ${{ inputs.sdk }} |
| check: coverage |
| fail_on: ${{ inputs.fail_on }} |
| warn_on: ${{ inputs.warn_on }} |
| upload_coverage: ${{ inputs.upload_coverage }} |
| coverage_web: ${{ inputs.coverage_web }} |
| local_debug: ${{ inputs.local_debug }} |
| flutter_packages: ${{ inputs.flutter_packages }} |
| ignore_coverage: ${{ inputs.ignore_coverage }} |
| ignore_packages: ${{ inputs.ignore_packages }} |
| checkout_submodules: ${{ inputs.checkout_submodules }} |
| experiments: ${{ inputs.experiments }} |
| health_yaml_name: ${{ inputs.health_yaml_name }} |
| |
| breaking: |
| if: ${{ contains(inputs.checks, 'breaking') }} |
| uses: ./.github/workflows/health_base.yaml |
| with: |
| sdk: ${{ inputs.sdk }} |
| check: breaking |
| fail_on: ${{ inputs.fail_on }} |
| warn_on: ${{ inputs.warn_on }} |
| local_debug: ${{ inputs.local_debug }} |
| flutter_packages: ${{ inputs.flutter_packages }} |
| ignore_breaking: ${{ inputs.ignore_breaking }} |
| ignore_packages: ${{ inputs.ignore_packages }} |
| checkout_submodules: ${{ inputs.checkout_submodules }} |
| health_yaml_name: ${{ inputs.health_yaml_name }} |
| |
| do-not-submit: |
| if: ${{ contains(inputs.checks, 'do-not-submit') }} |
| uses: ./.github/workflows/health_base.yaml |
| with: |
| sdk: ${{ inputs.sdk }} |
| check: do-not-submit |
| fail_on: ${{ inputs.fail_on }} |
| warn_on: ${{ inputs.warn_on }} |
| local_debug: ${{ inputs.local_debug }} |
| flutter_packages: ${{ inputs.flutter_packages }} |
| ignore_donotsubmit: ${{ inputs.ignore_donotsubmit }} |
| ignore_packages: ${{ inputs.ignore_packages }} |
| checkout_submodules: ${{ inputs.checkout_submodules }} |
| health_yaml_name: ${{ inputs.health_yaml_name }} |
| |
| leaking: |
| if: ${{ contains(inputs.checks, 'leaking') }} |
| uses: ./.github/workflows/health_base.yaml |
| with: |
| sdk: ${{ inputs.sdk }} |
| check: leaking |
| fail_on: ${{ inputs.fail_on }} |
| warn_on: ${{ inputs.warn_on }} |
| local_debug: ${{ inputs.local_debug }} |
| flutter_packages: ${{ inputs.flutter_packages }} |
| ignore_leaking: ${{ inputs.ignore_leaking }} |
| ignore_packages: ${{ inputs.ignore_packages }} |
| checkout_submodules: ${{ inputs.checkout_submodules }} |
| health_yaml_name: ${{ inputs.health_yaml_name }} |
| |
| unused-dependencies: |
| if: ${{ contains(inputs.checks, 'unused-dependencies') }} |
| uses: ./.github/workflows/health_base.yaml |
| with: |
| sdk: ${{ inputs.sdk }} |
| check: unused-dependencies |
| fail_on: ${{ inputs.fail_on }} |
| warn_on: ${{ inputs.warn_on }} |
| local_debug: ${{ inputs.local_debug }} |
| flutter_packages: ${{ inputs.flutter_packages }} |
| ignore_packages: ${{ inputs.ignore_packages }} |
| checkout_submodules: ${{ inputs.checkout_submodules }} |
| health_yaml_name: ${{ inputs.health_yaml_name }} |
| |
| comment: |
| needs: [changelog, license, coverage, breaking, do-not-submit, leaking, unused-dependencies] |
| if: always() |
| # These permissions are required for us to create comments on PRs. |
| permissions: |
| pull-requests: write |
| |
| runs-on: ubuntu-latest |
| |
| steps: |
| - uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260 |
| - name: Install firehose (internal) |
| if: 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: github.repository != 'dart-lang/ecosystem' |
| run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/ |
| - name: Download All Artifacts |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| with: |
| path: single-comments |
| |
| - run: ls -R single-comments |
| |
| - name: Find Comment |
| id: fc |
| run: | |
| COMMENT_ID=$(dart pub global run firehose:comment find --issue ${{ github.event.number }} --author github-actions[bot] --body-includes "## PR Health") |
| echo "comment-id=$COMMENT_ID" >> "$GITHUB_OUTPUT" |
| |
| - name: Merge all single comments |
| run: | |
| mkdir output |
| echo $'## PR Health\n\n' >> output/comment.md |
| find single-comments -name '*.md' -exec cat {} + >> output/comment.md |
| echo ${{ github.event.number }} > output/issueNumber |
| |
| - name: Write comment id to file |
| if: ${{ steps.fc.outputs.comment-id != 0 }} |
| run: echo ${STEPS_FC_OUTPUTS_COMMENT_ID} >> output/commentId |
| env: |
| STEPS_FC_OUTPUTS_COMMENT_ID: ${{ steps.fc.outputs.comment-id }} |
| |
| - name: Upload folder with number and markdown |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a |
| with: |
| name: output |
| path: output/ |