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

Introduce globbing for the JSONS input #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -37,6 +37,24 @@ describe('Github action results', () => {
expect(result.toString()).toContain(`::set-output name=INVALID,::${os.EOL}`);
});

test('JSONS argument accepts globs', () => {
// Arrange
mockedConfig.mockValue('SCHEMA', './mocks/schema/valid.json');
mockedConfig.mockValue('JSONS', './mocks/tested-*/valid.json');

mockedConfig.set();

const options: cp.ExecOptions = {
env: process.env,
};

// Act
const result = cp.execSync(`node ${ip}`, options);

// Assert
expect(result.toString()).toContain(`::set-output name=INVALID,::${os.EOL}`);
});

test('Error is thrown when GITHUB_WORKSPACE environment variable is not set', () => {
// Arrange
mockedConfig.resetAll();
24 changes: 18 additions & 6 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.0.0",
"@actions/glob": "^0.1.1",
"@types/jest": "^24.0.22",
"ajv": "^6.10.2",
"better-ajv-errors": "^0.6.7",
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from '@actions/core';
import * as glob from '@actions/glob';
import { getConfig, verifyConfigValues } from './configuration';
import { validateJsons } from './json-validator';

@@ -12,7 +13,9 @@ async function run() {
return;
}

const jsonRelativePaths = configuration.JSONS.split(',');
const patterns = configuration.JSONS.split(',');
const globber = await glob.create(patterns.join('\n'));
const jsonRelativePaths = await globber.glob();

const validationResults = await validateJsons(
configuration.GITHUB_WORKSPACE,