Skip to content

Commit 4abf7e9

Browse files
committed
Enhance workflow
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 175e20b commit 4abf7e9

9 files changed

+197
-29
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/coverage
2+
/node_modules

.github/CONTRIBUTING.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22

33
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
44

5-
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
5+
Contributions to this project are [released](https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license)
6+
to the public under the [project's open source license](LICENSE).
67

78
## Submitting a pull request
89

910
1. [Fork](https://github.com/docker/login-action/fork) and clone the repository
1011
2. Configure and install the dependencies: `yarn install`
11-
4. Create a new branch: `git checkout -b my-branch-name`
12-
5. Make your change
13-
6. Run pre-checkin: `yarn run pre-checkin`
14-
7. Push to your fork and [submit a pull request](https://github.com/docker/login-action/compare)
15-
8. Pat your self on the back and wait for your pull request to be reviewed and merged.
12+
3. Create a new branch: `git checkout -b my-branch-name`
13+
4. Make your changes
14+
5. Make sure the tests pass: `docker buildx bake test`
15+
6. Format code and build javascript artifacts: `docker buildx bake pre-checkin`
16+
7. Validate all code has correctly formatted and built: `docker buildx bake validate`
17+
8. Push to your fork and [submit a pull request](https://github.com/docker/login-action/compare)
18+
9. Pat your self on the back and wait for your pull request to be reviewed and merged.
1619

1720
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
1821

22+
- Write tests.
1923
- Make sure the `README.md` and any other relevant **documentation are kept up-to-date**.
2024
- We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
2125
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as **separate pull requests**.
@@ -24,5 +28,5 @@ Here are a few things you can do that will increase the likelihood of your pull
2428
## Resources
2529

2630
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
27-
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
28-
- [GitHub Help](https://help.github.com)
31+
- [Using Pull Requests](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
32+
- [GitHub Help](https://docs.github.com/en)

.github/ISSUE_TEMPLATE/bug_report.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ about: Create a report to help us improve
3030

3131
### Logs
3232

33-
> Download the [log file of your build](https://help.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#downloading-logs) and [attach it](https://help.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.
33+
> Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
34+
> and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
- cron: '0 10 * * *' # everyday at 10am
77
push:
88
branches:
9-
- master
9+
- 'master'
10+
- 'releases/v*'
1011

1112
jobs:
1213
dind:

.github/workflows/test.yml

+13-19
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,32 @@ name: test
33
on:
44
push:
55
branches:
6-
- master
7-
- releases/v*
8-
paths-ignore:
9-
- '**.md'
6+
- 'master'
7+
- 'releases/v*'
108
pull_request:
11-
paths-ignore:
12-
- '**.md'
9+
branches:
10+
- 'master'
11+
- 'releases/v*'
1312

1413
jobs:
1514
test:
16-
runs-on: ${{ matrix.os }}
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
os:
21-
- ubuntu-20.04
22-
- ubuntu-18.04
23-
- ubuntu-16.04
15+
runs-on: ubuntu-latest
2416
steps:
2517
-
2618
name: Checkout
2719
uses: actions/checkout@v2
2820
-
29-
name: Install
30-
run: yarn install
21+
name: Validate
22+
uses: docker/bake-action@v1
23+
with:
24+
targets: validate
3125
-
3226
name: Test
33-
run: yarn run test
27+
uses: docker/bake-action@v1
28+
with:
29+
targets: test
3430
-
3531
name: Upload coverage
3632
uses: codecov/codecov-action@v1
37-
if: success()
3833
with:
39-
token: ${{ secrets.CODECOV_TOKEN }}
4034
file: ./coverage/clover.xml

docker-bake.hcl

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
variable "NODE_VERSION" {
2+
default = "12"
3+
}
4+
5+
target "node-version" {
6+
args = {
7+
NODE_VERSION = NODE_VERSION
8+
}
9+
}
10+
11+
group "default" {
12+
targets = ["build"]
13+
}
14+
15+
group "pre-checkin" {
16+
targets = ["vendor-update", "format", "build"]
17+
}
18+
19+
group "validate" {
20+
targets = ["format-validate", "build-validate", "vendor-validate"]
21+
}
22+
23+
target "build" {
24+
inherits = ["node-version"]
25+
dockerfile = "./hack/build.Dockerfile"
26+
target = "build-update"
27+
output = ["."]
28+
}
29+
30+
target "build-validate" {
31+
inherits = ["node-version"]
32+
dockerfile = "./hack/build.Dockerfile"
33+
target = "build-validate"
34+
}
35+
36+
target "format" {
37+
inherits = ["node-version"]
38+
dockerfile = "./hack/build.Dockerfile"
39+
target = "format-update"
40+
output = ["."]
41+
}
42+
43+
target "format-validate" {
44+
inherits = ["node-version"]
45+
dockerfile = "./hack/build.Dockerfile"
46+
target = "format-validate"
47+
}
48+
49+
target "vendor-update" {
50+
inherits = ["node-version"]
51+
dockerfile = "./hack/vendor.Dockerfile"
52+
target = "update"
53+
output = ["."]
54+
}
55+
56+
target "vendor-validate" {
57+
inherits = ["node-version"]
58+
dockerfile = "./hack/vendor.Dockerfile"
59+
target = "validate"
60+
}
61+
62+
target "test" {
63+
inherits = ["node-version"]
64+
dockerfile = "./hack/test.Dockerfile"
65+
target = "test-coverage"
66+
output = ["./coverage"]
67+
}

hack/build.Dockerfile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# syntax=docker/dockerfile:1.2
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 \
11+
yarn install
12+
13+
FROM deps AS build
14+
RUN --mount=type=bind,target=.,rw \
15+
--mount=type=cache,target=/src/node_modules \
16+
yarn run build && mkdir /out && cp -Rf dist /out/
17+
18+
FROM scratch AS build-update
19+
COPY --from=build /out /
20+
21+
FROM build AS build-validate
22+
RUN --mount=type=bind,target=.,rw \
23+
git add -A && cp -rf /out/* .; \
24+
if [ -n "$(git status --porcelain -- dist)" ]; then \
25+
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \
26+
git status --porcelain -- dist; \
27+
exit 1; \
28+
fi
29+
30+
FROM deps AS format
31+
RUN --mount=type=bind,target=.,rw \
32+
--mount=type=cache,target=/src/node_modules \
33+
yarn run format \
34+
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
35+
36+
FROM scratch AS format-update
37+
COPY --from=format /out /
38+
39+
FROM deps AS format-validate
40+
RUN --mount=type=bind,target=.,rw \
41+
--mount=type=cache,target=/src/node_modules \
42+
yarn run format-check \

hack/test.Dockerfile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# syntax=docker/dockerfile:1.2
2+
ARG NODE_VERSION
3+
4+
FROM node:${NODE_VERSION}-alpine AS base
5+
RUN apk add --no-cache binutils curl git unzip
6+
ENV GLIBC_VER=2.31-r0
7+
RUN curl -sL "https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub" -o "/etc/apk/keys/sgerrand.rsa.pub" \
8+
&& curl -sLO "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk" \
9+
&& curl -sLO "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk" \
10+
&& apk add --no-cache \
11+
glibc-${GLIBC_VER}.apk \
12+
glibc-bin-${GLIBC_VER}.apk \
13+
&& curl -sL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
14+
&& unzip -qq "awscliv2.zip" \
15+
&& ./aws/install \
16+
&& aws --version
17+
WORKDIR /src
18+
19+
FROM base AS deps
20+
RUN --mount=type=bind,target=.,rw \
21+
--mount=type=cache,target=/src/node_modules \
22+
yarn install
23+
24+
FROM deps AS test
25+
ENV RUNNER_TEMP=/tmp/github_runner
26+
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
27+
RUN --mount=type=bind,target=.,rw \
28+
--mount=type=cache,target=/src/node_modules \
29+
--mount=type=bind,from=crazymax/docker,source=/usr/libexec/docker/cli-plugins/docker-buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
30+
--mount=type=bind,from=crazymax/docker,source=/usr/local/bin/docker,target=/usr/bin/docker \
31+
yarn run test --coverageDirectory=/tmp/coverage
32+
33+
FROM scratch AS test-coverage
34+
COPY --from=test /tmp/coverage /

hack/vendor.Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1.2
2+
ARG NODE_VERSION
3+
4+
FROM node:${NODE_VERSION}-alpine AS base
5+
RUN apk add --no-cache git
6+
WORKDIR /src
7+
8+
FROM base AS vendored
9+
RUN --mount=type=bind,target=.,rw \
10+
--mount=type=cache,target=/src/node_modules \
11+
yarn install && mkdir /out && cp yarn.lock /out
12+
13+
FROM scratch AS update
14+
COPY --from=vendored /out /
15+
16+
FROM vendored AS validate
17+
RUN --mount=type=bind,target=.,rw \
18+
git add -A && cp -rf /out/* .; \
19+
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \
20+
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \
21+
git status --porcelain -- yarn.lock; \
22+
exit 1; \
23+
fi

0 commit comments

Comments
 (0)