Skip to content

Commit

Permalink
Switch to glob
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Jan 8, 2024
1 parent 0c31c59 commit 6b487f8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/health.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ on:
type: boolean
required: false
use-flutter:
description: >-
Whether to setup Flutter in this workflow.
description: Whether to setup Flutter in this workflow.
default: false
required: false
type: boolean
ignore_license:
description: Which files to ignore when checking for licenses.
required: false
type: string

jobs:
version:
Expand Down Expand Up @@ -117,6 +120,7 @@ jobs:
warn_on: ${{ inputs.warn_on }}
local_debug: ${{ inputs.local_debug }}
use-flutter: ${{ inputs.use-flutter }}
ignore: ${{ inputs.ignore_license }}

coverage:
if: contains(${{ inputs.checks }}, 'coverage')
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/health_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ on:
type: boolean
ignore:
description: The files to ignore for this check.
default: ""
required: false
type: string

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/health_internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ jobs:
checks: version,changelog,license,coverage,breaking,do-not-submit
fail_on: version,changelog,do-not-submit
warn_on: license,coverage,breaking
ignore_license: '**.g.dart'
5 changes: 3 additions & 2 deletions pkgs/firehose/lib/src/health/health.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'dart:io';
import 'dart:math';

import 'package:collection/collection.dart';
import 'package:glob/glob.dart';
import 'package:path/path.dart' as path;
import 'package:pub_semver/pub_semver.dart';

Expand Down Expand Up @@ -53,14 +54,14 @@ class Health {
this.failOn,
this.coverageweb,
List<String> ignored,
) : ignoredFiles = ignored.map(RegExp.new).toList();
) : ignoredFiles = ignored.map((e) => Glob(e)).toList();
final github = GithubApi();

final String check;
final List<String> warnOn;
final List<String> failOn;
final bool coverageweb;
final List<RegExp> ignoredFiles;
final List<Glob> ignoredFiles;

Future<void> healthCheck() async {
// Do basic validation of our expected env var.
Expand Down
5 changes: 3 additions & 2 deletions pkgs/firehose/lib/src/health/license.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:io';

import 'package:collection/collection.dart';
import 'package:glob/glob.dart';
import 'package:path/path.dart' as path;

final license = '''
Expand All @@ -13,7 +14,7 @@ final license = '''
// BSD-style license that can be found in the LICENSE file.''';

Future<List<String>> getFilesWithoutLicenses(
Directory repositoryDir, List<RegExp> ignoredFiles) async {
Directory repositoryDir, List<Glob> ignoredFiles) async {
var dartFiles = await repositoryDir
.list(recursive: true)
.where((f) => f.path.endsWith('.dart'))
Expand All @@ -26,7 +27,7 @@ Future<List<String>> getFilesWithoutLicenses(
if (!fileContainsCopyright) {
var relativePath =
path.relative(file.path, from: Directory.current.path);
if (ignoredFiles.none((regex) => regex.hasMatch(relativePath))) {
if (ignoredFiles.none((regex) => regex.matches(relativePath))) {
print(relativePath);
return relativePath;
}
Expand Down
1 change: 1 addition & 0 deletions pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
pub_semver: ^2.1.0
pubspec_parse: ^1.2.3
yaml: ^3.1.0
glob: ^2.1.2

dev_dependencies:
dart_flutter_team_lints: ^2.0.0
Expand Down

0 comments on commit 6b487f8

Please sign in to comment.