Skip to content

Commit

Permalink
Container based developer flow (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max and crazy-max authored Dec 19, 2020
1 parent 446faac commit d231fa6
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 54 deletions.
17 changes: 4 additions & 13 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
.git
.github
.res
lib
node_modules
src
.editorconfig
.gitignore
.prettierrc.json
action.yml
package.json
package-lock.json
tsconfig.json
/.dev
/dist
/lib
/node_modules
11 changes: 6 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ Contributions to this project are [released](https://help.github.com/articles/gi
## Submitting a pull request

1. [Fork](https://github.com/crazy-max/ghaction-chocolatey/fork) and clone the repository
2. Configure and install the dependencies: `yarn install`
2. Configure and install the dependencies locally: `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`
7. Push to your fork and [submit a pull request](https://github.com/crazy-max/ghaction-chocolatey/compare)
8. Pat your self on the back and wait for your pull request to be reviewed and merged.
5. Make your changes
6. Format code and build javascript artifacts: `docker buildx bake pre-checkin`
7. Validate all code has correctly formatted and built: `docker buildx bake validate`
8. Push to your fork and [submit a pull request](https://github.com/crazy-max/ghaction-chocolatey/compare)
9. Pat your self on the back and wait for your pull request to be reviewed and merged.

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

Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name: ci
on:
schedule:
- cron: '0 10 * * *' # everyday at 10am
pull_request:
branches:
- master
- releases/v*
push:
branches:
- master
- releases/v*
- 'master'
- 'releases/v*'
pull_request:
branches:
- 'master'

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: validate

on:
push:
branches:
- 'master'
- 'releases/v*'
paths-ignore:
- '**.md'
pull_request:
branches:
- 'master'
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
Original file line number Diff line number Diff line change
@@ -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"]
48 changes: 48 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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"
}

0 comments on commit d231fa6

Please sign in to comment.