Skip to content

Commit 20111c6

Browse files
authored
Merge pull request #130 from crazy-max/update-dev
chore: update dev dependencies and workflow
2 parents c62171c + 2e23606 commit 20111c6

21 files changed

+2157
-16299
lines changed

.eslintrc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es2021": true,
5+
"jest/globals": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended",
10+
"plugin:jest/recommended",
11+
"plugin:prettier/recommended"
12+
],
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"ecmaVersion": "latest",
16+
"sourceType": "module"
17+
},
18+
"plugins": [
19+
"@typescript-eslint",
20+
"jest",
21+
"prettier"
22+
]
23+
}

__tests__/buildx.test.ts

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {describe, expect, it, jest, test} from '@jest/globals';
12
import * as fs from 'fs';
23
import * as os from 'os';
34
import * as path from 'path';
@@ -21,35 +22,21 @@ jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
2122
});
2223

2324
describe('isAvailable', () => {
24-
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
25+
const execSpy = jest.spyOn(exec, 'getExecOutput');
2526
buildx.isAvailable();
2627

28+
// eslint-disable-next-line jest/no-standalone-expect
2729
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
2830
silent: true,
2931
ignoreReturnCode: true
3032
});
3133
});
3234

3335
describe('getVersion', () => {
34-
async function isDaemonRunning() {
35-
return await exec
36-
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
37-
ignoreReturnCode: true,
38-
silent: true
39-
})
40-
.then(res => {
41-
return !res.stdout.trim().includes(' ') && res.exitCode == 0;
42-
});
43-
}
44-
(isDaemonRunning() ? it : it.skip)(
45-
'valid',
46-
async () => {
47-
const version = await buildx.getVersion();
48-
console.log(`version: ${version}`);
49-
expect(semver.valid(version)).not.toBeNull();
50-
},
51-
100000
52-
);
36+
it('valid', async () => {
37+
const version = await buildx.getVersion();
38+
expect(semver.valid(version)).not.toBeNull();
39+
});
5340
});
5441

5542
describe('parseVersion', () => {
@@ -74,54 +61,41 @@ describe('satisfies', () => {
7461
});
7562

7663
describe('inspect', () => {
77-
async function isDaemonRunning() {
78-
return await exec
79-
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
80-
ignoreReturnCode: true,
81-
silent: true
82-
})
83-
.then(res => {
84-
return !res.stdout.trim().includes(' ') && res.exitCode == 0;
85-
});
86-
}
87-
(isDaemonRunning() ? it : it.skip)(
88-
'valid',
89-
async () => {
90-
const builder = await buildx.inspect('');
91-
console.log('builder', builder);
92-
expect(builder).not.toBeUndefined();
93-
expect(builder.name).not.toEqual('');
94-
expect(builder.driver).not.toEqual('');
95-
expect(builder.node_platforms).not.toEqual('');
96-
},
97-
100000
98-
);
64+
it('valid', async () => {
65+
const builder = await buildx.inspect('');
66+
expect(builder).not.toBeUndefined();
67+
expect(builder.name).not.toEqual('');
68+
expect(builder.driver).not.toEqual('');
69+
expect(builder.node_platforms).not.toEqual('');
70+
}, 100000);
9971
});
10072

10173
describe('build', () => {
10274
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
75+
76+
// eslint-disable-next-line jest/no-disabled-tests
10377
it.skip('builds refs/pull/648/head', async () => {
10478
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#refs/pull/648/head', tmpDir);
105-
console.log(buildxBin);
10679
expect(fs.existsSync(buildxBin)).toBe(true);
10780
}, 100000);
81+
82+
// eslint-disable-next-line jest/no-disabled-tests
10883
it.skip('builds 67bd6f4dc82a9cd96f34133dab3f6f7af803bb14', async () => {
10984
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#67bd6f4dc82a9cd96f34133dab3f6f7af803bb14', tmpDir);
110-
console.log(buildxBin);
11185
expect(fs.existsSync(buildxBin)).toBe(true);
11286
}, 100000);
11387
});
11488

11589
describe('install', () => {
11690
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
91+
11792
it('acquires v0.4.1 version of buildx', async () => {
11893
const buildxBin = await buildx.install('v0.4.1', tmpDir);
119-
console.log(buildxBin);
12094
expect(fs.existsSync(buildxBin)).toBe(true);
12195
}, 100000);
96+
12297
it('acquires latest version of buildx', async () => {
12398
const buildxBin = await buildx.install('latest', tmpDir);
124-
console.log(buildxBin);
12599
expect(fs.existsSync(buildxBin)).toBe(true);
126100
}, 100000);
127101
});
@@ -148,13 +122,11 @@ describe('getConfig', () => {
148122
config = await buildx.getConfigInline(val);
149123
}
150124
expect(true).toBe(!invalid);
151-
console.log(`config: ${config}`);
152125
expect(config).toEqual(`${tmpNameSync}`);
153-
const configValue = await fs.readFileSync(tmpNameSync, 'utf-8');
154-
console.log(`configValue: ${configValue}`);
126+
const configValue = fs.readFileSync(tmpNameSync, 'utf-8');
155127
expect(configValue).toEqual(exValue);
156128
} catch (err) {
157-
console.log(err);
129+
// eslint-disable-next-line jest/no-conditional-expect
158130
expect(true).toBe(invalid);
159131
}
160132
});

__tests__/context.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
12
import * as fs from 'fs';
23
import * as os from 'os';
34
import * as path from 'path';
@@ -19,63 +20,54 @@ describe('getInputList', () => {
1920
it('handles single line correctly', async () => {
2021
await setInput('foo', 'bar');
2122
const res = await context.getInputList('foo');
22-
console.log(res);
2323
expect(res).toEqual(['bar']);
2424
});
2525

2626
it('handles multiple lines correctly', async () => {
2727
setInput('foo', 'bar\nbaz');
2828
const res = await context.getInputList('foo');
29-
console.log(res);
3029
expect(res).toEqual(['bar', 'baz']);
3130
});
3231

3332
it('remove empty lines correctly', async () => {
3433
setInput('foo', 'bar\n\nbaz');
3534
const res = await context.getInputList('foo');
36-
console.log(res);
3735
expect(res).toEqual(['bar', 'baz']);
3836
});
3937

4038
it('handles comma correctly', async () => {
4139
setInput('foo', 'bar,baz');
4240
const res = await context.getInputList('foo');
43-
console.log(res);
4441
expect(res).toEqual(['bar', 'baz']);
4542
});
4643

4744
it('remove empty result correctly', async () => {
4845
setInput('foo', 'bar,baz,');
4946
const res = await context.getInputList('foo');
50-
console.log(res);
5147
expect(res).toEqual(['bar', 'baz']);
5248
});
5349

5450
it('handles different new lines correctly', async () => {
5551
setInput('foo', 'bar\r\nbaz');
5652
const res = await context.getInputList('foo');
57-
console.log(res);
5853
expect(res).toEqual(['bar', 'baz']);
5954
});
6055

6156
it('handles different new lines and comma correctly', async () => {
6257
setInput('foo', 'bar\r\nbaz,bat');
6358
const res = await context.getInputList('foo');
64-
console.log(res);
6559
expect(res).toEqual(['bar', 'baz', 'bat']);
6660
});
6761

6862
it('handles multiple lines and ignoring comma correctly', async () => {
6963
setInput('driver-opts', 'image=moby/buildkit:master\nnetwork=host');
7064
const res = await context.getInputList('driver-opts', true);
71-
console.log(res);
7265
expect(res).toEqual(['image=moby/buildkit:master', 'network=host']);
7366
});
7467

7568
it('handles different new lines and ignoring comma correctly', async () => {
7669
setInput('driver-opts', 'image=moby/buildkit:master\r\nnetwork=host');
7770
const res = await context.getInputList('driver-opts', true);
78-
console.log(res);
7971
expect(res).toEqual(['image=moby/buildkit:master', 'network=host']);
8072
});
8173
});
@@ -95,19 +87,22 @@ describe('asyncForEach', () => {
9587

9688
describe('setOutput', () => {
9789
beforeEach(() => {
98-
process.stdout.write = jest.fn();
90+
process.stdout.write = jest.fn() as typeof process.stdout.write;
9991
});
10092

93+
// eslint-disable-next-line jest/expect-expect
10194
it('setOutput produces the correct command', () => {
10295
context.setOutput('some output', 'some value');
10396
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
10497
});
10598

99+
// eslint-disable-next-line jest/expect-expect
106100
it('setOutput handles bools', () => {
107101
context.setOutput('some output', false);
108102
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
109103
});
110104

105+
// eslint-disable-next-line jest/expect-expect
111106
it('setOutput handles numbers', () => {
112107
context.setOutput('some output', 1.01);
113108
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);

__tests__/git.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import {describe, expect, it} from '@jest/globals';
12
import * as git from '../src/git';
23

34
describe('git', () => {
45
it('returns git remote ref', async () => {
56
const ref: string = await git.getRemoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head');
6-
console.log(`ref: ${ref}`);
77
expect(ref).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
88
});
99
});

__tests__/github.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
import {describe, expect, it} from '@jest/globals';
12
import * as github from '../src/github';
23

34
describe('github', () => {
45
it('returns latest buildx GitHub release', async () => {
56
const release = await github.getRelease('latest');
6-
console.log(release);
77
expect(release).not.toBeNull();
88
expect(release?.tag_name).not.toEqual('');
99
});
1010

1111
it('returns v0.2.2 buildx GitHub release', async () => {
1212
const release = await github.getRelease('v0.2.2');
13-
console.log(release);
1413
expect(release).not.toBeNull();
1514
expect(release?.tag_name).toEqual('v0.2.2');
1615
});

__tests__/util.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {describe, expect, test} from '@jest/globals';
12
import * as util from '../src/util';
23

34
describe('isValidUrl', () => {

hack/build.Dockerfile renamed to dev.Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# syntax=docker/dockerfile:1.3-labs
1+
# syntax=docker/dockerfile:1
22

3-
ARG NODE_VERSION
4-
ARG DOCKER_VERSION=20.10.10
5-
ARG BUILDX_VERSION=0.7.0
3+
ARG NODE_VERSION=12
4+
ARG DOCKER_VERSION=20.10.13
5+
ARG BUILDX_VERSION=0.8.1
66

77
FROM node:${NODE_VERSION}-alpine AS base
88
RUN apk add --no-cache cpio findutils git
@@ -57,10 +57,10 @@ RUN --mount=type=bind,target=.,rw \
5757
FROM scratch AS format-update
5858
COPY --from=format /out /
5959

60-
FROM deps AS format-validate
60+
FROM deps AS lint
6161
RUN --mount=type=bind,target=.,rw \
6262
--mount=type=cache,target=/src/node_modules \
63-
yarn run format-check
63+
yarn run lint
6464

6565
FROM docker:${DOCKER_VERSION} as docker
6666
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx

0 commit comments

Comments
 (0)