feat: MVP's out 🚀 #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
# yamllint disable-line rule:truthy | |
on: | |
release: | |
types: [published] | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
paths: | |
- .github/workflows/integration.yml | |
- .golangci.yaml | |
- .goreleaser.yaml | |
- container-structure-test.yaml | |
- Dockerfile | |
- .dockerignore | |
- go.mod | |
- go.sum | |
- '**.go' | |
pull_request: | |
branches: | |
- master | |
paths: | |
- .github/workflows/integration.yml | |
- .golangci.yaml | |
- .goreleaser.yaml | |
- container-structure-test.yaml | |
- Dockerfile | |
- .dockerignore | |
- go.mod | |
- go.sum | |
- '**.go' | |
env: | |
GOLANG_VERSION: "1.20" | |
GOLANG_FLAGS: -race -mod=readonly | |
WORK_DIR: /usr/src | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: setup golang | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.GOLANG_VERSION }} | |
- name: set golang environment variables | |
uses: wwmoraes/actions/golang/env@master | |
- name: cache modules | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${GOMODCACHE} | |
key: ${{ runner.os }}-modules-${{ hashFiles('go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-modules-${{ hashFiles('go.sum') }} | |
${{ runner.os }}-modules- | |
- name: download dependencies | |
run: go mod download | |
- name: cache vendor | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-vendor-${{ hashFiles('go.mod', 'go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-vendor-${{ hashFiles('go.mod', 'go.sum') }} | |
${{ runner.os }}-vendor- | |
- name: vendor dependencies | |
run: go mod vendor | |
- name: cache build | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${GOCACHE} | |
key: ${{ runner.os }}-build-${{ hashFiles('**/*.go') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ hashFiles('**/*.go') }} | |
${{ runner.os }}-build- | |
- name: build | |
uses: wwmoraes/actions/golang/build@master | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: setup golang | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.GOLANG_VERSION }} | |
- name: set golang environment variables | |
uses: wwmoraes/actions/golang/env@master | |
- name: cache modules | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${GOMODCACHE} | |
key: ${{ runner.os }}-modules-${{ hashFiles('go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-modules-${{ hashFiles('go.sum') }} | |
${{ runner.os }}-modules- | |
- name: download dependencies | |
run: go mod download | |
- name: cache vendor | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-vendor-${{ hashFiles('go.mod', 'go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-vendor-${{ hashFiles('go.mod', 'go.sum') }} | |
${{ runner.os }}-vendor- | |
- name: vendor dependencies | |
run: go mod vendor | |
- name: cache lint | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${HOME}/.cache/golangci-lint | |
key: ${{ runner.os }}-lint-${{ hashFiles('.golangci.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-lint-${{ hashFiles('.golangci.yaml') }} | |
${{ runner.os }}-lint- | |
- name: lint | |
uses: wwmoraes/actions/golang/lint@master | |
id: lint | |
with: | |
work-dir: ${{ env.WORK_DIR }} | |
version: v1.46-alpine | |
- name: upload lint report | |
uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: lint-report | |
path: ${{ steps.lint.outputs.report-file }} | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: setup golang | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.GOLANG_VERSION }} | |
- name: set golang environment variables | |
uses: wwmoraes/actions/golang/env@master | |
- name: cache modules | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${GOMODCACHE} | |
key: ${{ runner.os }}-modules-${{ hashFiles('go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-modules-${{ hashFiles('go.sum') }} | |
${{ runner.os }}-modules- | |
- name: download dependencies | |
run: go mod download | |
- name: cache vendor | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-vendor-${{ hashFiles('go.mod', 'go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-vendor-${{ hashFiles('go.mod', 'go.sum') }} | |
${{ runner.os }}-vendor- | |
- name: vendor dependencies | |
run: go mod vendor | |
- name: cache test | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${GOCACHE} | |
key: ${{ runner.os }}-test-${{ hashFiles('**/*.go') }} | |
restore-keys: | | |
${{ runner.os }}-test-${{ hashFiles('**/*.go') }} | |
${{ runner.os }}-test- | |
- name: test | |
uses: wwmoraes/actions/golang/test@master | |
id: test | |
- name: security scan | |
uses: anchore/scan-action@v3 | |
with: | |
path: . | |
fail-build: true | |
- name: upload coverage report | |
uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: coverage-report | |
path: ${{ steps.test.outputs.cover-profile }} | |
- name: upload test report | |
uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: test-report | |
path: ${{ steps.test.outputs.report-file }} | |
report: | |
runs-on: ubuntu-latest | |
needs: [lint, test] | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: download lint report | |
uses: actions/download-artifact@v2 | |
with: | |
name: lint-report | |
- name: download test report | |
uses: actions/download-artifact@v2 | |
with: | |
name: test-report | |
- name: download coverage report | |
uses: actions/download-artifact@v2 | |
with: | |
name: coverage-report | |
release: | |
runs-on: ubuntu-latest | |
needs: [build, lint, test] | |
if: >- | |
github.event_name == 'push' | |
&& startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: setup golang | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.GOLANG_VERSION }} | |
- name: set golang environment variables | |
uses: wwmoraes/actions/golang/env@master | |
- name: cache modules | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${GOMODCACHE} | |
key: ${{ runner.os }}-modules-${{ hashFiles('go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-modules-${{ hashFiles('go.sum') }} | |
${{ runner.os }}-modules- | |
- name: cache vendor | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-vendor-${{ hashFiles('go.mod', 'go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-vendor-${{ hashFiles('go.mod', 'go.sum') }} | |
${{ runner.os }}-vendor- | |
- name: cache build | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${GOCACHE} | |
key: ${{ runner.os }}-build-${{ hashFiles('**/*.go') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ hashFiles('**/*.go') }} | |
${{ runner.os }}-build- | |
- name: run goreleaser | |
uses: goreleaser/goreleaser-action@v3 | |
with: | |
version: latest | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
docker: | |
runs-on: ubuntu-latest | |
needs: [build, lint, test] | |
env: | |
# runner context is not available here... | |
GRYPE_DB_CACHE_TEMP_PATH: .cache/grype/db/ | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: generate container meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ github.repository }} | |
flavor: | | |
latest=true | |
# yamllint disable rule:line-length | |
labels: | | |
org.opencontainers.image.authors=${{ secrets.OCI_AUTHORS }} | |
org.opencontainers.image.documentation=https://github.com/${{ github.repository }} | |
org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
org.opencontainers.image.url=https://github.com/${{ github.repository }} | |
org.opencontainers.image.vendor=${{ secrets.OCI_AUTHORS }} | |
# yamllint enable rule:line-length | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=raw,value=${{ env.BRANCH }} | |
type=semver,pattern={{version}} | |
github-token: ${{ github.token }} | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: cache buildx | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${{ runner.temp }}/.buildx-cache | |
# yamllint disable-line rule:line-length | |
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile', '.dockerignore') }} | |
# yamllint disable rule:line-length | |
restore-keys: | | |
${{ runner.os }}-buildx-${{ hashFiles('Dockerfile', '.dockerignore') }} | |
${{ runner.os }}-buildx- | |
# yamllint enable rule:line-length | |
- name: build single-arch test image | |
uses: docker/build-push-action@v3 | |
env: | |
DOCKER_BUILDKIT: 0 | |
BUILDKIT_INLINE_CACHE: 1 | |
with: | |
push: false | |
load: true | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-to: | | |
type=local,mode=max,dest=${{ runner.temp }}/.buildx-cache-new | |
cache-from: | | |
type=local,src=${{ runner.temp }}/.buildx-cache | |
tags: ${{ github.repository }}:test | |
build-args: | | |
GOLANG_VERSION=${{ env.GOLANG_VERSION }} | |
# fix to prevent ever-growing caches | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf ${{ runner.temp }}/.buildx-cache | |
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache | |
- name: test structure | |
uses: brpaz/structure-tests-action@v1.1.2 | |
with: | |
image: ${{ github.repository }}:test | |
configFile: container-structure-test.yaml | |
- name: cache grype | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${{ runner.temp }}/${{ env.GRYPE_DB_CACHE_TEMP_PATH }} | |
key: ${{ runner.os }}-grype-${{ hashFiles('.grype.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-grype-${{ hashFiles('.grype.yaml') }} | |
${{ runner.os }}-grype- | |
- name: grype scan | |
uses: anchore/scan-action@v3 | |
with: | |
image: ${{ github.repository }}:test | |
fail-build: true | |
publish-docker: | |
runs-on: ubuntu-latest | |
needs: docker | |
if: github.event_name == 'release' | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: generate container meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ github.repository }} | |
flavor: | | |
latest=true | |
# yamllint disable rule:line-length | |
labels: | | |
org.opencontainers.image.authors=${{ secrets.OCI_AUTHORS }} | |
org.opencontainers.image.documentation=https://github.com/${{ github.repository }} | |
org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
org.opencontainers.image.url=https://github.com/${{ github.repository }} | |
org.opencontainers.image.vendor=${{ secrets.OCI_AUTHORS }} | |
# yamllint enable rule:line-length | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=raw,value=${{ env.BRANCH }} | |
type=semver,pattern={{version}} | |
github-token: ${{ github.token }} | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: cache buildx | |
uses: pat-s/always-upload-cache@v2.1.5 | |
with: | |
path: ${{ runner.temp }}/.buildx-cache | |
# yamllint disable-line rule:line-length | |
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile', '.dockerignore') }} | |
# yamllint disable rule:line-length | |
restore-keys: | | |
${{ runner.os }}-buildx-${{ hashFiles('Dockerfile', '.dockerignore') }} | |
${{ runner.os }}-buildx- | |
# yamllint enable rule:line-length | |
- name: login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: build multi-arch image | |
uses: docker/build-push-action@v3 | |
env: | |
DOCKER_BUILDKIT: 1 | |
BUILDKIT_INLINE_CACHE: 1 | |
with: | |
push: false | |
load: true | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-to: | | |
type=local,mode=max,dest=${{ runner.temp }}/.buildx-cache-new | |
cache-from: | | |
type=local,src=${{ runner.temp }}/.buildx-cache | |
${{ steps.meta.outputs.tags }} | |
${{ github.repository }}:master | |
${{ github.repository }}:latest | |
build-args: | | |
GOLANG_VERSION=${{ env.GOLANG_VERSION }} | |
tags: ${{ steps.meta.outputs.tags }} | |
# fix to prevent ever-growing caches | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf ${{ runner.temp }}/.buildx-cache | |
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache | |
- name: test release | |
uses: brpaz/structure-tests-action@v1.1.2 | |
with: | |
image: ${{ github.repository }}:test | |
configFile: container-structure-test.yaml | |
- name: security scan | |
uses: anchore/scan-action@v3 | |
with: | |
image: ${{ github.repository }}:test | |
fail-build: true | |
- name: push multi-arch image | |
uses: docker/build-push-action@v3 | |
env: | |
DOCKER_BUILDKIT: 1 | |
BUILDKIT_INLINE_CACHE: 1 | |
with: | |
push: true | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-to: | | |
type=local,mode=max,dest=${{ runner.temp }}/.buildx-cache-new | |
cache-from: | | |
type=local,src=${{ runner.temp }}/.buildx-cache | |
${{ steps.meta.outputs.tags }} | |
${{ github.repository }}:master | |
${{ github.repository }}:latest | |
build-args: | | |
GOLANG_VERSION=${{ env.GOLANG_VERSION }} | |
tags: ${{ steps.meta.outputs.tags }} | |
# fix to prevent ever-growing caches | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf ${{ runner.temp }}/.buildx-cache | |
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache | |
- name: update DockerHub description | |
uses: meeDamian/sync-readme@v1.0.6 | |
with: | |
pass: ${{ secrets.DOCKER_PASSWORD }} | |
description: true |