Skip to content

Commit e33a648

Browse files
authored
Container based developer flow (#76)
Co-authored-by: CrazyMax <[email protected]>
1 parent c9085d8 commit e33a648

File tree

11 files changed

+205
-94
lines changed

11 files changed

+205
-94
lines changed

.dockerignore

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

.github/CONTRIBUTING.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ Contributions to this project are [released](https://help.github.com/articles/gi
77
## Submitting a pull request
88

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

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

.github/workflows/ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ name: ci
33
on:
44
schedule:
55
- cron: '0 10 * * *' # everyday at 10am
6-
pull_request:
7-
branches:
8-
- master
9-
- releases/v*
106
push:
117
branches:
12-
- master
13-
- releases/v*
8+
- 'master'
9+
- 'releases/v*'
10+
pull_request:
11+
branches:
12+
- 'master'
1413

1514
jobs:
1615
armored:

.github/workflows/pre-checkin.yml

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

.github/workflows/test.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ on:
1212
- '**.md'
1313

1414
jobs:
15+
test-containerized:
16+
runs-on: ubuntu-latest
17+
steps:
18+
-
19+
name: Checkout
20+
uses: actions/checkout@v2
21+
-
22+
name: Test
23+
run: docker buildx bake test
24+
1525
test:
1626
runs-on: ${{ matrix.os }}
1727
strategy:
@@ -34,7 +44,6 @@ jobs:
3444
-
3545
name: Upload coverage
3646
uses: codecov/codecov-action@v1
37-
if: success()
3847
with:
3948
token: ${{ secrets.CODECOV_TOKEN }}
4049
file: ./coverage/clover.xml

.github/workflows/validate.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: validate
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'releases/v*'
8+
paths-ignore:
9+
- '**.md'
10+
pull_request:
11+
branches:
12+
- 'master'
13+
paths-ignore:
14+
- '**.md'
15+
16+
jobs:
17+
validate:
18+
runs-on: ubuntu-latest
19+
steps:
20+
-
21+
name: Checkout
22+
uses: actions/checkout@v2
23+
-
24+
name: Validate
25+
run: docker buildx bake validate

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pids
3535
lib-cov
3636

3737
# Coverage directory used by tools like istanbul
38-
coverage
38+
/coverage
3939
*.lcov
4040

4141
# nyc test coverage

Dockerfile.dev

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#syntax=docker/dockerfile:1.2
2+
3+
FROM node:12 AS deps
4+
WORKDIR /src
5+
COPY package.json yarn.lock ./
6+
RUN --mount=type=cache,target=/src/node_modules \
7+
yarn install
8+
9+
FROM scratch AS update-yarn
10+
COPY --from=deps /src/yarn.lock /
11+
12+
FROM deps AS validate-yarn
13+
COPY .git .git
14+
RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi
15+
16+
FROM deps AS base
17+
COPY . .
18+
19+
FROM base AS build
20+
RUN --mount=type=cache,target=/src/node_modules \
21+
yarn build
22+
23+
FROM deps AS test
24+
ARG GITHUB_REPOSITORY
25+
ENV RUNNER_TEMP=/tmp/github_runner
26+
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
27+
ENV GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
28+
COPY . .
29+
RUN --mount=type=cache,target=/src/node_modules \
30+
yarn run test
31+
32+
FROM scratch AS test-coverage
33+
COPY --from=test /src/coverage /coverage/
34+
35+
FROM base AS run-format
36+
RUN --mount=type=cache,target=/src/node_modules \
37+
yarn run format
38+
39+
FROM scratch AS format
40+
COPY --from=run-format /src/src/*.ts /src/
41+
42+
FROM base AS validate-format
43+
RUN --mount=type=cache,target=/src/node_modules \
44+
yarn run format-check
45+
46+
FROM scratch AS dist
47+
COPY --from=build /src/dist/ /dist/
48+
49+
FROM build AS validate-build
50+
RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi
51+
52+
FROM base AS dev
53+
ENTRYPOINT ["bash"]

0 commit comments

Comments
 (0)