chore(opts): taking a parameter on the include zero and nil opts (#108) #253
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
# This workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: "Code Approval" | |
on: | |
merge_group: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
types: | |
- opened | |
- reopened | |
- synchronize # source branch updated | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
pull-requests: write | |
issues: write | |
jobs: | |
golang-ci-lint: | |
name: Golangci-lint | |
runs-on: ubuntu-latest | |
steps: | |
# Sets up golang | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ vars.GO_VERSION }} | |
cache-dependency-path: "**/*.sum" | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: latest | |
only-new-issues: true | |
args: --verbose --timeout 5m | |
code-approval: | |
name: "Code Approval" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ vars.GO_VERSION }} | |
cache-dependency-path: "**/*.sum" | |
- name: Make | |
run: make pr-approval | |
- name: Check code coverage | |
run: | | |
go test -coverprofile=coverage.out -coverpkg=$(go list ./... | grep -v /examples | grep -v 'mock_') $(go list ./... | grep -v /examples) | |
coverage=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//') | |
if (( $(echo "$coverage < 80" | bc -l) )); then | |
echo "Code coverage is below 80%: $coverage%" | |
exit 1 | |
else | |
echo "Code coverage is sufficient: $coverage%" | |
fi | |
codegen-generation: | |
name: "Code Generation" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ vars.GO_VERSION }} | |
cache-dependency-path: "**/*.sum" | |
- name: "Run Code Generation" | |
run: go generate ./... | |
- name: "fmt" | |
run: go fmt ./... | |
# Do not run this is the PR is created by dependabot | |
- name: "Check for changes" | |
run: git diff --exit-code | |
- name: "Check for new files" | |
run: git diff --exit-code --name-status |