-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from crazy-max/workflow
Enhance workflow
- Loading branch information
Showing
9 changed files
with
197 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
variable "NODE_VERSION" { | ||
default = "12" | ||
} | ||
|
||
target "node-version" { | ||
args = { | ||
NODE_VERSION = NODE_VERSION | ||
} | ||
} | ||
|
||
group "default" { | ||
targets = ["build"] | ||
} | ||
|
||
group "pre-checkin" { | ||
targets = ["vendor-update", "format", "build"] | ||
} | ||
|
||
group "validate" { | ||
targets = ["format-validate", "build-validate", "vendor-validate"] | ||
} | ||
|
||
target "build" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "build-update" | ||
output = ["."] | ||
} | ||
|
||
target "build-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "build-validate" | ||
} | ||
|
||
target "format" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "format-update" | ||
output = ["."] | ||
} | ||
|
||
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 "vendor-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "validate" | ||
} | ||
|
||
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,34 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
ARG NODE_VERSION | ||
|
||
FROM node:${NODE_VERSION}-alpine AS base | ||
RUN apk add --no-cache binutils curl git unzip | ||
ENV GLIBC_VER=2.31-r0 | ||
RUN curl -sL "https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub" -o "/etc/apk/keys/sgerrand.rsa.pub" \ | ||
&& curl -sLO "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk" \ | ||
&& curl -sLO "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk" \ | ||
&& apk add --no-cache \ | ||
glibc-${GLIBC_VER}.apk \ | ||
glibc-bin-${GLIBC_VER}.apk \ | ||
&& curl -sL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ | ||
&& unzip -qq "awscliv2.zip" \ | ||
&& ./aws/install \ | ||
&& aws --version | ||
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 |