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

github check created after loading ruleset #643

Merged
merged 1 commit into from
Jun 7, 2022
Merged
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
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ const program = pipe(
TE.fromEither(getRepositoryInfoFromEvent(config.GITHUB_EVENT_PATH, config.INPUT_EVENT_NAME))
),
TE.bind('octokit', ({ config }) => TE.fromEither(createOctokitInstance(config.INPUT_REPO_TOKEN))),
TE.bind('check', ({ octokit, repositoryInfo }) =>
createGithubCheck(octokit, repositoryInfo, `${CHECK_NAME} (${repositoryInfo.eventName})`)
),
TE.bind('fileContents', ({ config }) => readFilesToAnalyze(config.INPUT_FILE_GLOB, config.GITHUB_WORKSPACE)),
TE.bind('annotations', ({ fileContents, config }) =>
createSpectralAnnotations(config.INPUT_SPECTRAL_RULESET, fileContents, config.GITHUB_WORKSPACE)
),
TE.bind('check', ({ octokit, repositoryInfo }) =>
createGithubCheck(octokit, repositoryInfo, `${CHECK_NAME} (${repositoryInfo.eventName})`)
),
TE.bind('checkResponse', ({ octokit, check, repositoryInfo, annotations }) =>
updateGithubCheck(
octokit,
Expand Down
11 changes: 9 additions & 2 deletions src/spectral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as TE from 'fp-ts/TaskEither';
import * as E from 'fp-ts/Either';
import { pipe } from 'fp-ts/pipeable';

import { info } from '@actions/core';
import { info, setFailed } from '@actions/core';
import { getRuleset } from './getRuleset';

const retrieveSpectralPackageVersion = (): IOEither.IOEither<Error, string> =>
Expand All @@ -25,7 +25,14 @@ export const createSpectral = (rulesetPath: string) =>
info(`Running @stoplight/spectral-core v${spectralPackageVersion}`);

const spectral = new Spectral({ resolver: httpAndFileResolver });
spectral.setRuleset(await getRuleset(rulesetPath));

try {
const ruleset = await getRuleset(rulesetPath);
spectral.setRuleset(ruleset);
} catch (e) {
setFailed('Issue loading ruleset');
throw e;
}

const loadedRules = Object.values(spectral.ruleset!.rules);
info(` - ${pluralize('rule', loadedRules.length)} (${loadedRules.filter(r => r.enabled).length} enabled)`);
Expand Down