Skip to content

Fix PR label fetching #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions .github/workflows/health_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,42 +54,42 @@ on:
required: false
flutter_packages:
description: List of packages depending on Flutter.
default: "\"\""
default: '""'
required: false
type: string
ignore_license:
description: Which files to ignore for the license check.
default: "\"\""
default: '""'
required: false
type: string
ignore_changelog:
description: Which files to ignore for the license check.
default: "\"\""
default: '""'
required: false
type: string
ignore_coverage:
description: Which files to ignore for the coverage check.
default: "\"\""
default: '""'
required: false
type: string
ignore_breaking:
description: Which files to ignore for the license check.
default: "\"\""
default: '""'
required: false
type: string
ignore_leaking:
description: Which files to ignore for the license check.
default: "\"\""
default: '""'
required: false
type: string
ignore_donotsubmit:
description: Which files to ignore for the license check.
default: "\"\""
default: '""'
required: false
type: string
ignore_packages:
description: Which packages to ignore.
default: "\"\""
default: '""'
required: false
type: string
checkout_submodules:
Expand All @@ -99,7 +99,7 @@ on:
type: boolean
experiments:
description: Which experiments should be enabled for Dart.
default: "\"\""
default: '""'
type: string
required: false

Expand All @@ -117,7 +117,7 @@ jobs:
with:
path: current_repo/
submodules: ${{ inputs.checkout_submodules }}

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ github.event.pull_request.base.ref }}
Expand All @@ -126,7 +126,7 @@ jobs:
if: ${{ inputs.check == 'coverage' }} || ${{ inputs.check == 'breaking' }}

- run: mkdir -p current_repo/output/

- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
sdk: ${{ inputs.sdk }}
Expand All @@ -148,19 +148,32 @@ jobs:

- name: Install firehose
run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/
if: ${{ !inputs.local_debug }}
if: ${{ !inputs.local_debug }}

- name: Install local firehose
run: dart pub global activate --source path current_repo/pkgs/firehose/
if: ${{ inputs.local_debug }}

if: ${{ inputs.local_debug }}

- name: Fetch labels
id: fetch-labels
run: |
labels="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')"
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: "${{ join(github.event.pull_request.labels.*.name) }}"
PR_LABELS: ${{ steps.fetch-labels.outputs.labels }}
run: |
cd current_repo/
dart pub global run firehose:health \
Expand Down
56 changes: 34 additions & 22 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ name: Publish
# with:
# write-comments: false

# It is also possible to ignore certain packages in the repository
# It is also possible to ignore certain packages in the repository
# via a glob.
#
# jobs:
Expand All @@ -60,10 +60,10 @@ on:
inputs:
environment:
description: >-
If specified, publishes will be performed from this environment,
which will require additional approvals. See
https://dart.dev/tools/pub/automated-publishing for more
information.
If specified, publishes will be performed from this environment,
which will require additional approvals. See
https://dart.dev/tools/pub/automated-publishing for more
information.
required: false
type: string
sdk:
Expand Down Expand Up @@ -94,7 +94,7 @@ on:
type: boolean
ignore-packages:
description: Which packages to ignore.
default: "\"\""
default: '""'
required: false
type: string
local_debug:
Expand Down Expand Up @@ -123,7 +123,6 @@ jobs:
if: ${{ inputs.use-flutter }}
with:
channel: ${{ inputs.sdk }}


- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
if: ${{ !inputs.use-flutter }}
Expand All @@ -132,45 +131,59 @@ jobs:

- name: Install firehose
run: dart pub global activate firehose
if: ${{ !inputs.local_debug }}
if: ${{ !inputs.local_debug }}

- name: Install local firehose
run: dart pub global activate --source path pkgs/firehose/
if: ${{ inputs.local_debug }}

if: ${{ inputs.local_debug }}

- name: Fetch labels
id: fetch-labels
run: |
labels="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')"
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: Validate packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.number }}
PR_LABELS: "${{ join(github.event.pull_request.labels.*.name) }}"
PR_LABELS: ${{ steps.fetch-labels.outputs.labels }}
run: |
dart pub global run firehose \
--validate \
${{ fromJSON('{"true":"--use-flutter","false":"--no-use-flutter"}')[inputs.use-flutter] }} \
--ignore-packages ${{ inputs.ignore-packages }}
dart pub global run firehose \
--validate \
${{ fromJSON('{"true":"--use-flutter","false":"--no-use-flutter"}')[inputs.use-flutter] }} \
--ignore-packages ${{ inputs.ignore-packages }}

- name: Get comment id
id: comment-id
if: ${{ (hashFiles('output/comment.md') != '') && inputs.write-comments }}
run: |
touch -a output/commentId
COMMENT_ID=$(cat output/commentId)
echo "COMMENT_ID=$COMMENT_ID" >> $GITHUB_ENV
echo "comment=$COMMENT_ID" >> "$GITHUB_OUTPUT"

- name: Create comment
uses: peter-evans/create-or-update-comment@5a1e4b77bf9c12cc13806fc353ad08dc110f78ce
if: ${{ (hashFiles('output/comment.md') != '') && inputs.write-comments && (env.COMMENT_ID == '') }}
if: ${{ (hashFiles('output/comment.md') != '') && inputs.write-comments && (steps.comment-id.outputs.comment == '') }}
continue-on-error: true
with:
issue-number: ${{ github.event.number }}
body-path: 'output/comment.md'
body-path: "output/comment.md"
edit-mode: replace

- name: Update comment
uses: peter-evans/create-or-update-comment@5a1e4b77bf9c12cc13806fc353ad08dc110f78ce
if: ${{ (hashFiles('output/comment.md') != '') && inputs.write-comments && (env.COMMENT_ID != '') }}
if: ${{ (hashFiles('output/comment.md') != '') && inputs.write-comments && (steps.comment-id.outputs.comment != '') }}
with:
comment-id: ${{ env.COMMENT_ID }}
body-path: 'output/comment.md'
comment-id: ${{ steps.comment-id.outputs.comment }}
body-path: "output/comment.md"
edit-mode: replace

- name: Save PR number
Expand All @@ -184,7 +197,6 @@ jobs:
with:
name: output
path: output/


publish:
if: ${{ github.event_name == 'push' }}
Expand Down