feat: Container based developer flow (#258)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
d19982d4d2
commit
a61bc075fd
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
|
@ -1,30 +0,0 @@
|
||||||
name: pre-checkin
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
pre-checkin:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Install
|
|
||||||
run: yarn install
|
|
||||||
-
|
|
||||||
name: Pre-checkin
|
|
||||||
run: yarn run pre-checkin
|
|
||||||
-
|
|
||||||
name: Check for uncommitted changes
|
|
||||||
run: |
|
|
||||||
if [[ `git status --porcelain` ]]; then
|
|
||||||
git status --porcelain
|
|
||||||
echo "::warning::Found changes. Please run 'yarn run pre-checkin' and push"
|
|
||||||
fi
|
|
|
@ -12,6 +12,21 @@ on:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test-containerized:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
-
|
||||||
|
name: Validate
|
||||||
|
run: docker buildx bake validate
|
||||||
|
-
|
||||||
|
name: Test
|
||||||
|
run: docker buildx bake test
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
#syntax=docker/dockerfile:1.1-experimental
|
||||||
|
|
||||||
|
FROM node:12 AS deps
|
||||||
|
WORKDIR /src
|
||||||
|
COPY package.json yarn.lock ./
|
||||||
|
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \
|
||||||
|
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 yarn build
|
||||||
|
|
||||||
|
FROM deps AS test
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
ENV RUNNER_TEMP=/tmp/github_runner
|
||||||
|
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
||||||
|
COPY . .
|
||||||
|
RUN yarn run test
|
||||||
|
|
||||||
|
FROM base AS run-format
|
||||||
|
RUN yarn run format
|
||||||
|
|
||||||
|
FROM scratch AS format
|
||||||
|
COPY --from=run-format /src/src/*.ts /src/
|
||||||
|
|
||||||
|
FROM base AS validate-format
|
||||||
|
RUN 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"]
|
14
README.md
14
README.md
|
@ -24,6 +24,7 @@ ___
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [environment variables](#environment-variables)
|
* [environment variables](#environment-variables)
|
||||||
* [Limitation](#limitation)
|
* [Limitation](#limitation)
|
||||||
|
* [Development](#development)
|
||||||
* [License](#license)
|
* [License](#license)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
@ -178,6 +179,19 @@ secret named `GH_PAT`, the step will look like this:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
```
|
||||||
|
# format code and build javascript artifacts
|
||||||
|
docker buildx bake pre-checkin
|
||||||
|
|
||||||
|
# validate all code has correctly formatted and built
|
||||||
|
docker buildx bake validate
|
||||||
|
|
||||||
|
# run tests
|
||||||
|
docker buildx bake test
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT. See `LICENSE` for more details.
|
MIT. See `LICENSE` for more details.
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
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 "test" {
|
||||||
|
inherits = ["dockerfile"]
|
||||||
|
target = "test"
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
Loading…
Reference in New Issue