Merge pull request #48 from crazy-max/nits

fix some nits to be consistent across actions
This commit is contained in:
CrazyMax 2026-03-02 10:41:10 +01:00 committed by GitHub
commit 2dd6325a67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 39 deletions

View file

@ -32,7 +32,7 @@ describe('getInputs', () => {
}); });
// prettier-ignore // prettier-ignore
test.each([ const cases: [number, Map<string, string>, context.Inputs][] = [
[ [
0, 0,
new Map<string, string>([ new Map<string, string>([
@ -41,7 +41,7 @@ describe('getInputs', () => {
{ {
version: '', version: '',
cacheBinary: true, cacheBinary: true,
} as context.Inputs }
], ],
[ [
1, 1,
@ -52,18 +52,16 @@ describe('getInputs', () => {
{ {
version: 'v2.32.4', version: 'v2.32.4',
cacheBinary: false cacheBinary: false
} as context.Inputs }
] ]
])( ];
'[%d] given %p as inputs, returns %p', test.each(cases)('[%d] given %o as inputs, returns %o', async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {
async (num: number, inputs: Map<string, string>, expected: context.Inputs) => { inputs.forEach((value: string, name: string) => {
inputs.forEach((value: string, name: string) => { setInput(name, value);
setInput(name, value); });
}); const res = await context.getInputs();
const res = await context.getInputs(); expect(res).toEqual(expected);
expect(res).toEqual(expected); });
}
);
}); });
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67 // See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67

View file

@ -2,7 +2,7 @@ import fs from 'node:fs';
import os from 'node:os'; import os from 'node:os';
import path from 'node:path'; import path from 'node:path';
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')); const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-setup-compose-action-'));
process.env = Object.assign({}, process.env, { process.env = Object.assign({}, process.env, {
TEMP: tmpDir, TEMP: tmpDir,

View file

@ -3,10 +3,11 @@
ARG NODE_VERSION=20 ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-alpine AS base 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 WORKDIR /src
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache <<EOT --mount=type=cache,target=/src/.yarn/cache <<EOT
set -e
corepack enable corepack enable
yarn --version yarn --version
yarn config set --home enableTelemetry 0 yarn config set --home enableTelemetry 0
@ -34,18 +35,27 @@ RUN --mount=type=bind,target=.,rw <<EOT
EOT EOT
FROM deps AS build 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/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules <<EOT
yarn run build && mkdir /out && cp -Rf dist /out/ set -e
rsync -a /context/. .
rm -rf dist
yarn run build
mkdir /out
cp -r dist /out
EOT
FROM scratch AS build-update FROM scratch AS build-update
COPY --from=build /out / COPY --from=build /out /
FROM build AS build-validate FROM build AS build-validate
RUN --mount=type=bind,target=.,rw <<EOT RUN --mount=target=/context \
--mount=target=.,type=tmpfs <<EOT
set -e set -e
rsync -a /context/. .
git add -A git add -A
rm -rf dist
cp -rf /out/* . cp -rf /out/* .
if [ -n "$(git status --porcelain -- dist)" ]; then if [ -n "$(git status --porcelain -- dist)" ]; then
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"' echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
@ -58,8 +68,7 @@ FROM deps AS format
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \ --mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run format \ yarn run format && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
FROM scratch AS format-update FROM scratch AS format-update
COPY --from=format /out / COPY --from=format /out /

View file

@ -3,7 +3,6 @@
"module": "nodenext", "module": "nodenext",
"moduleResolution": "nodenext", "moduleResolution": "nodenext",
"esModuleInterop": true, "esModuleInterop": true,
"strict": true,
"newLine": "lf", "newLine": "lf",
"outDir": "./lib", "outDir": "./lib",
"rootDir": "./src", "rootDir": "./src",

View file

@ -1,19 +1,3 @@
/**
* Copyright 2026 actions-toolkit authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {defineConfig} from 'vitest/config'; import {defineConfig} from 'vitest/config';
export default defineConfig({ export default defineConfig({
@ -26,7 +10,7 @@ export default defineConfig({
provider: 'v8', provider: 'v8',
reporter: ['clover'], reporter: ['clover'],
include: ['src/**/*.ts'], include: ['src/**/*.ts'],
exclude: ['src/**/main.ts', '__tests__/**', 'dist/**'] exclude: ['src/**/main.ts']
} }
} }
}); });