Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Enhance workflow
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
- Loading branch information
CrazyMax
committed
Mar 28, 2021
1 parent
09f8407
commit 460e0e4
Showing
13 changed files
with
159 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
/coverage | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,67 @@ | ||
variable "NODE_VERSION" { | ||
default = "12" | ||
} | ||
|
||
target "node-version" { | ||
args = { | ||
NODE_VERSION = NODE_VERSION | ||
} | ||
} | ||
|
||
group "default" { | ||
targets = ["build"] | ||
} | ||
|
||
group "pre-checkin" { | ||
targets = ["update-yarn", "format", "build"] | ||
targets = ["vendor-update", "format", "build"] | ||
} | ||
|
||
group "validate" { | ||
targets = ["validate-format", "validate-build", "validate-yarn"] | ||
} | ||
|
||
target "update-yarn" { | ||
target = "update-yarn" | ||
output = ["."] | ||
targets = ["format-validate", "build-validate", "vendor-validate"] | ||
} | ||
|
||
target "build" { | ||
target = "dist" | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "build-update" | ||
output = ["."] | ||
} | ||
|
||
target "test" { | ||
target = "test" | ||
target "build-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "build-validate" | ||
} | ||
|
||
target "format" { | ||
target = "format" | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "format-update" | ||
output = ["."] | ||
} | ||
|
||
target "validate-format" { | ||
target = "validate-format" | ||
target "format-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "format-validate" | ||
} | ||
|
||
target "vendor-update" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "update" | ||
output = ["."] | ||
} | ||
|
||
target "validate-build" { | ||
target = "validate-build" | ||
target "vendor-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "validate" | ||
} | ||
|
||
target "validate-yarn" { | ||
target = "validate-yarn" | ||
target "test" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/test.Dockerfile" | ||
target = "test-coverage" | ||
output = ["./coverage"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
ARG NODE_VERSION | ||
|
||
FROM node:${NODE_VERSION}-alpine AS base | ||
RUN apk add --no-cache cpio findutils git | ||
WORKDIR /src | ||
|
||
FROM base AS deps | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn install | ||
|
||
FROM deps AS build | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn run build && mkdir /out && cp -Rf dist /out/ | ||
|
||
FROM scratch AS build-update | ||
COPY --from=build /out / | ||
|
||
FROM build AS build-validate | ||
RUN --mount=type=bind,target=.,rw \ | ||
git add -A && cp -rf /out/* .; \ | ||
if [ -n "$(git status --porcelain -- dist)" ]; then \ | ||
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \ | ||
git status --porcelain -- dist; \ | ||
exit 1; \ | ||
fi | ||
|
||
FROM deps AS format | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn run format \ | ||
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out | ||
|
||
FROM scratch AS format-update | ||
COPY --from=format /out / | ||
|
||
FROM deps AS format-validate | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn run format-check \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
ARG NODE_VERSION | ||
|
||
FROM node:${NODE_VERSION}-alpine AS base | ||
RUN apk add --no-cache git | ||
WORKDIR /src | ||
|
||
FROM base AS deps | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn install | ||
|
||
FROM deps AS test | ||
ENV RUNNER_TEMP=/tmp/github_runner | ||
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
--mount=type=bind,from=crazymax/docker,source=/usr/libexec/docker/cli-plugins/docker-buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \ | ||
--mount=type=bind,from=crazymax/docker,source=/usr/local/bin/docker,target=/usr/bin/docker \ | ||
yarn run test --coverageDirectory=/tmp/coverage | ||
|
||
FROM scratch AS test-coverage | ||
COPY --from=test /tmp/coverage / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
ARG NODE_VERSION | ||
|
||
FROM node:${NODE_VERSION}-alpine AS base | ||
RUN apk add --no-cache git | ||
WORKDIR /src | ||
|
||
FROM base AS vendored | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn install && mkdir /out && cp yarn.lock /out | ||
|
||
FROM scratch AS update | ||
COPY --from=vendored /out / | ||
|
||
FROM vendored AS validate | ||
RUN --mount=type=bind,target=.,rw \ | ||
git add -A && cp -rf /out/* .; \ | ||
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \ | ||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \ | ||
git status --porcelain -- yarn.lock; \ | ||
exit 1; \ | ||
fi |
File renamed without changes.
File renamed without changes.