chore: enhance workflow (#271)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
d8a076a057
commit
b458824747
|
@ -1 +1,2 @@
|
||||||
node_modules
|
/coverage
|
||||||
|
/node_modules
|
||||||
|
|
|
@ -44,12 +44,14 @@ jobs:
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
args: check --debug
|
args: check --debug
|
||||||
|
workdir: ./test
|
||||||
-
|
-
|
||||||
name: GoReleaser
|
name: GoReleaser
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
args: release --skip-publish --rm-dist
|
args: release --skip-publish --rm-dist
|
||||||
|
workdir: ./test
|
||||||
|
|
||||||
install-only:
|
install-only:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -115,6 +117,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: -f .goreleaser-signing.yml check --debug
|
args: -f .goreleaser-signing.yml check --debug
|
||||||
|
workdir: ./test
|
||||||
env:
|
env:
|
||||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||||
-
|
-
|
||||||
|
@ -123,6 +126,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: -f .goreleaser-signing.yml release --skip-publish --rm-dist
|
args: -f .goreleaser-signing.yml release --skip-publish --rm-dist
|
||||||
|
workdir: ./test
|
||||||
env:
|
env:
|
||||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||||
|
|
||||||
|
@ -144,14 +148,16 @@ jobs:
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
args: check --debug
|
args: check --debug
|
||||||
|
workdir: ./test
|
||||||
-
|
-
|
||||||
name: GoReleaser
|
name: GoReleaser
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
args: release --skip-publish --rm-dist
|
args: release --skip-publish --rm-dist
|
||||||
|
workdir: ./test
|
||||||
-
|
-
|
||||||
name: Upload assets
|
name: Upload assets
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: myapp
|
name: myapp
|
||||||
path: dist/*
|
path: ./test/dist/*
|
||||||
|
|
|
@ -3,16 +3,15 @@ name: test
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- 'master'
|
||||||
- releases/v*
|
- 'releases/v*'
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
branches:
|
||||||
- '**.md'
|
- 'master'
|
||||||
|
- 'releases/v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-containerized:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
|
@ -22,36 +21,16 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
-
|
-
|
||||||
name: Validate
|
name: Validate
|
||||||
run: docker buildx bake validate
|
uses: docker/bake-action@v1
|
||||||
-
|
|
||||||
name: Test
|
|
||||||
run: docker buildx bake test
|
|
||||||
|
|
||||||
test:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- ubuntu-latest
|
|
||||||
- macOS-latest
|
|
||||||
- windows-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
targets: validate
|
||||||
-
|
|
||||||
name: Install
|
|
||||||
run: yarn install
|
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
run: yarn run test
|
uses: docker/bake-action@v1
|
||||||
|
with:
|
||||||
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
if: success()
|
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
file: ./coverage/clover.xml
|
file: ./coverage/clover.xml
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
#syntax=docker/dockerfile:1.2
|
|
||||||
|
|
||||||
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"]
|
|
|
@ -1,53 +1,67 @@
|
||||||
|
variable "NODE_VERSION" {
|
||||||
|
default = "12"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "node-version" {
|
||||||
|
args = {
|
||||||
|
NODE_VERSION = NODE_VERSION
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
group "default" {
|
group "default" {
|
||||||
targets = ["build"]
|
targets = ["build"]
|
||||||
}
|
}
|
||||||
|
|
||||||
group "pre-checkin" {
|
group "pre-checkin" {
|
||||||
targets = ["update-yarn", "format", "build"]
|
targets = ["vendor-update", "format", "build"]
|
||||||
}
|
}
|
||||||
|
|
||||||
group "validate" {
|
group "validate" {
|
||||||
targets = ["validate-format", "validate-build", "validate-yarn"]
|
targets = ["format-validate", "build-validate", "vendor-validate"]
|
||||||
}
|
|
||||||
|
|
||||||
target "dockerfile" {
|
|
||||||
dockerfile = "dev.Dockerfile"
|
|
||||||
}
|
|
||||||
|
|
||||||
target "update-yarn" {
|
|
||||||
inherits = ["dockerfile"]
|
|
||||||
target = "update-yarn"
|
|
||||||
output = ["."]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target "build" {
|
target "build" {
|
||||||
inherits = ["dockerfile"]
|
inherits = ["node-version"]
|
||||||
target = "dist"
|
dockerfile = "./hack/build.Dockerfile"
|
||||||
|
target = "build-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "test" {
|
target "build-validate" {
|
||||||
inherits = ["dockerfile"]
|
inherits = ["node-version"]
|
||||||
target = "test"
|
dockerfile = "./hack/build.Dockerfile"
|
||||||
|
target = "build-validate"
|
||||||
}
|
}
|
||||||
|
|
||||||
target "format" {
|
target "format" {
|
||||||
inherits = ["dockerfile"]
|
inherits = ["node-version"]
|
||||||
target = "format"
|
dockerfile = "./hack/build.Dockerfile"
|
||||||
|
target = "format-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "validate-format" {
|
target "format-validate" {
|
||||||
inherits = ["dockerfile"]
|
inherits = ["node-version"]
|
||||||
target = "validate-format"
|
dockerfile = "./hack/build.Dockerfile"
|
||||||
|
target = "format-validate"
|
||||||
}
|
}
|
||||||
|
|
||||||
target "validate-build" {
|
target "vendor-update" {
|
||||||
inherits = ["dockerfile"]
|
inherits = ["node-version"]
|
||||||
target = "validate-build"
|
dockerfile = "./hack/vendor.Dockerfile"
|
||||||
|
target = "update"
|
||||||
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "validate-yarn" {
|
target "vendor-validate" {
|
||||||
inherits = ["dockerfile"]
|
inherits = ["node-version"]
|
||||||
target = "validate-yarn"
|
dockerfile = "./hack/vendor.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "test" {
|
||||||
|
inherits = ["node-version"]
|
||||||
|
dockerfile = "./hack/test.Dockerfile"
|
||||||
|
target = "test-coverage"
|
||||||
|
output = ["./coverage"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
# syntax=docker/dockerfile:1.2
|
||||||
|
ARG NODE_VERSION
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
|
RUN apk add --no-cache cpio findutils git
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
FROM base AS deps
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
FROM deps AS build
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run build && mkdir /out && cp -Rf dist /out/
|
||||||
|
|
||||||
|
FROM scratch AS build-update
|
||||||
|
COPY --from=build /out /
|
||||||
|
|
||||||
|
FROM build AS build-validate
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
git add -A && cp -rf /out/* .; \
|
||||||
|
if [ -n "$(git status --porcelain -- dist)" ]; then \
|
||||||
|
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \
|
||||||
|
git status --porcelain -- dist; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
FROM deps AS format
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run format \
|
||||||
|
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
|
||||||
|
|
||||||
|
FROM scratch AS format-update
|
||||||
|
COPY --from=format /out /
|
||||||
|
|
||||||
|
FROM deps AS format-validate
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run format-check \
|
|
@ -0,0 +1,21 @@
|
||||||
|
# syntax=docker/dockerfile:1.2
|
||||||
|
ARG NODE_VERSION
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
FROM base AS deps
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
FROM deps AS test
|
||||||
|
ENV RUNNER_TEMP=/tmp/github_runner
|
||||||
|
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run test --coverageDirectory=/tmp/coverage
|
||||||
|
|
||||||
|
FROM scratch AS test-coverage
|
||||||
|
COPY --from=test /tmp/coverage /
|
|
@ -0,0 +1,23 @@
|
||||||
|
# syntax=docker/dockerfile:1.2
|
||||||
|
ARG NODE_VERSION
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
FROM base AS vendored
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn install && mkdir /out && cp yarn.lock /out
|
||||||
|
|
||||||
|
FROM scratch AS update
|
||||||
|
COPY --from=vendored /out /
|
||||||
|
|
||||||
|
FROM vendored AS validate
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
git add -A && cp -rf /out/* .; \
|
||||||
|
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \
|
||||||
|
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \
|
||||||
|
git status --porcelain -- yarn.lock; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
|
@ -8,7 +8,7 @@ module.exports = {
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testMatch: ['**/*.test.ts'],
|
testMatch: ['**/*.test.ts'],
|
||||||
testRunner: 'jest-circus/runner',
|
testRunner: 'jest-circus/runner',
|
||||||
testTimeout: 10000,
|
testTimeout: 30000,
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': 'ts-jest'
|
'^.+\\.ts$': 'ts-jest'
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
env:
|
env:
|
||||||
- GO111MODULE=on
|
- GO111MODULE=on
|
||||||
- GOPROXY=https://goproxy.io
|
|
||||||
|
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -26,10 +25,6 @@ archives:
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
format: zip
|
format: zip
|
||||||
files:
|
|
||||||
- LICENSE
|
|
||||||
- README.md
|
|
||||||
- CHANGELOG.md
|
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: 'checksums.txt'
|
name_template: 'checksums.txt'
|
|
@ -1,6 +1,5 @@
|
||||||
env:
|
env:
|
||||||
- GO111MODULE=on
|
- GO111MODULE=on
|
||||||
- GOPROXY=https://goproxy.io
|
|
||||||
|
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -26,10 +25,6 @@ archives:
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
format: zip
|
format: zip
|
||||||
files:
|
|
||||||
- LICENSE
|
|
||||||
- README.md
|
|
||||||
- CHANGELOG.md
|
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: 'checksums.txt'
|
name_template: 'checksums.txt'
|
Loading…
Reference in New Issue