Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container based developer flow #134

Merged
merged 1 commit into from Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
@@ -0,0 +1,4 @@
/.dev
/dist
/lib
/node_modules
9 changes: 5 additions & 4 deletions .github/CONTRIBUTING.md
Expand Up @@ -7,10 +7,11 @@ Contributions to this project are [released](https://help.github.com/articles/gi
## Submitting a pull request

1. [Fork](https://github.com/crazy-max/ghaction-github-pages/fork) and clone the repository
2. Configure and install the dependencies: `yarn install`
4. Create a new branch: `git checkout -b my-branch-name`
5. Make your change
6. Run pre-checkin: `yarn run pre-checkin`
2. Configure and install the dependencies locally: `yarn install`
3. Create a new branch: `git checkout -b my-branch-name`
4. Make your changes
5. Format code and build javascript artifacts: `docker buildx bake pre-checkin`
6. Validate all code has correctly formatted and built: `docker buildx bake validate`
7. Push to your fork and [submit a pull request](https://github.com/crazy-max/ghaction-github-pages/compare)
8. Pat your self on the back and wait for your pull request to be reviewed and merged.

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -5,8 +5,8 @@ on:
- cron: '0 10 * * *' # everyday at 10am
push:
branches:
- dev
- releases/v*
- 'dev'
- 'releases/v*'

jobs:
ci:
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/pre-checkin.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/validate.yml
@@ -0,0 +1,25 @@
name: validate

on:
push:
branches:
- 'dev'
- 'releases/v*'
paths-ignore:
- '**.md'
pull_request:
branches:
- 'dev'
paths-ignore:
- '**.md'

jobs:
validate:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Validate
run: docker buildx bake validate
41 changes: 41 additions & 0 deletions Dockerfile.dev
@@ -0,0 +1,41 @@
#syntax=docker/dockerfile:1.2

FROM node:12 AS deps
WORKDIR /src
COPY package.json yarn.lock ./
RUN --mount=type=cache,target=/src/node_modules \
yarn install

FROM scratch AS update-yarn
COPY --from=deps /src/yarn.lock /

FROM deps AS validate-yarn
COPY .git .git
RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi

FROM deps AS base
COPY . .

FROM base AS build
RUN --mount=type=cache,target=/src/node_modules \
yarn build

FROM base AS run-format
RUN --mount=type=cache,target=/src/node_modules \
yarn run format

FROM scratch AS format
COPY --from=run-format /src/src/*.ts /src/

FROM base AS validate-format
RUN --mount=type=cache,target=/src/node_modules \
yarn run format-check

FROM scratch AS dist
COPY --from=build /src/dist/ /dist/

FROM build AS validate-build
RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi

FROM base AS dev
ENTRYPOINT ["bash"]
52 changes: 52 additions & 0 deletions docker-bake.hcl
@@ -0,0 +1,52 @@
variable "GITHUB_REPOSITORY" {
default = "crazy-max/ghaction-github-pages"
}

group "default" {
targets = ["build"]
}

group "pre-checkin" {
targets = ["update-yarn", "format", "build"]
}

group "validate" {
targets = ["validate-format", "validate-build", "validate-yarn"]
}

target "dockerfile" {
dockerfile = "Dockerfile.dev"
}

target "update-yarn" {
inherits = ["dockerfile"]
target = "update-yarn"
output = ["."]
}

target "build" {
inherits = ["dockerfile"]
target = "dist"
output = ["."]
}

target "format" {
inherits = ["dockerfile"]
target = "format"
output = ["."]
}

target "validate-format" {
inherits = ["dockerfile"]
target = "validate-format"
}

target "validate-build" {
inherits = ["dockerfile"]
target = "validate-build"
}

target "validate-yarn" {
inherits = ["dockerfile"]
target = "validate-yarn"
}