chore: exclude xo generated files from Code Climate #132
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: Integration | |
# yamllint disable-line rule:truthy | |
on: | |
push: | |
branches: | |
- master | |
tags-ignore: | |
- "*" | |
paths: | |
- .dockerignore | |
- .github/workflows/integration.yml | |
- .golangci.yaml | |
- .goreleaser.yaml | |
- '**.go' | |
- container-structure-test.yaml | |
- Dockerfile | |
- go.mod | |
- go.sum | |
- sonar-project.properties | |
pull_request: | |
branches: | |
- master | |
paths: | |
- .dockerignore | |
- .github/workflows/integration.yml | |
- .golangci.yaml | |
- .goreleaser.yaml | |
- '**.go' | |
- container-structure-test.yaml | |
- Dockerfile | |
- go.mod | |
- go.sum | |
- sonar-project.properties | |
env: | |
GOLANG_FLAGS: -race -mod=readonly | |
GOLANG_INTEGRATION_SRC_PATH: cmd/internal/integration | |
GOLANG_MERGED_GOCOV_FILE: merged.txt | |
GOLANG_RUN_REPORT_FILE: run-report.json | |
GOLANG_VERSION: "1.20" | |
WORK_DIR: /usr/src | |
permissions: | |
contents: read | |
jobs: | |
metadata: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: calculate version | |
uses: paulhatch/semantic-version@v5.0.3 | |
id: version | |
with: | |
branch: ${{ github.ref_name }} | |
bump_each_commit: false | |
change_path: >- | |
cmd/handler | |
internal | |
go.mod | |
go.sum | |
major_pattern: /^BREAKING CHANGE:|^[^()!:]+(?:\([^()!:]+\))?!:/ | |
minor_pattern: /^feat(?:\([^()!:]+\))?:/ | |
search_commit_body: true | |
user_format_type: csv | |
version_format: ${major}.${minor}.${patch}-rc.${increment} | |
- name: generate container meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
context: workflow | |
images: ${{ github.repository }} | |
flavor: | | |
latest=true | |
# yamllint disable rule:line-length | |
labels: | | |
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/blob/master/README.md | |
org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
org.opencontainers.image.url=https://hub.docker.com/r/${{ github.repository }} | |
org.opencontainers.image.version=${{ steps.version.outputs.version }} | |
# 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 }} | |
outputs: | |
major: ${{ steps.version.outputs.major }} | |
minor: ${{ steps.version.outputs.minor }} | |
patch: ${{ steps.version.outputs.patch }} | |
increment: ${{ steps.version.outputs.increment }} | |
version_type: ${{ steps.version.outputs.version_type }} | |
version: ${{ steps.version.outputs.version }} | |
tag: ${{ steps.version.outputs.version_tag }} | |
revision: ${{ steps.version.outputs.current_commit }} | |
authors: ${{ steps.version.outputs.authors }} | |
container-labels: ${{ steps.meta.outputs.labels }} | |
container-tags: ${{ steps.meta.outputs.tags }} | |
build: | |
runs-on: ubuntu-latest | |
needs: metadata | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- 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 modules | |
run: go mod download | |
- 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 | |
run: make build | |
env: | |
VERSION: ${{ needs.metadata.outputs.version }}+${{ github.sha }} | |
# - name: generate | |
# run: go generate ./... | |
# env: | |
# VERSION: ${{ needs.metadata.outputs.version }}+${{ github.sha }} | |
# - name: build | |
# uses: wwmoraes/actions/packages/golang/build@develop | |
# with: | |
# flags: -race -mod=readonly | |
lint: | |
runs-on: ubuntu-latest | |
env: | |
CONTAINER_LINT_REPORT_FILE: hadolint-report.json | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- 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 modules | |
run: go mod download | |
- 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 code source | |
uses: wwmoraes/actions/golang/lint@master | |
id: lint | |
with: | |
work-dir: ${{ env.WORK_DIR }} | |
version: v1.46-alpine | |
- name: upload code lint report | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: source-lint-report | |
path: ${{ steps.lint.outputs.report-file }} | |
- name: lint container source | |
uses: hadolint/hadolint-action@v3.1.0 | |
with: | |
dockerfile: Dockerfile | |
format: sonarqube | |
output-file: ${{ env.CONTAINER_LINT_REPORT_FILE }} | |
- name: upload container lint report | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: container-lint-report | |
path: ${{ env.CONTAINER_LINT_REPORT_FILE }} | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- 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 modules | |
run: go mod download | |
- 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: coverage test | |
run: make coverage | |
# - name: integration test | |
# uses: wwmoraes/actions/golang/integration@master | |
# with: | |
# run-flags: -race -mod=readonly | |
# packages: ./cmd/internal/integration/... | |
# cover-profile: ${{ runner.temp }}/integration.txt | |
# coverage-packages: |- | |
# github.com/${{ github.repository }}/internal/usecases | |
# github.com/${{ github.repository }}/internal/adapters | |
# - name: unit test | |
# uses: wwmoraes/actions/golang/test@master | |
# with: | |
# flags: -race -mod=readonly | |
# cover-profile: ${{ runner.temp }}/unit.txt | |
# - name: aggregate test results | |
# run: >- | |
# go run github.com/wadey/gocovmerge@latest | |
# ${{ runner.temp }}/integration.txt | |
# ${{ runner.temp }}/unit.txt | |
# > ${{ runner.temp }}/merged.txt | |
- name: upload coverage report | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: coverage-report | |
path: ${{ env.GOLANG_MERGED_GOCOV_FILE }} | |
- name: upload run report | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: run-report | |
path: ${{ env.GOLANG_RUN_REPORT_FILE }} | |
report: | |
runs-on: ubuntu-latest | |
needs: [lint, test] | |
if: always() | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
# - name: cache sonar scanner | |
# uses: pat-s/always-upload-cache@v2.1.5 | |
# if: false | |
# with: | |
# path: ${{ runner.temp }}/sonar-scanner/cache | |
# # yamllint disable-line rule:line-length | |
# key: ${{ runner.os }}-sonar-scanner-cache-${{ hashFiles('**/sonar-project.properties') }} | |
# # yamllint disable rule:line-length | |
# restore-keys: | | |
# ${{ runner.os }}-sonar-scanner-cache-${{ hashFiles('**/sonar-project.properties') }} | |
# ${{ runner.os }}-sonar-scanner-cache- | |
# # yamllint enable rule:line-length | |
- name: download source lint report | |
uses: actions/download-artifact@v3 | |
with: | |
name: source-lint-report | |
- name: download container lint report | |
uses: actions/download-artifact@v3 | |
with: | |
name: container-lint-report | |
- name: download run report | |
uses: actions/download-artifact@v3 | |
with: | |
name: run-report | |
- name: download coverage report | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-report | |
# - name: SonarCloud Scan | |
# uses: sonarsource/sonarcloud-github-action@master | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
# - name: run sonar scanner | |
# uses: wwmoraes/actions/sonar-scanner@master | |
# if: false | |
# with: | |
# token: ${{ secrets.SONAR_TOKEN }} | |
# work-dir: ${{ env.WORK_DIR }} | |
# home: ${{ runner.temp }}/sonar-scanner | |
- name: Setup Code Climate | |
uses: amancevice/setup-code-climate@v1 | |
- name: Setup Codecov | |
run: |- | |
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import | |
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig | |
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM | |
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM | |
curl -Os https://cli.codecov.io/latest/linux/codecov | |
shasum -a 256 -c codecov.SHA256SUM | |
install -d codecov ${{ runner.temp }}/bin/codecov | |
echo $PATH | grep -E "(^|:)${{ runner.temp }}/bin(:|$)" || echo "${{ runner.temp }}/bin" >> $GITHUB_PATH | |
- name: Upload report | |
run: make report | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
# - name: Upload coverage reports to Codecov | |
# uses: codecov/codecov-action@v3 | |
# with: | |
# flags: -X fixes | |
# files: >- | |
# ${{ env.GOLANG_MERGED_GOCOV_FILE }} | |
# ${{ env.GOLANG_RUN_REPORT_FILE }} | |
# env: | |
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
container: | |
runs-on: ubuntu-latest | |
needs: metadata | |
env: | |
# runner context is not available here... | |
GRYPE_DB_CACHE_TEMP_PATH: .cache/grype/db/ | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- 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: ${{ needs.metadata.outputs.container-labels }} | |
cache-to: | | |
type=local,mode=max,dest=${{ runner.temp }}/.buildx-cache-new | |
cache-from: | | |
type=local,src=${{ runner.temp }}/.buildx-cache | |
${{ needs.metadata.outputs.container-tags }} | |
${{ github.repository }}:test | |
tags: ${{ github.repository }}:test | |
build-args: | | |
GOLANG_VERSION=${{ env.GOLANG_VERSION }} | |
VERSION=${{ needs.metadata.outputs.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 |