Created
March 16, 2023 22:02
Golang testing and github workflow w/ coverage, dependencies and badges
This file contains hidden or 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
version: 2 | |
updates: | |
- package-ecosystem: github-actions | |
directory: / | |
labels: | |
- dependencies | |
- actions | |
- Skip Changelog | |
schedule: | |
interval: weekly | |
day: sunday | |
- package-ecosystem: gomod | |
directory: / | |
labels: | |
- dependencies | |
- go | |
- Skip Changelog | |
schedule: | |
interval: weekly | |
day: sunday | |
# - package-ecosystem: docker | |
# directory: /<docker directory> | |
# labels: | |
# - dependencies | |
# - docker | |
# - Skip Changelog | |
# schedule: | |
# interval: weekly | |
# day: sunday |
This file contains hidden or 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
# Note: to ensure coverage is only pushed once, you need to constrain on one matrix combination. | |
name: Go Workflows | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
gotest: | |
name: Go | |
runs-on: ${{ matrix.os }} | |
env: | |
CGO_ENABLED: 0 | |
strategy: | |
matrix: | |
go-version: [ "1.16", "1.18", "1.20", "1.x" ] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- name: Set up Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Code checkout | |
uses: actions/checkout@v3 | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
# In order: | |
# * Module download cache | |
# * Build cache (Linux) | |
# * Build cache (Mac) | |
# * Build cache (Windows) | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
~/Library/Caches/go-build | |
%LocalAppData%\go-build | |
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.go-version }}-go- | |
- name: Test | |
run: go test ./... | |
#run: make test | |
- name: Update Coverage | |
uses: ncruces/go-coverage-report@main | |
if: | | |
matrix.os == 'ubuntu-latest' && | |
matrix.go-version == '1.x' && | |
github.event_name == 'push' | |
continue-on-error: true |
This file contains hidden or 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
- Enabling Coverage | |
- You need a wiki, so create at least one page. If it doesn't exist, just accept the "Welcome!..." default. | |
- Give workflows read/write permissions: | |
- Settings -> General -> Workflow permissions -> Read and write permissions -> [Save] | |
- Enablint Dependabot | |
- Settings -> Security -> Code security and analysis -> | |
-> Dependabot security updates [Enable] | |
-> Dependabot version updates [Enable] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment