Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update dev dependencies and workflow #170

Merged
merged 2 commits into from Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
10 changes: 5 additions & 5 deletions dev.Dockerfile
@@ -1,8 +1,8 @@
# syntax=docker/dockerfile:1.3-labs
# syntax=docker/dockerfile:1

ARG NODE_VERSION=12
ARG DOCKER_VERSION=20.10.10
ARG BUILDX_VERSION=0.7.0
ARG DOCKER_VERSION=20.10.13
ARG BUILDX_VERSION=0.8.1

FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git
Expand Down 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