Skip to content

Commit eefeb0e

Browse files
committed
Enhance workflow
1 parent 2536e18 commit eefeb0e

File tree

11 files changed

+153
-109
lines changed

11 files changed

+153
-109
lines changed

.dockerignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
/.dev
21
/coverage
3-
/dist
4-
/lib
52
/node_modules
6-
/.env

.github/CONTRIBUTING.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
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

@@ -18,6 +19,7 @@ Contributions to this project are [released](https://help.github.com/articles/gi
1819

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

22+
- Write tests.
2123
- Make sure the `README.md` and any other relevant **documentation are kept up-to-date**.
2224
- We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
2325
- 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**.
@@ -26,5 +28,5 @@ Here are a few things you can do that will increase the likelihood of your pull
2628
## Resources
2729

2830
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
29-
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
30-
- [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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
name: ci
22

33
on:
4+
schedule:
5+
- cron: '0 10 * * *' # everyday at 10am
46
push:
57
branches:
6-
- master
8+
- 'master'
9+
- 'releases/v*'
10+
tags:
11+
- 'v*'
712
pull_request:
813
branches:
9-
- master
14+
- 'master'
15+
- 'releases/v*'
1016

1117
jobs:
1218
bake:

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ on:
55
branches:
66
- 'master'
77
- 'releases/v*'
8-
paths-ignore:
9-
- '**.md'
108
pull_request:
119
branches:
1210
- 'master'
13-
paths-ignore:
14-
- '**.md'
11+
- 'releases/v*'
1512

1613
jobs:
1714
test:
@@ -22,10 +19,11 @@ jobs:
2219
uses: actions/checkout@v2
2320
-
2421
name: Test
25-
run: docker buildx bake test
22+
uses: docker/bake-action@v1
23+
with:
24+
targets: test
2625
-
2726
name: Upload coverage
2827
uses: codecov/codecov-action@v1
2928
with:
30-
token: ${{ secrets.CODECOV_TOKEN }}
3129
file: ./coverage/clover.xml

.github/workflows/validate.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ on:
55
branches:
66
- 'master'
77
- 'releases/v*'
8-
paths-ignore:
9-
- '**.md'
108
pull_request:
119
branches:
1210
- 'master'
13-
paths-ignore:
14-
- '**.md'
11+
- 'releases/v*'
1512

1613
jobs:
1714
validate:
@@ -22,4 +19,6 @@ jobs:
2219
uses: actions/checkout@v2
2320
-
2421
name: Validate
25-
run: docker buildx bake validate
22+
uses: docker/bake-action@v1
23+
with:
24+
targets: validate

Dockerfile.dev

Lines changed: 0 additions & 59 deletions
This file was deleted.

docker-bake.hcl

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,67 @@
1-
group "default" {
2-
targets = ["build"]
1+
variable "NODE_VERSION" {
2+
default = "12"
33
}
44

5-
group "pre-checkin" {
6-
targets = ["update-yarn", "format", "build"]
5+
target "node-version" {
6+
args = {
7+
NODE_VERSION = NODE_VERSION
8+
}
79
}
810

9-
group "validate" {
10-
targets = ["validate-format", "validate-build", "validate-yarn"]
11+
group "default" {
12+
targets = ["build"]
1113
}
1214

13-
target "dockerfile" {
14-
dockerfile = "Dockerfile.dev"
15+
group "pre-checkin" {
16+
targets = ["vendor-update", "format", "build"]
1517
}
1618

17-
target "update-yarn" {
18-
inherits = ["dockerfile"]
19-
target = "update-yarn"
20-
output = ["."]
19+
group "validate" {
20+
targets = ["format-validate", "build-validate", "vendor-validate"]
2121
}
2222

2323
target "build" {
24-
inherits = ["dockerfile"]
25-
target = "dist"
24+
inherits = ["node-version"]
25+
dockerfile = "./hack/build.Dockerfile"
26+
target = "build-update"
2627
output = ["."]
2728
}
2829

29-
target "test" {
30-
inherits = ["dockerfile"]
31-
target = "test-coverage"
32-
output = ["."]
30+
target "build-validate" {
31+
inherits = ["node-version"]
32+
dockerfile = "./hack/build.Dockerfile"
33+
target = "build-validate"
3334
}
3435

3536
target "format" {
36-
inherits = ["dockerfile"]
37-
target = "format"
37+
inherits = ["node-version"]
38+
dockerfile = "./hack/build.Dockerfile"
39+
target = "format-update"
3840
output = ["."]
3941
}
4042

41-
target "validate-format" {
42-
inherits = ["dockerfile"]
43-
target = "validate-format"
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 = ["."]
4454
}
4555

46-
target "validate-build" {
47-
inherits = ["dockerfile"]
48-
target = "validate-build"
56+
target "vendor-validate" {
57+
inherits = ["node-version"]
58+
dockerfile = "./hack/vendor.Dockerfile"
59+
target = "validate"
4960
}
5061

51-
target "validate-yarn" {
52-
inherits = ["dockerfile"]
53-
target = "validate-yarn"
62+
target "test" {
63+
inherits = ["node-version"]
64+
dockerfile = "./hack/test.Dockerfile"
65+
target = "test-coverage"
66+
output = ["./coverage"]
5467
}

hack/build.Dockerfile

Lines changed: 42 additions & 0 deletions
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

Lines changed: 23 additions & 0 deletions
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 deps
9+
RUN --mount=type=bind,target=.,rw \
10+
--mount=type=cache,target=/src/node_modules \
11+
yarn install
12+
13+
FROM deps AS test
14+
ENV RUNNER_TEMP=/tmp/github_runner
15+
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
16+
RUN --mount=type=bind,target=.,rw \
17+
--mount=type=cache,target=/src/node_modules \
18+
--mount=type=bind,from=crazymax/docker,source=/usr/libexec/docker/cli-plugins/docker-buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
19+
--mount=type=bind,from=crazymax/docker,source=/usr/local/bin/docker,target=/usr/bin/docker \
20+
yarn run test --coverageDirectory=/tmp/coverage
21+
22+
FROM scratch AS test-coverage
23+
COPY --from=test /tmp/coverage /

0 commit comments

Comments
 (0)