Skip to content

Commit

Permalink
Excise health from firehose (#118)
Browse files Browse the repository at this point in the history
* Excise health from firehose

* Switch to branch

* Fix call site

* Fix call site 2

* Add changelog entry

* Change PR comment

* Typo

* Refactor severity

* Add version health check

* Change validation markdown

* Add tags to skip

* Prepare for publish

* Changes as per review
  • Loading branch information
mosuem authored Jun 27, 2023
1 parent 36c662e commit 9ef5948
Show file tree
Hide file tree
Showing 9 changed files with 320 additions and 288 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/health.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ on:
required: false
type: string
checks:
description: What to check for in the PR health check - any subset of "version,changelog,license"
default: "version,changelog,license"
description: What to check for in the PR health check - any subset of "version changelog license"
default: "version changelog license"
type: string
required: false

Expand All @@ -60,12 +60,12 @@ jobs:
sdk: ${{ inputs.sdk }}

- name: Install firehose
run: dart pub global activate --source git https://github.com/dart-lang/ecosystem.git --git-path pkgs/firehose/ --git-ref=unifiedWorkflow #TODO remove, just for testing
run: dart pub global activate firehose

- name: Validate packages
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: dart pub global run firehose --health ${{ inputs.checks }}
run: dart pub global run firehose:health ${{ inputs.checks }}
2 changes: 0 additions & 2 deletions .github/workflows/health_internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ on:
jobs:
health:
uses: ./.github/workflows/health.yaml
with:
checks: "changelog,license"
3 changes: 2 additions & 1 deletion pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.3.18-wip
## 0.3.18
- Add Github workflow for PR health.
- Refactorings to health workflow.

## 0.3.17

Expand Down
14 changes: 3 additions & 11 deletions pkgs/firehose/bin/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ void main(List<String> arguments) async {

var validate = argResults['validate'] == true;
var publish = argResults['publish'] == true;
var health = argResults['health'] != null;

if (!validate && !publish && !health) {
_usage(argParser, error: '''
Error: one of --validate, --publish, or --health must be specified.''');
if (!validate && !publish) {
_usage(argParser,
error: 'Error: one of --validate or --publish must be specified.');
exit(1);
}

Expand All @@ -42,8 +41,6 @@ Error: one of --validate, --publish, or --health must be specified.''');
await firehose.validate();
} else if (publish) {
await firehose.publish();
} else if (health) {
await firehose.healthCheck(argResults['health'] as List);
}
} on ArgParserException catch (e) {
_usage(argParser, error: e.message);
Expand Down Expand Up @@ -76,11 +73,6 @@ ArgParser _createArgs() {
help: 'Validate packages and indicate whether --publish would publish '
'anything.',
)
..addMultiOption(
'health',
defaultsTo: ['version', 'license', 'changelog'],
help: 'Check PR health.',
)
..addFlag(
'publish',
negatable: false,
Expand Down
22 changes: 22 additions & 0 deletions pkgs/firehose/bin/health.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';

import 'package:args/args.dart';
import 'package:firehose/health.dart';

void main(List<String> arguments) async {
var argParser = ArgParser()
..addMultiOption(
'checks',
defaultsTo: ['version', 'license', 'changelog'],
allowed: ['version', 'license', 'changelog'],
help: 'Check PR health.',
);
var parsedArgs = argParser.parse(arguments);

await Health(Directory.current)
.healthCheck(parsedArgs['checks'] as List<String>);
}
Loading

0 comments on commit 9ef5948

Please sign in to comment.