Skip to content

Commit

Permalink
Merge pull request #18 from crazy-max/update-workflow
Browse files Browse the repository at this point in the history
dev: update workflow
  • Loading branch information
crazy-max authored Dec 16, 2021
2 parents d965b93 + 2ca3546 commit 9e6ff7e
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 95 deletions.
80 changes: 80 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# syntax=docker/dockerfile:1.3-labs
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 <<EOT
yarn install
mkdir /vendor
cp yarn.lock /vendor
EOT

FROM scratch AS vendor-update
COPY --from=deps /vendor /

FROM deps AS vendor-validate
RUN --mount=type=bind,target=.,rw <<EOT
set -e
git add -A
cp -rf /vendor/* .
diff=$(git status --porcelain -- yarn.lock)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
echo "$diff"
exit 1
fi
EOT

FROM deps AS build
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules <<EOT
yarn run build
mkdir /out
cp -Rf dist /out/
EOT

FROM scratch AS build-update
COPY --from=build /out /

FROM build AS build-validate
RUN --mount=type=bind,target=.,rw <<EOT
set -e
git add -A
cp -rf /out/* .
diff=$(git status --porcelain -- dist)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
echo "$diff"
exit 1
fi
EOT

FROM deps AS format
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules <<EOT
yarn run format
mkdir /out
find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
EOT

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

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 \
yarn run test --coverageDirectory=/tmp/coverage

FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /
21 changes: 12 additions & 9 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,49 @@ group "validate" {

target "build" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "./dev.Dockerfile"
target = "build-update"
output = ["."]
}

target "build-validate" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "./dev.Dockerfile"
target = "build-validate"
output = ["type=cacheonly"]
}

target "format" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "./dev.Dockerfile"
target = "format-update"
output = ["."]
}

target "format-validate" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "./dev.Dockerfile"
target = "format-validate"
output = ["type=cacheonly"]
}

target "vendor-update" {
inherits = ["node-version"]
dockerfile = "./hack/vendor.Dockerfile"
target = "update"
dockerfile = "./dev.Dockerfile"
target = "vendor-update"
output = ["."]
}

target "vendor-validate" {
inherits = ["node-version"]
dockerfile = "./hack/vendor.Dockerfile"
target = "validate"
dockerfile = "./dev.Dockerfile"
target = "vendor-validate"
output = ["type=cacheonly"]
}

target "test" {
inherits = ["node-version"]
dockerfile = "./hack/test.Dockerfile"
dockerfile = "./dev.Dockerfile"
target = "test-coverage"
output = ["./coverage"]
}
42 changes: 0 additions & 42 deletions hack/build.Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions hack/test.Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions hack/vendor.Dockerfile

This file was deleted.

0 comments on commit 9e6ff7e

Please sign in to comment.