Compare commits

..

9 Commits

Author SHA1 Message Date
CrazyMax
de22160057
Merge 918a0ca878 into a5609cb39f 2023-09-08 07:36:25 +00:00
CrazyMax
918a0ca878
chore: node 20 as default runtime
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-08 09:36:17 +02:00
CrazyMax
a91f9b84f0
chore: update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-08 09:36:16 +02:00
CrazyMax
4705740e75
chore: fix license
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-08 09:36:16 +02:00
CrazyMax
b8db742e11
test: fix tests after toolkit update
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-08 09:36:16 +02:00
CrazyMax
36287a2763
vendor: bump @docker/actions-toolkit from 0.7.1 to 0.12.0
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-08 09:36:16 +02:00
CrazyMax
d39729083f
dev: remove unneeded binaries
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-08 09:36:16 +02:00
CrazyMax
36c0d2a427
chore: update dev dependencies
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-08 09:36:16 +02:00
CrazyMax
92049ffdaa
chore: update to node 20
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-08 09:36:15 +02:00
4 changed files with 13 additions and 77 deletions

3
.eslintignore Normal file
View File

@ -0,0 +1,3 @@
/dist/**
/coverage/**
/node_modules/**

View File

@ -1,65 +0,0 @@
import {expect, jest, test} from '@jest/globals';
import osm = require('os');
import {main} from '../src/main';
import * as docker from '../src/docker';
import * as stateHelper from '../src/state-helper';
test('errors without username and password', async () => {
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
process.env['INPUT_LOGOUT'] = 'true'; // default value
await expect(main()).rejects.toThrow(new Error('Username and password required'));
});
test('successful with username and password', async () => {
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(() => Promise.resolve());
const username = 'dbowie';
process.env[`INPUT_USERNAME`] = username;
const password = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;
const ecr = 'auto';
process.env['INPUT_ECR'] = ecr;
const logout = false;
process.env['INPUT_LOGOUT'] = String(logout);
await main();
expect(setRegistrySpy).toHaveBeenCalledWith('');
expect(setLogoutSpy).toHaveBeenCalledWith(logout);
expect(dockerSpy).toHaveBeenCalledWith('', username, password, ecr);
});
test('calls docker login', async () => {
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(() => Promise.resolve());
const username = 'dbowie';
process.env[`INPUT_USERNAME`] = username;
const password = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;
const registry = 'ghcr.io';
process.env[`INPUT_REGISTRY`] = registry;
const ecr = 'auto';
process.env['INPUT_ECR'] = ecr;
const logout = true;
process.env['INPUT_LOGOUT'] = String(logout);
await main();
expect(setRegistrySpy).toHaveBeenCalledWith(registry);
expect(setLogoutSpy).toHaveBeenCalledWith(logout);
expect(dockerSpy).toHaveBeenCalledWith(registry, username, password, ecr);
});

View File

@ -65,7 +65,7 @@ ENV RUNNER_TEMP=/tmp/github_runner
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run test --coverageDirectory=/tmp/coverage
yarn run test --coverage --coverageDirectory=/tmp/coverage
FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /

View File

@ -4,9 +4,13 @@
"main": "lib/main.js",
"scripts": {
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
"lint": "eslint src/**/*.ts __tests__/**/*.ts",
"format": "eslint --fix src/**/*.ts __tests__/**/*.ts",
"test": "jest --coverage",
"lint": "yarn run prettier && yarn run eslint",
"format": "yarn run prettier:fix && yarn run eslint:fix",
"eslint": "eslint --max-warnings=0 .",
"eslint:fix": "eslint --fix .",
"prettier": "prettier --check \"./**/*.ts\"",
"prettier:fix": "prettier --write \"./**/*.ts\"",
"test": "jest",
"all": "yarn run build && yarn run format && yarn test"
},
"repository": {
@ -18,14 +22,8 @@
"docker",
"login"
],
"author": "Docker",
"contributors": [
{
"name": "CrazyMax",
"url": "https://crazymax.dev"
}
],
"license": "MIT",
"author": "Docker Inc.",
"license": "Apache-2.0",
"dependencies": {
"@actions/core": "^1.10.0",
"@aws-sdk/client-ecr": "^3.398.0",