Skip to content

Commit

Permalink
chore: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
XVincentX committed Nov 27, 2019
1 parent 8183021 commit 7616e77
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ inputs:
file_glob:
required: true
description: The file path to lint with Spectral
default: '*.oas.{json,yml,yaml}'
spectral_ruleset:
required: true
description: Ruleset file to load in Spectral
default: 'spectral:oas'
repo_token:
required: true
description: Ruleset file to load in Spectral
runs:
using: docker
image: Dockerfile
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { DiagnosticSeverity } from '@stoplight/types';
import { warning } from '@actions/core';
import { EOL } from 'os';
import { promises as fs } from 'fs';
import { array, flatten } from 'fp-ts/lib/Array';
import { array } from 'fp-ts/lib/Array';
import { flatten } from 'lodash';
import { Config } from './config';
import { runSpectral, createSpectral } from './spectral';
import { createGithubCheck, createOctokitInstance, getRepositoryInfoFromEvent, updateGithubCheck } from './octokit';
Expand Down
20 changes: 9 additions & 11 deletions src/octokit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { GitHub } from '@actions/github';
import * as TaskEither from 'fp-ts/lib/TaskEither';
import * as IOEither from 'fp-ts/lib/IOEither';
import * as Either from 'fp-ts/lib/Either';
import * as TE from 'fp-ts/lib/TaskEither';
import * as E from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/pipeable';
import { ChecksCreateResponse, ChecksUpdateParamsOutputAnnotations, ChecksUpdateParams, Response } from '@octokit/rest';

Expand All @@ -14,30 +13,29 @@ type Event = {
};
};

export const createOctokitInstance = (token: string) =>
TaskEither.fromIOEither(IOEither.tryCatch(() => new GitHub(token), Either.toError));
export const createOctokitInstance = (token: string) => TE.fromEither(E.tryCatch(() => new GitHub(token), E.toError));

export const createGithubCheck = (
octokit: GitHub,
event: { owner: string; repo: string },
name: string,
head_sha: string
) =>
TaskEither.tryCatch(
TE.tryCatch(
() =>
octokit.checks.create({
owner: event.owner,
repo: event.repo,
name,
head_sha,
}),
Either.toError
E.toError
);

export const getRepositoryInfoFromEvent = (eventPath: string) =>
pipe(
TaskEither.fromIOEither(IOEither.tryCatch<Error, Event>(() => require(eventPath), Either.toError)),
TaskEither.map(event => {
TE.fromEither(E.tryCatch<Error, Event>(() => require(eventPath), E.toError)),
TE.map(event => {
const { repository } = event;
const {
owner: { login: owner },
Expand All @@ -56,7 +54,7 @@ export const updateGithubCheck = (
conclusion: ChecksUpdateParams['conclusion'],
message?: string
) =>
TaskEither.tryCatch(
TE.tryCatch(
() =>
octokit.checks.update({
check_run_id: check.data.id,
Expand All @@ -76,5 +74,5 @@ export const updateGithubCheck = (
annotations,
},
}),
Either.toError
E.toError
);

0 comments on commit 7616e77

Please sign in to comment.