Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

24 changes: 0 additions & 24 deletions .eslintrc.json

This file was deleted.

3 changes: 1 addition & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
"arrowParens": "avoid"
}
28 changes: 15 additions & 13 deletions __tests__/aws.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
import {beforeEach, describe, expect, test, vi} from 'vitest';
import {AuthorizationData} from '@aws-sdk/client-ecr';

import * as aws from '../src/aws';
import * as aws from '../src/aws.js';

describe('isECR', () => {
test.each([
Expand Down Expand Up @@ -65,26 +65,28 @@ describe('getAccountIDs', () => {
});
});

const mockEcrGetAuthToken = jest.fn();
const mockEcrPublicGetAuthToken = jest.fn();
jest.mock('@aws-sdk/client-ecr', () => {
const mockEcrGetAuthToken = vi.fn();
const mockEcrPublicGetAuthToken = vi.fn();
vi.mock('@aws-sdk/client-ecr', () => {
class ECR {
getAuthorizationToken = mockEcrGetAuthToken;
}
return {
ECR: jest.fn(() => ({
getAuthorizationToken: mockEcrGetAuthToken
}))
ECR
};
});
jest.mock('@aws-sdk/client-ecr-public', () => {
vi.mock('@aws-sdk/client-ecr-public', () => {
class ECRPUBLIC {
getAuthorizationToken = mockEcrPublicGetAuthToken;
}
return {
ECRPUBLIC: jest.fn(() => ({
getAuthorizationToken: mockEcrPublicGetAuthToken
}))
ECRPUBLIC
};
});

describe('getRegistriesData', () => {
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
delete process.env.AWS_ACCOUNT_IDS;
});
// prettier-ignore
Expand Down
4 changes: 2 additions & 2 deletions __tests__/context.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {expect, test} from '@jest/globals';
import {expect, test} from 'vitest';

import {getInputs} from '../src/context';
import {getInputs} from '../src/context.js';

test('with password and username getInputs does not throw error', async () => {
process.env['INPUT_USERNAME'] = 'dbowie';
Expand Down
10 changes: 5 additions & 5 deletions __tests__/docker.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {expect, jest, test} from '@jest/globals';
import {expect, test, vi} from 'vitest';
import * as path from 'path';

import {loginStandard, logout} from '../src/docker';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';

import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {loginStandard, logout} from '../src/docker.js';

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(Docker, 'getExecOutput').mockImplementation(async () => {
const execSpy = vi.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
return {
exitCode: expect.any(Number),
stdout: expect.any(Function),
Expand Down Expand Up @@ -40,7 +40,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(Docker, 'getExecOutput').mockImplementation(async () => {
const execSpy = vi.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
return {
exitCode: expect.any(Number),
stdout: expect.any(Function),
Expand Down
12 changes: 12 additions & 0 deletions __tests__/setup.unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-login-action-'));

process.env = Object.assign({}, process.env, {
TEMP: tmpDir,
GITHUB_REPOSITORY: 'docker/login-action',
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
});
25 changes: 17 additions & 8 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
ARG NODE_VERSION=20

FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git
RUN apk add --no-cache cpio findutils git rsync
WORKDIR /src
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache <<EOT
set -e
corepack enable
yarn --version
yarn config set --home enableTelemetry 0
Expand Down Expand Up @@ -34,18 +35,27 @@ RUN --mount=type=bind,target=.,rw <<EOT
EOT

FROM deps AS build
RUN --mount=type=bind,target=.,rw \
RUN --mount=target=/context \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn run build && mkdir /out && cp -Rf dist /out/
--mount=type=cache,target=/src/node_modules <<EOT
set -e
rsync -a /context/. .
rm -rf dist
yarn run build
mkdir /out
cp -r dist /out
EOT

FROM scratch AS build-update
COPY --from=build /out /

FROM build AS build-validate
RUN --mount=type=bind,target=.,rw <<EOT
RUN --mount=target=/context \
--mount=target=.,type=tmpfs <<EOT
set -e
rsync -a /context/. .
git add -A
rm -rf dist
cp -rf /out/* .
if [ -n "$(git status --porcelain -- dist)" ]; then
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
Expand All @@ -58,8 +68,7 @@ FROM deps AS format
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn run format \
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
yarn run format && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out

FROM scratch AS format-update
COPY --from=format /out /
Expand All @@ -76,7 +85,7 @@ ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn run test --coverage --coverageDirectory=/tmp/coverage
yarn run test --coverage --coverage.reportsDirectory=/tmp/coverage

FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /
9 changes: 4 additions & 5 deletions dist/136.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/136.index.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions dist/360.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/360.index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions dist/443.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/443.index.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions dist/566.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/566.index.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions dist/579.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading