Skip to content
Closed
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
48 changes: 48 additions & 0 deletions .github/workflows/skills_tool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: skills_tool
permissions: read-all

on:
# Run CI on all PRs (against any branch) and on pushes to the main branch.
pull_request:
paths:
- '.github/workflows/skills_tool.yaml'
- 'tool/**'
push:
branches: [ main ]
paths:
- '.github/workflows/skills_tool.yaml'
- 'tool/**'
schedule:
- cron: '0 0 * * 0' # weekly

defaults:
run:
working-directory: tool

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
sdk:
- stable
- dev
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.sdk }}

- run: dart pub get

- run: dart analyze --fatal-infos

- run: dart format --output=none --set-exit-if-changed .
if: ${{ matrix.sdk == 'dev' }}

- run: dart test
7 changes: 6 additions & 1 deletion tool/lib/src/commands/base_skill_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abstract class BaseSkillCommand extends Command {
required this.httpClient,
required this.logger,
this.outputDir,
this.environmentOverride,
}) {
argParser
..addOption('skill', help: 'Process only the specified skill by name.')
Expand All @@ -45,6 +46,9 @@ abstract class BaseSkillCommand extends Command {
/// The logger for this command.
final Logger logger;

/// Testing override for Platform.environment
final Map<String, String>? environmentOverride;

@override
Future<void> run() async {
final inputFile = argResults!.rest.isNotEmpty
Expand Down Expand Up @@ -77,7 +81,8 @@ abstract class BaseSkillCommand extends Command {
return;
}

final apiKey = Platform.environment['GEMINI_API_KEY'];
final env = environmentOverride ?? Platform.environment;
final apiKey = env['GEMINI_API_KEY'];
if (apiKey == null) {
logger.severe('GEMINI_API_KEY environment variable not set.');
return;
Expand Down
7 changes: 5 additions & 2 deletions tool/lib/src/commands/generate_skill_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import 'base_skill_command.dart';
/// Command to generate skills from a configuration file.
class GenerateSkillCommand extends BaseSkillCommand {
/// Creates a new [GenerateSkillCommand].
GenerateSkillCommand({required super.httpClient, super.outputDir})
: super(logger: Logger('GenerateSkillCommand'));
GenerateSkillCommand({
required super.httpClient,
super.outputDir,
super.environmentOverride,
}) : super(logger: Logger('GenerateSkillCommand'));

@override
String get name => 'generate-skill';
Expand Down
1 change: 1 addition & 0 deletions tool/lib/src/commands/validate_skill_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ValidateSkillCommand extends BaseSkillCommand {
ValidateSkillCommand({
required super.httpClient,
super.outputDir,
super.environmentOverride,
this.validationDir,
}) : super(logger: Logger('ValidateSkillCommand'));

Expand Down
1 change: 1 addition & 0 deletions tool/test/generate_skills_retry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void main() {
});

final command = GenerateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
httpClient: mockClient,
outputDir: tempDir,
);
Expand Down
4 changes: 4 additions & 0 deletions tool/test/generate_skills_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void main() {
});

final command = GenerateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
httpClient: mockClient,
outputDir: tempDir,
);
Expand Down Expand Up @@ -158,6 +159,7 @@ void main() {
});

final command = GenerateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
httpClient: mockClient,
outputDir: tempDir,
);
Expand Down Expand Up @@ -225,6 +227,7 @@ void main() {
});

final command = GenerateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
httpClient: mockClient,
outputDir: skillsDir,
);
Expand Down Expand Up @@ -302,6 +305,7 @@ void main() {
});

final command = GenerateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
httpClient: mockClient,
outputDir: skillsDir,
);
Expand Down
18 changes: 11 additions & 7 deletions tool/test/skill_assertions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ void main() {
group('Skill Assertions', () {
final skillsDir = Directory('../skills');

test('skills directory exists', () {
expect(
skillsDir.existsSync(),
isTrue,
reason: 'skills directory should exist',
);
});
test(
'skills directory exists',
() {
expect(
skillsDir.existsSync(),
isTrue,
reason: 'skills directory should exist',
);
},
skip: 'these tests need to be moved out of these tests, not all skills will be written to this directory',
);

final skillDirs = skillsDir.listSync().whereType<Directory>();

Expand Down
25 changes: 22 additions & 3 deletions tool/test/validate_skills_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void main() {
runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
validationDir: validationDir,
httpClient: mockClient,
Expand Down Expand Up @@ -136,6 +137,7 @@ void main() {
runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
validationDir: validationDir,
httpClient: mockClient,
Expand Down Expand Up @@ -180,6 +182,7 @@ void main() {
runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
validationDir: validationDir,
httpClient: mockClient,
Expand All @@ -199,7 +202,11 @@ void main() {

runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(outputDir: skillsDir, httpClient: mockClient),
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
httpClient: mockClient,
),
);

await IOOverrides.runZoned(() async {
Expand Down Expand Up @@ -240,7 +247,11 @@ void main() {

runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(outputDir: skillsDir, httpClient: mockClient),
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
httpClient: mockClient,
),
);

await IOOverrides.runZoned(() async {
Expand Down Expand Up @@ -274,7 +285,11 @@ void main() {

runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(outputDir: skillsDir, httpClient: mockClient),
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
httpClient: mockClient,
),
);

await runner.run(['validate-skill', configFile.path]);
Expand Down Expand Up @@ -320,6 +335,7 @@ void main() {
runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
validationDir: validationDir,
httpClient: mockClient,
Expand Down Expand Up @@ -369,6 +385,7 @@ void main() {
runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
validationDir: validationDir,
httpClient: mockClient,
Expand Down Expand Up @@ -416,6 +433,7 @@ void main() {
runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
validationDir: validationDir,
httpClient: mockClient,
Expand Down Expand Up @@ -495,6 +513,7 @@ Content
runner = CommandRunner('skills', 'Test runner')
..addCommand(
ValidateSkillCommand(
environmentOverride: {'GEMINI_API_KEY': 'fake'},
outputDir: skillsDir,
httpClient: mockClient,
validationDir: validationDir,
Expand Down
4 changes: 3 additions & 1 deletion tool/test/yaml_assets_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ void main() {
isTrue,
reason: 'tool/resources directory should exist',
);
});
},
skip: 'these tests need to be moved out of these tests, not all skills will be written to this directory',
);

if (!resourcesDir.existsSync()) return;

Expand Down
Loading