Skip to content

Commit 6018583

Browse files
authored
Merge pull request #643 from stoplightio/fix/640-regression
github check created after loading ruleset
2 parents 4842a6b + da315eb commit 6018583

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ const program = pipe(
133133
TE.fromEither(getRepositoryInfoFromEvent(config.GITHUB_EVENT_PATH, config.INPUT_EVENT_NAME))
134134
),
135135
TE.bind('octokit', ({ config }) => TE.fromEither(createOctokitInstance(config.INPUT_REPO_TOKEN))),
136-
TE.bind('check', ({ octokit, repositoryInfo }) =>
137-
createGithubCheck(octokit, repositoryInfo, `${CHECK_NAME} (${repositoryInfo.eventName})`)
138-
),
139136
TE.bind('fileContents', ({ config }) => readFilesToAnalyze(config.INPUT_FILE_GLOB, config.GITHUB_WORKSPACE)),
140137
TE.bind('annotations', ({ fileContents, config }) =>
141138
createSpectralAnnotations(config.INPUT_SPECTRAL_RULESET, fileContents, config.GITHUB_WORKSPACE)
142139
),
140+
TE.bind('check', ({ octokit, repositoryInfo }) =>
141+
createGithubCheck(octokit, repositoryInfo, `${CHECK_NAME} (${repositoryInfo.eventName})`)
142+
),
143143
TE.bind('checkResponse', ({ octokit, check, repositoryInfo, annotations }) =>
144144
updateGithubCheck(
145145
octokit,

src/spectral.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as TE from 'fp-ts/TaskEither';
88
import * as E from 'fp-ts/Either';
99
import { pipe } from 'fp-ts/pipeable';
1010

11-
import { info } from '@actions/core';
11+
import { info, setFailed } from '@actions/core';
1212
import { getRuleset } from './getRuleset';
1313

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

2727
const spectral = new Spectral({ resolver: httpAndFileResolver });
28-
spectral.setRuleset(await getRuleset(rulesetPath));
28+
29+
try {
30+
const ruleset = await getRuleset(rulesetPath);
31+
spectral.setRuleset(ruleset);
32+
} catch (e) {
33+
setFailed('Issue loading ruleset');
34+
throw e;
35+
}
2936

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

0 commit comments

Comments
 (0)