Skip to content

Commit

Permalink
Merge pull request #643 from stoplightio/fix/640-regression
Browse files Browse the repository at this point in the history
github check created after loading ruleset
  • Loading branch information
kaylachun authored Jun 7, 2022
2 parents 4842a6b + da315eb commit 6018583
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
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

0 comments on commit 6018583

Please sign in to comment.