Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: lint and test workflows #973

Merged
merged 6 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
62 changes: 14 additions & 48 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,23 @@ on:
- v*

jobs:
test-linux:
name: Test (Linux)
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: 1.20.x
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- uses: golangci/golangci-lint-action@v3
- run: make convention
- run: make cover
- run: test "$(gofmt -l . | wc -l)" = 0
- uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: .profile.cov

test-windows:
name: Test (Windows)
# Please do not specify `windows-latest`
# Build process is complex then need to check operation.
runs-on: windows-2022
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x

- uses: golangci/golangci-lint-action@v3
with:
args: --timeout 5m
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**\go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Run Test
run: |
go test -short ./...
Comment on lines -54 to -55
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-short no longer reduce anything

#972

shell: bash
lint:
uses: mackerelio/workflows/.github/workflows/go-lint.yml@v1.1.0
convention:
uses: mackerelio/workflows/.github/workflows/setup-go-matrix.yml@v1.1.0
with:
run: make convention
test:
uses: mackerelio/workflows/.github/workflows/go-test.yml@v1.1.0
with:
# Please do not specify `windows-latest`
# Build process is complex then need to check operation.
os-versions: '["ubuntu-latest", "windows-2022"]'

build-linux:
name: Build (Linux)
runs-on: ubuntu-latest
needs: test-linux
needs: test
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
env:
DEBIAN_FRONTEND: noninteractive
Expand Down Expand Up @@ -95,7 +61,7 @@ jobs:
build-windows:
name: Build (Windows)
runs-on: windows-2022
needs: test-windows
needs: test
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!.circleci
!.dependabot
!.github
!.gitattributes
!.gitignore
!.goxc.json
!.travis.yml
Expand Down
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
linters:
enable:
- gofmt
linters-settings:
gofmt:
simplify: true
issues:
exclude-rules:
- path: _test\.go
Expand Down
4 changes: 2 additions & 2 deletions command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ func TestCollectHostParamWithChecks(t *testing.T) {
customIdentifier := "app.example.com"
conf := config.Config{
CheckPlugins: map[string]*config.CheckPlugin{
"chk1": &config.CheckPlugin{
"chk1": {
CustomIdentifier: nil,
},
"chk2": &config.CheckPlugin{
"chk2": {
CustomIdentifier: &customIdentifier,
},
},
Expand Down
4 changes: 2 additions & 2 deletions metrics/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (g *AgentGenerator) CustomIdentifier() *string {
func (g *AgentGenerator) PrepareGraphDefs() ([]*mkr.GraphDefsParam, error) {
meta := &pluginMeta{
Graphs: map[string]customGraphDef{
"agent.memory": customGraphDef{
"agent.memory": {
Label: "Agent Memory",
Unit: "bytes",
Metrics: []customGraphMetricDef{
Expand All @@ -47,7 +47,7 @@ func (g *AgentGenerator) PrepareGraphDefs() ([]*mkr.GraphDefsParam, error) {
{Name: "heapSys", Label: "Heap Sys"},
},
},
"agent.runtime": customGraphDef{
"agent.runtime": {
Label: "Agent Runtime",
Unit: "integer",
Metrics: []customGraphMetricDef{
Expand Down
Loading