Skip to content

Commit 567531d

Browse files
authored
Merge pull request #212 from crazy-max/esm
switch to ESM and update config/test wiring
2 parents 206b75d + 9ba91ce commit 567531d

17 files changed

+1339
-3581
lines changed

.prettierrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
"singleQuote": true,
77
"trailingComma": "none",
88
"bracketSpacing": false,
9-
"arrowParens": "avoid",
10-
"parser": "typescript"
9+
"arrowParens": "avoid"
1110
}

__tests__/context.test.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {beforeEach, describe, expect, test} from '@jest/globals';
1+
import {beforeEach, describe, expect, test} from 'vitest';
22
import * as os from 'os';
33
import * as path from 'path';
44

5-
import * as context from '../src/context';
5+
import * as context from '../src/context.js';
66

77
describe('getInputs', () => {
88
beforeEach(() => {
@@ -15,7 +15,7 @@ describe('getInputs', () => {
1515
});
1616

1717
// prettier-ignore
18-
test.each([
18+
const cases: [number, Map<string, string>, context.Inputs][] = [
1919
[
2020
0,
2121
new Map<string, string>([
@@ -35,7 +35,7 @@ describe('getInputs', () => {
3535
setHost: false,
3636
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
3737
githubToken: '',
38-
} as context.Inputs
38+
}
3939
],
4040
[
4141
1,
@@ -59,7 +59,7 @@ describe('getInputs', () => {
5959
setHost: false,
6060
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
6161
githubToken: '',
62-
} as context.Inputs
62+
}
6363
],
6464
[
6565
2,
@@ -79,7 +79,7 @@ describe('getInputs', () => {
7979
setHost: true,
8080
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
8181
githubToken: '',
82-
} as context.Inputs
82+
}
8383
],
8484
[
8585
3,
@@ -101,7 +101,7 @@ describe('getInputs', () => {
101101
setHost: false,
102102
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
103103
githubToken: '',
104-
} as context.Inputs
104+
}
105105
],
106106
[
107107
4,
@@ -121,7 +121,7 @@ describe('getInputs', () => {
121121
setHost: false,
122122
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
123123
githubToken: '',
124-
} as context.Inputs
124+
}
125125
],
126126
[
127127
5,
@@ -142,7 +142,7 @@ describe('getInputs', () => {
142142
rootless: false,
143143
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
144144
githubToken: '',
145-
} as context.Inputs
145+
}
146146
],
147147
[
148148
6,
@@ -163,7 +163,7 @@ describe('getInputs', () => {
163163
rootless: false,
164164
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
165165
githubToken: '',
166-
} as context.Inputs
166+
}
167167
],
168168
[
169169
7,
@@ -183,7 +183,7 @@ describe('getInputs', () => {
183183
rootless: false,
184184
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
185185
githubToken: '',
186-
} as context.Inputs
186+
}
187187
],
188188
[
189189
8,
@@ -203,7 +203,7 @@ describe('getInputs', () => {
203203
rootless: true,
204204
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
205205
githubToken: '',
206-
} as context.Inputs
206+
}
207207
],
208208
[
209209
9,
@@ -226,10 +226,11 @@ describe('getInputs', () => {
226226
setHost: false,
227227
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
228228
githubToken: '',
229-
} as context.Inputs
229+
}
230230
],
231-
])(
232-
'[%d] given %p as inputs, returns %p',
231+
];
232+
test.each(cases)(
233+
'[%d] given %o as inputs, returns %o',
233234
async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {
234235
inputs.forEach((value: string, name: string) => {
235236
setInput(name, value);

__tests__/setup.unit.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import fs from 'node:fs';
2+
import os from 'node:os';
3+
import path from 'node:path';
4+
5+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-setup-docker-action-'));
6+
7+
process.env = Object.assign({}, process.env, {
8+
TEMP: tmpDir,
9+
GITHUB_REPOSITORY: 'docker/setup-docker-action',
10+
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
11+
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
12+
});

dev.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ FROM deps AS test
7474
RUN --mount=type=bind,target=.,rw \
7575
--mount=type=cache,target=/src/.yarn/cache \
7676
--mount=type=cache,target=/src/node_modules \
77-
yarn run test --coverage --coverageDirectory=/tmp/coverage
77+
yarn run test --coverage --coverage.reportsDirectory=/tmp/coverage
7878

7979
FROM scratch AS test-coverage
8080
COPY --from=test /tmp/coverage /

dist/index.js

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import {defineConfig} from 'eslint/config';
2+
import js from '@eslint/js';
3+
import tseslint from '@typescript-eslint/eslint-plugin';
4+
import vitest from '@vitest/eslint-plugin';
5+
import globals from 'globals';
6+
import eslintConfigPrettier from 'eslint-config-prettier/flat';
7+
import eslintPluginPrettier from 'eslint-plugin-prettier';
8+
9+
export default defineConfig([
10+
{
11+
ignores: ['.yarn/**/*', 'coverage/**/*', 'dist/**/*']
12+
},
13+
js.configs.recommended,
14+
...tseslint.configs['flat/recommended'],
15+
eslintConfigPrettier,
16+
{
17+
languageOptions: {
18+
globals: {
19+
...globals.node
20+
}
21+
}
22+
},
23+
{
24+
files: ['__tests__/**'],
25+
...vitest.configs.recommended,
26+
languageOptions: {
27+
globals: {
28+
...globals.node,
29+
...vitest.environments.env.globals
30+
}
31+
},
32+
rules: {
33+
...vitest.configs.recommended.rules,
34+
'vitest/no-conditional-expect': 'error',
35+
'vitest/no-disabled-tests': 0
36+
}
37+
},
38+
{
39+
plugins: {
40+
prettier: eslintPluginPrettier
41+
},
42+
rules: {
43+
'prettier/prettier': 'error',
44+
'@typescript-eslint/no-require-imports': [
45+
'error',
46+
{
47+
allowAsImport: true
48+
}
49+
]
50+
}
51+
}
52+
]);

0 commit comments

Comments
 (0)