Skip to content
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

Update health workflow #216

Merged
merged 49 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
41f8ca7
Update health workflow
mosuem Jan 4, 2024
83c2789
Add warn_on and fail_on
mosuem Jan 4, 2024
8450538
Change defaults
mosuem Jan 4, 2024
9b2e772
Refactorings
mosuem Jan 4, 2024
abc38a9
Change failure message
mosuem Jan 4, 2024
d208116
Write on failure
mosuem Jan 4, 2024
be8d46a
Test throw
mosuem Jan 4, 2024
fdae641
Move comment Id saving up
mosuem Jan 4, 2024
d1e27e3
Fix line break
mosuem Jan 4, 2024
babac7d
Revert introducing error
mosuem Jan 4, 2024
c19d543
Append new workflows
mosuem Jan 4, 2024
a992afd
Fixes
mosuem Jan 4, 2024
b7c52eb
Add debug
mosuem Jan 4, 2024
6371dc0
Fix name
mosuem Jan 4, 2024
33f0446
Extract license wf
mosuem Jan 4, 2024
0a22004
Post summaries of license wf
mosuem Jan 4, 2024
1b5359c
Refactor
mosuem Jan 4, 2024
c0669d0
Split into jobs
mosuem Jan 4, 2024
4b35e55
Separate jobs
mosuem Jan 5, 2024
585e0c4
Fix
mosuem Jan 5, 2024
32caf70
Fix again
mosuem Jan 5, 2024
8bf8c0f
Set version
mosuem Jan 5, 2024
ea12bb7
Try again
mosuem Jan 5, 2024
cda8c7f
set fail
mosuem Jan 5, 2024
f36ff91
Fix fail
mosuem Jan 5, 2024
010b90d
Create folder
mosuem Jan 5, 2024
f83626e
Fix commenting
mosuem Jan 5, 2024
f978966
Rename comment files
mosuem Jan 5, 2024
e245114
Route options
mosuem Jan 5, 2024
b90fff6
Add comment id
mosuem Jan 5, 2024
745bb75
Set version hash
mosuem Jan 5, 2024
6e04cac
Fix ref
mosuem Jan 5, 2024
ecbc5fc
Fix commenting
mosuem Jan 5, 2024
85bf4a1
rename comments
mosuem Jan 5, 2024
238e5b2
Fix merging
mosuem Jan 5, 2024
5a21dc9
Remove empty
mosuem Jan 5, 2024
2e29e30
Debug finding comment id
mosuem Jan 5, 2024
b55afb6
Fix
mosuem Jan 5, 2024
797675d
Always comment
mosuem Jan 5, 2024
0a1a932
Always upload comment
mosuem Jan 5, 2024
f6180e1
Fixes
mosuem Jan 5, 2024
4fee5d3
Rename job
mosuem Jan 5, 2024
aee37ad
Refactor to single check
mosuem Jan 5, 2024
7000934
Don't fail on changelog
mosuem Jan 5, 2024
4e84c0c
Cleanups
mosuem Jan 5, 2024
a5c3912
Add changelog
mosuem Jan 5, 2024
ed74b97
Remove names
mosuem Jan 5, 2024
3e0fb4a
Fix documentation
mosuem Jan 5, 2024
0e21976
Add newlines
mosuem Jan 5, 2024
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
158 changes: 102 additions & 56 deletions .github/workflows/health.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ on:
default: "version,changelog,license,coverage,breaking,do-not-submit"
type: string
required: false
fail_on:
description: Which checks should lead to failure - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
default: "version,changelog,do-not-submit"
type: string
required: false
warn_on:
description: Which checks should not fail, but only warn - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
default: "license,coverage,breaking"
type: string
required: false
local_debug:
description: Whether to use a local copy of package:firehose - only for debug
default: false
Expand All @@ -70,76 +80,112 @@ on:
type: boolean

jobs:
health:
version:
if: contains(${{ inputs.checks }}, 'version')
uses: ./.github/workflows/health_base.yaml
with:
sdk: ${{ inputs.sdk }}
check: version
fail_on: ${{ inputs.fail_on }}
warn_on: ${{ inputs.warn_on }}
local_debug: ${{ inputs.local_debug }}
use-flutter: ${{ inputs.use-flutter }}

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 }}
use-flutter: ${{ inputs.use-flutter }}

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 }}
use-flutter: ${{ inputs.use-flutter }}

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 }}
use-flutter: ${{ inputs.use-flutter }}

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 }}
use-flutter: ${{ inputs.use-flutter }}

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 }}
use-flutter: ${{ inputs.use-flutter }}

comment:
needs: [version, changelog, license, coverage, breaking, do-not-submit]
if: always()
# These permissions are required for us to create comments on PRs.
permissions:
pull-requests: write

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Download All Artifacts
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110
with:
path: current_repo/

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ github.event.pull_request.base.ref }}
path: base_repo/

- uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225
if: ${{ inputs.use-flutter }}
with:
channel: ${{ inputs.sdk }}

- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d
if: ${{ !inputs.use-flutter }}
with:
sdk: ${{ inputs.sdk }}

- name: Install coverage
run: dart pub global activate coverage
path: single-comments

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

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

- name: Install api_tool
run: dart pub global activate dart_apitool

- name: Check PR health
id: healthstep
if: ${{ github.event_name == 'pull_request' }}
continue-on-error: true # continue, so that the result is written as a comment. Fail in the last step
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.number }}
PR_LABELS: "${{ join(github.event.pull_request.labels.*.name) }}"
run: cd current_repo/ && dart pub global run firehose:health --checks ${{ inputs.checks }} ${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }}

- name: Upload coverage to Coveralls
if: ${{ inputs.upload_coverage }}
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
- name: Find Comment
uses: peter-evans/find-comment@4541d1b6b0e618acc24284e118743fc5ad0bc5de
id: fc
with:
format: lcov
base-path: current_repo/
compare-sha: ${{ github.event.pull_request.base.ref }}
allow-empty: true

- name: Save PR number
issue-number: ${{ github.event.number }}
comment-author: github-actions[bot]
body-includes: '## PR Health'

- name: Merge all single comments
run: |
mkdir -p current_repo/output/ && echo ${{ github.event.number }} > current_repo/output/issueNumber
mkdir output
echo $'## PR Health \n\n' >> output/comment.md
cat single-comments/*/*.md >> 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

- name: Upload folder with number and markdown
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
with:
name: output
path: current_repo/output/

- name: Fail the workflow if "Check PR health" failed
if: steps.healthstep.outcome != 'success'
run: exit 1
path: output/
155 changes: 155 additions & 0 deletions .github/workflows/health_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# A CI configuration to check PR health.

name: Health:Base

# 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
mosuem marked this conversation as resolved.
Show resolved Hide resolved
# with:
# coverage_web: true #If the coverage should run browser tests

# 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.
#
# The checks can also be restricted to any subset of version, changelog, and license,
# if needed.
#
# jobs:
mosuem marked this conversation as resolved.
Show resolved Hide resolved
# health:
# uses: dart-lang/ecosystem/.github/workflows/health.yaml@main
# with:
# sdk: beta
# checks: "version,changelog,license,coverage,breaking,do-not-submit"

on:
workflow_call:
inputs:
sdk:
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
check:
description: What to check for in the PR health check - any of "version,changelog,license,coverage,breaking,do-not-submit"
type: string
required: true
fail_on:
description: Which checks should lead to failure - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
default: "version,changelog,do-not-submit"
type: string
required: false
warn_on:
description: Which checks should not fail, but only warn - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
default: "license,coverage,breaking"
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
use-flutter:
description: >-
Whether to setup Flutter in this workflow.
default: false
required: false
type: boolean

jobs:
health:
name: run
# These permissions are required for us to create comments on PRs.
permissions:
pull-requests: write

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
path: current_repo/

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ github.event.pull_request.base.ref }}
path: base_repo/
if: ${{ inputs.check == 'coverage' }} || ${{ inputs.check == 'breaking' }}

- name: Write comment if not present
run: |
mkdir -p current_repo/output/
test -f current_repo/output/comment.md || echo $'The ${{ inputs.check }} workflow has encountered an exception and did not complete.' >> current_repo/output/comment.md

- uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225
if: ${{ inputs.use-flutter }}
with:
channel: ${{ inputs.sdk }}

- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d
if: ${{ !inputs.use-flutter }}
with:
sdk: ${{ inputs.sdk }}

- name: Install coverage
run: dart pub global activate coverage
if: ${{ inputs.check == 'coverage' }}

- name: Install firehose
run: dart pub global activate 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: Install api_tool
run: dart pub global activate dart_apitool
if: ${{ inputs.check == 'breaking' }}

- 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) }}"
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 }}

- name: Upload coverage to Coveralls
if: ${{ inputs.upload_coverage }}
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
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@c7d193f32edcb7bfad88892161225aeda64e9392
with:
name: comment-${{ inputs.check }}
path: current_repo/output/comment.md
mosuem marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions .github/workflows/health_internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ jobs:
coverage_web: false
upload_coverage: false
checks: version,changelog,license,coverage,breaking,do-not-submit
fail_on: version,changelog,do-not-submit
warn_on: license,coverage,breaking
mosuem marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/workflows/post_summaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_run:
workflows:
- Publish
- Health
- Health:Comment
types:
- completed

Expand Down
4 changes: 4 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0

- Split health checks in individual workflows.

## 0.4.2

- Get needed version from `dart_apitool` in PR health checks.
Expand Down
Loading