Skip to content

Commit 9e6ff7e

Browse files
authored
Merge pull request #18 from crazy-max/update-workflow
dev: update workflow
2 parents d965b93 + 2ca3546 commit 9e6ff7e

5 files changed

Lines changed: 92 additions & 95 deletions

File tree

dev.Dockerfile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# syntax=docker/dockerfile:1.3-labs
2+
ARG NODE_VERSION
3+
4+
FROM node:${NODE_VERSION}-alpine AS base
5+
RUN apk add --no-cache cpio findutils git
6+
WORKDIR /src
7+
8+
FROM base AS deps
9+
RUN --mount=type=bind,target=.,rw \
10+
--mount=type=cache,target=/src/node_modules <<EOT
11+
yarn install
12+
mkdir /vendor
13+
cp yarn.lock /vendor
14+
EOT
15+
16+
FROM scratch AS vendor-update
17+
COPY --from=deps /vendor /
18+
19+
FROM deps AS vendor-validate
20+
RUN --mount=type=bind,target=.,rw <<EOT
21+
set -e
22+
git add -A
23+
cp -rf /vendor/* .
24+
diff=$(git status --porcelain -- yarn.lock)
25+
if [ -n "$diff" ]; then
26+
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
27+
echo "$diff"
28+
exit 1
29+
fi
30+
EOT
31+
32+
FROM deps AS build
33+
RUN --mount=type=bind,target=.,rw \
34+
--mount=type=cache,target=/src/node_modules <<EOT
35+
yarn run build
36+
mkdir /out
37+
cp -Rf dist /out/
38+
EOT
39+
40+
FROM scratch AS build-update
41+
COPY --from=build /out /
42+
43+
FROM build AS build-validate
44+
RUN --mount=type=bind,target=.,rw <<EOT
45+
set -e
46+
git add -A
47+
cp -rf /out/* .
48+
diff=$(git status --porcelain -- dist)
49+
if [ -n "$diff" ]; then
50+
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
51+
echo "$diff"
52+
exit 1
53+
fi
54+
EOT
55+
56+
FROM deps AS format
57+
RUN --mount=type=bind,target=.,rw \
58+
--mount=type=cache,target=/src/node_modules <<EOT
59+
yarn run format
60+
mkdir /out
61+
find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
62+
EOT
63+
64+
FROM scratch AS format-update
65+
COPY --from=format /out /
66+
67+
FROM deps AS format-validate
68+
RUN --mount=type=bind,target=.,rw \
69+
--mount=type=cache,target=/src/node_modules \
70+
yarn run format-check
71+
72+
FROM deps AS test
73+
ENV RUNNER_TEMP=/tmp/github_runner
74+
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
75+
RUN --mount=type=bind,target=.,rw \
76+
--mount=type=cache,target=/src/node_modules \
77+
yarn run test --coverageDirectory=/tmp/coverage
78+
79+
FROM scratch AS test-coverage
80+
COPY --from=test /tmp/coverage /

docker-bake.hcl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,49 @@ group "validate" {
2222

2323
target "build" {
2424
inherits = ["node-version"]
25-
dockerfile = "./hack/build.Dockerfile"
25+
dockerfile = "./dev.Dockerfile"
2626
target = "build-update"
2727
output = ["."]
2828
}
2929

3030
target "build-validate" {
3131
inherits = ["node-version"]
32-
dockerfile = "./hack/build.Dockerfile"
32+
dockerfile = "./dev.Dockerfile"
3333
target = "build-validate"
34+
output = ["type=cacheonly"]
3435
}
3536

3637
target "format" {
3738
inherits = ["node-version"]
38-
dockerfile = "./hack/build.Dockerfile"
39+
dockerfile = "./dev.Dockerfile"
3940
target = "format-update"
4041
output = ["."]
4142
}
4243

4344
target "format-validate" {
4445
inherits = ["node-version"]
45-
dockerfile = "./hack/build.Dockerfile"
46+
dockerfile = "./dev.Dockerfile"
4647
target = "format-validate"
48+
output = ["type=cacheonly"]
4749
}
4850

4951
target "vendor-update" {
5052
inherits = ["node-version"]
51-
dockerfile = "./hack/vendor.Dockerfile"
52-
target = "update"
53+
dockerfile = "./dev.Dockerfile"
54+
target = "vendor-update"
5355
output = ["."]
5456
}
5557

5658
target "vendor-validate" {
5759
inherits = ["node-version"]
58-
dockerfile = "./hack/vendor.Dockerfile"
59-
target = "validate"
60+
dockerfile = "./dev.Dockerfile"
61+
target = "vendor-validate"
62+
output = ["type=cacheonly"]
6063
}
6164

6265
target "test" {
6366
inherits = ["node-version"]
64-
dockerfile = "./hack/test.Dockerfile"
67+
dockerfile = "./dev.Dockerfile"
6568
target = "test-coverage"
6669
output = ["./coverage"]
6770
}

hack/build.Dockerfile

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

hack/test.Dockerfile

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

hack/vendor.Dockerfile

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

0 commit comments

Comments
 (0)