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
Merge pull request #26 from crazy-max/workflow
Enhance workflow
- Loading branch information
Showing
11 changed files
with
133 additions
and
65 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,4 +1 @@ | ||
/.dev | ||
/dist | ||
/lib | ||
/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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,52 +1,60 @@ | ||
variable "GITHUB_REPOSITORY" { | ||
default = "docker/setup-qemu-action" | ||
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 "dockerfile" { | ||
dockerfile = "Dockerfile.dev" | ||
targets = ["format-validate", "build-validate", "vendor-validate"] | ||
} | ||
|
||
target "update-yarn" { | ||
inherits = ["dockerfile"] | ||
target = "update-yarn" | ||
target "build" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "build-update" | ||
output = ["."] | ||
} | ||
|
||
target "build" { | ||
inherits = ["dockerfile"] | ||
target = "dist" | ||
output = ["."] | ||
target "build-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "build-validate" | ||
} | ||
|
||
target "format" { | ||
inherits = ["dockerfile"] | ||
target = "format" | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "format-update" | ||
output = ["."] | ||
} | ||
|
||
target "validate-format" { | ||
inherits = ["dockerfile"] | ||
target = "validate-format" | ||
target "format-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "format-validate" | ||
} | ||
|
||
target "validate-build" { | ||
inherits = ["dockerfile"] | ||
target = "validate-build" | ||
target "vendor-update" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "update" | ||
output = ["."] | ||
} | ||
|
||
target "validate-yarn" { | ||
inherits = ["dockerfile"] | ||
target = "validate-yarn" | ||
target "vendor-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "validate" | ||
} |
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 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 |
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