Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dev: switch to eslint
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
CrazyMax committed Mar 21, 2022
1 parent 56f72fc commit 0828e0e
Show file tree
Hide file tree
Showing 16 changed files with 10,227 additions and 32,445 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,23 @@
{
"env": {
"node": true,
"es2021": true,
"jest/globals": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"jest",
"prettier"
]
}
10 changes: 6 additions & 4 deletions __tests__/docker.test.ts
Expand Up @@ -6,6 +6,7 @@ import * as exec from '@actions/exec';
process.env['RUNNER_TEMP'] = path.join(__dirname, 'runner');

test('loginStandard calls exec', async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
Expand All @@ -15,9 +16,9 @@ test('loginStandard calls exec', async () => {
};
});

const username: string = 'dbowie';
const password: string = 'groundcontrol';
const registry: string = 'https://ghcr.io';
const username = 'dbowie';
const password = 'groundcontrol';
const registry = 'https://ghcr.io';

await loginStandard(registry, username, password);

Expand All @@ -29,6 +30,7 @@ test('loginStandard calls exec', async () => {
});

test('logout calls exec', async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
Expand All @@ -38,7 +40,7 @@ test('logout calls exec', async () => {
};
});

const registry: string = 'https://ghcr.io';
const registry = 'https://ghcr.io';

await logout(registry);

Expand Down
25 changes: 12 additions & 13 deletions __tests__/main.test.ts
Expand Up @@ -8,8 +8,7 @@ import * as stateHelper from '../src/state-helper';
import * as core from '@actions/core';

test('errors without username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');

jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
process.env['INPUT_LOGOUT'] = 'true'; // default value
const coreSpy = jest.spyOn(core, 'setFailed');

Expand All @@ -18,21 +17,21 @@ test('errors without username and password', async () => {
});

test('successful with username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy = jest.spyOn(docker, 'login').mockImplementation(jest.fn());

const username: string = 'dbowie';
const username = 'dbowie';
process.env[`INPUT_USERNAME`] = username;

const password: string = 'groundcontrol';
const password = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;

const ecr: string = 'auto';
const ecr = 'auto';
process.env['INPUT_ECR'] = ecr;

const logout: boolean = false;
const logout = false;
process.env['INPUT_LOGOUT'] = String(logout);

await run();
Expand All @@ -43,25 +42,25 @@ test('successful with username and password', async () => {
});

test('calls docker login', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(jest.fn());

const username: string = 'dbowie';
const username = 'dbowie';
process.env[`INPUT_USERNAME`] = username;

const password: string = 'groundcontrol';
const password = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;

const registry: string = 'ghcr.io';
const registry = 'ghcr.io';
process.env[`INPUT_REGISTRY`] = registry;

const ecr: string = 'auto';
const ecr = 'auto';
process.env['INPUT_ECR'] = ecr;

const logout: boolean = true;
const logout = true;
process.env['INPUT_LOGOUT'] = String(logout);

await run();
Expand Down
4 changes: 2 additions & 2 deletions dev.Dockerfile
Expand Up @@ -57,10 +57,10 @@ RUN --mount=type=bind,target=.,rw \
FROM scratch AS format-update
COPY --from=format /out /

FROM deps AS format-validate
FROM deps AS lint
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run format-check
yarn run lint

FROM docker:${DOCKER_VERSION} as docker
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx
Expand Down

0 comments on commit 0828e0e

Please sign in to comment.