Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
chore: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
technote-space committed Jun 1, 2022
1 parent 7fe45d8 commit 744bb25
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"build": "tsc",
"cover": "vitest run --coverage",
"postinstall": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/husky ] || husky install",
"lint": "eslint 'src/**/*.ts' '__tests__/**/*.ts' --cache",
"lint:fix": "eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",
"lint": "eslint 'src/**/*.ts' --cache",
"lint:fix": "eslint --fix 'src/**/*.ts'",
"prepublishOnly": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --disable",
"postpublish": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --enable",
"release": "yarn release-ga --test",
Expand Down
12 changes: 6 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {resolve} from 'path';
import {setFailed} from '@actions/core';
import {Context} from '@actions/github/lib/context';
import {ContextHelper, Utils} from '@technote-space/github-action-helper';
import {Logger} from '@technote-space/github-action-log-helper';
import {execute} from './process';
import { resolve } from 'path';
import { setFailed } from '@actions/core';
import { Context } from '@actions/github/lib/context';
import { ContextHelper, Utils } from '@technote-space/github-action-helper';
import { Logger } from '@technote-space/github-action-log-helper';
import { execute } from './process';

const run = async(): Promise<void> => {
const logger = new Logger();
Expand Down
38 changes: 19 additions & 19 deletions __tests__/process.test.ts → src/process.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-magic-numbers */
import { describe, expect, it } from 'vitest';
import nock from 'nock';
import {resolve} from 'path';
import { resolve } from 'path';
import {
testEnv,
spyOnStdout,
Expand All @@ -14,12 +14,12 @@ import {
spyOnExportVariable,
exportVariableCalledWith,
} from '@technote-space/github-action-test-helper';
import {Logger} from '@technote-space/github-action-log-helper';
import {getJobs, getJobConclusions, getWorkflowConclusion, execute} from '../src/process';
import { Logger } from '@technote-space/github-action-log-helper';
import { getJobs, getJobConclusions, getWorkflowConclusion, execute } from './process';

const rootDir = resolve(__dirname, '..');
const fixtureRootDir = resolve(__dirname, 'fixtures');
const context = generateContext({owner: 'hello', repo: 'world'}, {
const context = generateContext({ owner: 'hello', repo: 'world' }, {
runId: 123,
});
const octokit = getOctokit();
Expand Down Expand Up @@ -59,17 +59,17 @@ describe('getJobs', () => {
describe('getJobConclusions', () => {
it('should get conclusions', () => {
expect(getJobConclusions([
{name: 'test1', conclusion: 'cancelled'},
{name: 'test2', conclusion: 'neutral'},
{name: 'test3', conclusion: 'failure'},
{name: 'test4', conclusion: 'success'},
{name: 'test5', conclusion: 'failure'},
{name: 'test6', conclusion: 'success'},
{name: 'test7', conclusion: 'cancelled'},
{name: 'test8', conclusion: 'skipped'},
{name: 'test9', conclusion: 'test1'},
{name: 'test9', conclusion: 'test2'},
{name: 'test9', conclusion: 'test3'},
{ name: 'test1', conclusion: 'cancelled' },
{ name: 'test2', conclusion: 'neutral' },
{ name: 'test3', conclusion: 'failure' },
{ name: 'test4', conclusion: 'success' },
{ name: 'test5', conclusion: 'failure' },
{ name: 'test6', conclusion: 'success' },
{ name: 'test7', conclusion: 'cancelled' },
{ name: 'test8', conclusion: 'skipped' },
{ name: 'test9', conclusion: 'test1' },
{ name: 'test9', conclusion: 'test2' },
{ name: 'test9', conclusion: 'test3' },
])).toEqual([
'cancelled',
'neutral',
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('execute', () => {
'::set-output name=conclusion::success',
]);
exportVariableCalledWith(mockEnv, [
{name: 'WORKFLOW_CONCLUSION', val: 'success'},
{ name: 'WORKFLOW_CONCLUSION', val: 'success' },
]);
});

Expand All @@ -150,7 +150,7 @@ describe('execute', () => {
'::set-output name=conclusion::cancelled',
]);
exportVariableCalledWith(mockEnv, [
{name: 'WORKFLOW_CONCLUSION', val: 'cancelled'},
{ name: 'WORKFLOW_CONCLUSION', val: 'cancelled' },
]);
});

Expand All @@ -173,7 +173,7 @@ describe('execute', () => {
'::set-output name=conclusion::failure',
]);
exportVariableCalledWith(mockEnv, [
{name: 'WORKFLOW_CONCLUSION', val: 'failure'},
{ name: 'WORKFLOW_CONCLUSION', val: 'failure' },
]);
});

Expand All @@ -196,7 +196,7 @@ describe('execute', () => {
'::set-output name=conclusion::skipped',
]);
exportVariableCalledWith(mockEnv, [
{name: 'WORKFLOW_CONCLUSION', val: 'skipped'},
{ name: 'WORKFLOW_CONCLUSION', val: 'skipped' },
]);
});

Expand Down
18 changes: 9 additions & 9 deletions src/process.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type {Context} from '@actions/github/lib/context';
import type {Octokit} from '@technote-space/github-action-helper/dist/types';
import type {Logger} from '@technote-space/github-action-log-helper';
import {setOutput, exportVariable, getInput} from '@actions/core';
import {Utils} from '@technote-space/github-action-helper';
import {components} from '@octokit/openapi-types';
import {CONCLUSIONS} from './constant';
import type { Context } from '@actions/github/lib/context';
import type { Octokit } from '@technote-space/github-action-helper/dist/types';
import type { Logger } from '@technote-space/github-action-log-helper';
import { setOutput, exportVariable, getInput } from '@actions/core';
import { Utils } from '@technote-space/github-action-helper';
import { components } from '@octokit/openapi-types';
import { CONCLUSIONS } from './constant';

type ActionsListJobsForWorkflowRunResponseData = components['schemas']['job'];

Expand All @@ -22,8 +22,8 @@ export const getJobConclusions = (jobs: Array<{ name: string; conclusion: string
Object.values(
jobs
.filter(job => null !== job.conclusion)
.map(job => ({name: job.name, conclusion: String(job.conclusion)}))
.reduce((acc, job) => ({...acc, [job.name]: job.conclusion}), {}),
.map(job => ({ name: job.name, conclusion: String(job.conclusion) }))
.reduce((acc, job) => ({ ...acc, [job.name]: job.conclusion }), {}),
),
);

Expand Down

0 comments on commit 744bb25

Please sign in to comment.