-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from digineo/gh-actions
ci: improve Github actions
- Loading branch information
Showing
4 changed files
with
90 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
env: | ||
GO_VERSION: "1.16" | ||
steps: | ||
- name: Set up Go ${{ env.GO_VERSION }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod # Module download cache | ||
~/.cache/go-build # Build cache (Linux) | ||
key: ${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-${{ env.GO_VERSION }}-go- | ||
|
||
- name: Check and get dependencies | ||
run: | | ||
go mod tidy | ||
git diff --exit-code go.mod | ||
git diff --exit-code go.sum | ||
go mod download | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.38 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*.*.*' | ||
|
||
name: Release | ||
jobs: | ||
goreleaser: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
env: | ||
GO_VERSION: "1.16" | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
- name: Set up Go ${{ env.GO_VERSION }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod # Module download cache | ||
~/.cache/go-build # Build cache (Linux) | ||
key: ${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-${{ env.GO_VERSION }}-go- | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
args: release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
name: Test | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.16.x] | ||
platform: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.platform }} | ||
runs-on: "${{ matrix.platform }}" | ||
env: | ||
CGO_ENABLED: 0 | ||
steps: | ||
- name: Install Go | ||
if: success() | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Build | ||
run: go build | ||
- name: Run tests | ||
run: go test ./... -v -covermode=count | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod # Module download cache | ||
~/.cache/go-build # Build cache (Linux) | ||
~/Library/Caches/go-build # Build cache (Mac) | ||
'%LocalAppData%\go-build' # Build cache (Windows) | ||
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-${{ matrix.go-version }}-go- | ||
|
||
- name: Build | ||
run: go build -v -ldflags="-s -w" -trimpath -o ping_exporter | ||
|
||
- name: Test | ||
run: go test ./... -v -covermode=count |
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