Skip to content

Commit

Permalink
Merge branch 'main' into alestiago/always-local-license-check
Browse files Browse the repository at this point in the history
  • Loading branch information
alestiago authored Nov 17, 2023
2 parents 7cd5133 + d991437 commit fff6b60
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 20 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ jobs:
- test/commands/create/dart_cli/dart_cli_test.dart
- test/commands/create/dart_package/dart_pkg_test.dart
- test/commands/create/docs_site/docs_site_test.dart
# FIXME(alestiago): Re-enable once the issue is fixed:
# https://github.com/VeryGoodOpenSource/very_good_flame_game/issues/103
# - test/commands/create/flame_game/flame_game_test.dart
- test/commands/create/flame_game/flame_game_test.dart
- test/commands/create/flutter_package/flutter_pkg_test.dart
- test/commands/create/flutter_plugin/flutter_plugin_test.dart

# E2E tests for the `packages check licenses` command
- test/commands/packages/check/licenses/licenses_allowed_test.dart
- test/commands/packages/check/licenses/licenses_forbidden_test.dart

steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/commands/create/flame_game/flame_game_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void main() {
['coverage/lcov.info', '-o', 'coverage'],
workingDirectory: workingDirectory,
);
expect(testCoverageResult.stdout, contains('lines......: 97.8%'));
expect(testCoverageResult.stdout, contains('lines......: 97.9%'));
}),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'dart:io';

import 'package:mason/mason.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

import '../../../../../helpers/helpers.dart';

/// Objectives:
///
/// * Generate a new Dart project using (`dart create`)
/// * Add dependencies to `pubspec.yaml` with an MIT license
/// * Run `very_good packages check licenses --allowed="MIT"` and expect success
void main() {
test(
'packages check licenses --allowed="MIT"',
timeout: const Timeout(Duration(minutes: 2)),
withRunner((commandRunner, logger, updater, logs) async {
final tempDirectory = Directory.systemTemp.createTempSync();
addTearDown(() => tempDirectory.deleteSync(recursive: true));

const projectName = 'my_dart_project';
await expectSuccessfulProcessResult(
'dart',
['create', 'my_dart_project', '--no-pub'],
workingDirectory: tempDirectory.path,
);
final projectPath = path.join(tempDirectory.path, projectName);
await expectSuccessfulProcessResult(
'dart',
['pub', 'add', 'formz'],
workingDirectory: projectPath,
);
await expectSuccessfulProcessResult(
'dart',
['pub', 'get'],
workingDirectory: projectPath,
);

final relativeProjectPath = path.relative(
projectPath,
from: Directory.current.path,
);
final resultAllowed = await commandRunner.run(
[
'packages',
'check',
'licenses',
'--allowed=MIT',
relativeProjectPath,
],
);
expect(
resultAllowed,
equals(ExitCode.success.code),
reason: 'Should succeed when allowed licenses are used',
);
}),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'dart:io';

import 'package:mason/mason.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

import '../../../../../helpers/helpers.dart';

/// Objectives:
///
/// * Generate a new Dart project using (`dart create`)
/// * Add dependencies to `pubspec.yaml` with an MIT license
/// * Run `very_good packages check licenses --forbidden="MIT"` and expect
/// failure
void main() {
test(
'packages check licenses --forbidden="MIT"',
timeout: const Timeout(Duration(minutes: 2)),
withRunner((commandRunner, logger, updater, logs) async {
final tempDirectory = Directory.systemTemp.createTempSync();
addTearDown(() => tempDirectory.deleteSync(recursive: true));

const projectName = 'my_dart_project';
await expectSuccessfulProcessResult(
'dart',
['create', 'my_dart_project', '--no-pub'],
workingDirectory: tempDirectory.path,
);
final projectPath = path.join(tempDirectory.path, projectName);
await expectSuccessfulProcessResult(
'dart',
['pub', 'add', 'formz'],
workingDirectory: projectPath,
);
await expectSuccessfulProcessResult(
'dart',
['pub', 'get'],
workingDirectory: projectPath,
);

final relativeProjectPath = path.relative(
projectPath,
from: Directory.current.path,
);

final resultForbidden = await commandRunner.run(
[
'packages',
'check',
'licenses',
'--forbidden=MIT',
relativeProjectPath,
],
);
expect(
resultForbidden,
equals(ExitCode.config.code),
reason: 'Should fail when forbidden licenses are used',
);
}),
);
}
28 changes: 14 additions & 14 deletions site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"react-dom": "^17.0.2"
},
"devDependencies": {
"@babel/eslint-parser": "^7.22.15",
"@babel/eslint-parser": "^7.23.3",
"@docusaurus/eslint-plugin": "^2.4.3",
"@docusaurus/module-type-aliases": "^2.4.3",
"@tsconfig/docusaurus": "^2.0.2",
"eslint": "^8.53.0",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"typescript": "^5.2.2"
},
"browserslist": {
Expand Down

0 comments on commit fff6b60

Please sign in to comment.