Skip to content

Commit

Permalink
Use common reusable Go workflows (#129)
Browse files Browse the repository at this point in the history
* Use common reusable Go workflows
* Quiet CI warnings
  • Loading branch information
webbnh committed Jun 27, 2024
1 parent 72aa096 commit 7ae1ee0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 107 deletions.
123 changes: 16 additions & 107 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,120 +2,29 @@ name: Continuous Integration
on:
push:
branches:
- "main"
- main
tags:
- "v*"
- v*
pull_request:
jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ vars.ARCALOT_GO_VERSION }}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2

test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ vars.ARCALOT_GO_VERSION }}

- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up limgo
uses: GoTestTools/limgo-action@v1.0.2
with:
version: "v1.0.0"
install-only: true

- name: Setup go mockgen
run: go install go.uber.org/mock/mockgen@v0.4.0

- name: generate mocks
run: go generate ./...

- name: run tests
run: |
set -euo pipefail
go test -coverprofile=test.cov -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: upload test log
uses: actions/upload-artifact@v4
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error

- name: Calculate test coverage
run: |
cat .limgo.json
limgo -coverfile=test.cov -config=.limgo.json -outfmt=md -outfile=limgo_cov.md
cat limgo_cov.md >> $GITHUB_STEP_SUMMARY
- name: upload coverage results
uses: actions/upload-artifact@v4
with:
name: coverage
path: limgo_cov.md
if-no-files-found: error
lint_and_test:
name: lint and test
uses: arcalot/arcaflow-reusable-workflows/.github/workflows/go_lint_and_test.yaml@main
with:
go_version: ${{ vars.ARCALOT_GO_VERSION }}

release:
name: release
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs:
- golangci-lint
- test
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ vars.ARCALOT_GO_VERSION }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Release if tagged, else Build
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: ${{ env.GR_CMD }} ${{ env.GR_ARGS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GR_CMD: ${{ startsWith(github.event.ref, 'refs/tags/') && 'release' || 'build' }}
GR_ARGS: ${{ startsWith(github.event.ref, 'refs/tags/') && '--clean' || '--snapshot' }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries
path: dist
- lint_and_test
uses: arcalot/arcaflow-reusable-workflows/.github/workflows/go_release.yaml@main
secrets:
REGISTRY_USERNAME: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
with:
go_version: ${{ vars.ARCALOT_GO_VERSION }}
for_release: ${{ startsWith(github.event.ref, 'refs/tags/') }}
registry: ghcr.io
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2
project_name: arcaflow-container-toolkit
before:
hooks:
Expand Down

0 comments on commit 7ae1ee0

Please sign in to comment.