Skip to content

Commit 75c825a

Browse files
authored
Merge pull request #571 from crazy-max/update-dev
chore: update dev dependencies and workflow
2 parents ac9327e + 5f7b938 commit 75c825a

17 files changed

+2747
-29670
lines changed

.eslintrc.json

+23
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+
}

.github/workflows/virtual-env.yml

+18
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,33 @@ jobs:
1919
-
2020
name: File system
2121
run: df -ah
22+
-
23+
name: Mounts
24+
run: mount
25+
-
26+
name: Node info
27+
run: node -p process
28+
-
29+
name: NPM version
30+
run: npm version
2231
-
2332
name: List install packages
2433
run: apt list --installed
34+
-
35+
name: Docker daemon conf
36+
run: |
37+
cat /etc/docker/daemon.json
2538
-
2639
name: Docker info
2740
run: docker info
2841
-
2942
name: Docker version
3043
run: docker version
44+
-
45+
name: Cgroups
46+
run: |
47+
sudo apt-get install -y cgroup-tools
48+
lscgroup
3149
-
3250
name: buildx version
3351
run: docker buildx version

__tests__/buildx.test.ts

+19-76
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import {describe, expect, it, jest, test} from '@jest/globals';
12
import * as fs from 'fs';
23
import * as path from 'path';
34
import * as semver from 'semver';
45
import * as exec from '@actions/exec';
5-
66
import * as buildx from '../src/buildx';
77
import * as context from '../src/context';
88

@@ -53,94 +53,36 @@ describe('getDigest', () => {
5353
});
5454

5555
describe('isLocalOrTarExporter', () => {
56-
// prettier-ignore
5756
test.each([
58-
[
59-
[
60-
'type=registry,ref=user/app',
61-
],
62-
false
63-
],
64-
[
65-
[
66-
'type=docker',
67-
],
68-
false
69-
],
70-
[
71-
[
72-
'type=local,dest=./release-out'
73-
],
74-
true
75-
],
76-
[
77-
[
78-
'type=tar,dest=/tmp/image.tar'
79-
],
80-
true
81-
],
82-
[
83-
[
84-
'type=docker',
85-
'type=tar,dest=/tmp/image.tar'
86-
],
87-
true
88-
],
89-
[
90-
[
91-
'"type=tar","dest=/tmp/image.tar"'
92-
],
93-
true
94-
],
95-
[
96-
[
97-
'" type= local" , dest=./release-out'
98-
],
99-
true
100-
],
101-
[
102-
[
103-
'.'
104-
],
105-
true
106-
],
107-
])(
108-
'given %p returns %p',
109-
async (outputs: Array<string>, expected: boolean) => {
110-
expect(buildx.isLocalOrTarExporter(outputs)).toEqual(expected);
111-
}
112-
);
57+
[['type=registry,ref=user/app'], false],
58+
[['type=docker'], false],
59+
[['type=local,dest=./release-out'], true],
60+
[['type=tar,dest=/tmp/image.tar'], true],
61+
[['type=docker', 'type=tar,dest=/tmp/image.tar'], true],
62+
[['"type=tar","dest=/tmp/image.tar"'], true],
63+
[['" type= local" , dest=./release-out'], true],
64+
[['.'], true]
65+
])('given %p returns %p', async (outputs: Array<string>, expected: boolean) => {
66+
expect(buildx.isLocalOrTarExporter(outputs)).toEqual(expected);
67+
});
11368
});
11469

11570
describe('isAvailable', () => {
116-
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
71+
const execSpy = jest.spyOn(exec, 'getExecOutput');
11772
buildx.isAvailable();
11873

74+
// eslint-disable-next-line jest/no-standalone-expect
11975
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
12076
silent: true,
12177
ignoreReturnCode: true
12278
});
12379
});
12480

12581
describe('getVersion', () => {
126-
async function isDaemonRunning() {
127-
return await exec
128-
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
129-
ignoreReturnCode: true,
130-
silent: true
131-
})
132-
.then(res => {
133-
return !res.stdout.includes(' ') && res.exitCode == 0;
134-
});
135-
}
136-
(isDaemonRunning() ? it : it.skip)(
137-
'valid',
138-
async () => {
139-
const version = await buildx.getVersion();
140-
expect(semver.valid(version)).not.toBeNull();
141-
},
142-
100000
143-
);
82+
it('valid', async () => {
83+
const version = await buildx.getVersion();
84+
expect(semver.valid(version)).not.toBeNull();
85+
});
14486
});
14587

14688
describe('parseVersion', () => {
@@ -187,6 +129,7 @@ describe('getSecret', () => {
187129
const secretValue = await fs.readFileSync(tmpNameSync, 'utf-8');
188130
expect(secretValue).toEqual(exValue);
189131
} catch (err) {
132+
// eslint-disable-next-line jest/no-conditional-expect
190133
expect(true).toBe(invalid);
191134
}
192135
});

__tests__/context.test.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {beforeEach, 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';
@@ -517,8 +518,8 @@ nproc=3`],
517518
],
518519
])(
519520
'[%d] given %p with %p as inputs, returns %p',
520-
async (num: number, buildxVersion: string, inputs: Map<string, any>, expected: Array<string>) => {
521-
await inputs.forEach((value: string, name: string) => {
521+
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
522+
inputs.forEach((value: string, name: string) => {
522523
setInput(name, value);
523524
});
524525
const defContext = context.defaultContext();
@@ -666,7 +667,7 @@ FOO=bar`
666667
expect(res).toEqual([
667668
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
668669
`MYSECRET=aaaaaaaa
669-
bbbb\"bbb
670+
bbbb"bbb
670671
ccccccccc`,
671672
'FOO=bar'
672673
]);
@@ -688,19 +689,22 @@ describe('asyncForEach', () => {
688689

689690
describe('setOutput', () => {
690691
beforeEach(() => {
691-
process.stdout.write = jest.fn();
692+
process.stdout.write = jest.fn() as typeof process.stdout.write;
692693
});
693694

695+
// eslint-disable-next-line jest/expect-expect
694696
it('setOutput produces the correct command', () => {
695697
context.setOutput('some output', 'some value');
696698
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
697699
});
698700

701+
// eslint-disable-next-line jest/expect-expect
699702
it('setOutput handles bools', () => {
700703
context.setOutput('some output', false);
701704
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
702705
});
703706

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

hack/build.Dockerfile renamed to dev.Dockerfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# syntax=docker/dockerfile:1.3-labs
1+
# syntax=docker/dockerfile:1.4
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.0
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)