Skip to content

Commit

Permalink
Yaml lint/fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlion committed Jun 3, 2024
1 parent ab712cc commit ae27a04
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 77 deletions.
62 changes: 34 additions & 28 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,66 @@
name: lint
name: "lint"
on:
push:
pull_request:
workflow_call:

permissions:
contents: read
contents: "read"

jobs:
go-lint:
strategy:
matrix:
go: ['1.23']
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
go: ["1.23"]
os: ["ubuntu-latest", "macos-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Checkout"
uses: "actions/checkout@v4"

- name: Setup Go
uses: actions/setup-go@v5
- name: "Setup Go"
uses: "actions/setup-go@v5"
with:
go-version: ${{ matrix.go }}
go-version: "${{ matrix.go }}"

- name: Lint go code
uses: golangci/golangci-lint-action@v6
- name: "Lint go code"
uses: "golangci/golangci-lint-action@v6"
with:
version: v1.59
version: "v1.59"

cpp-lint:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
os: ["ubuntu-latest", "macos-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Checkout"
uses: "actions/checkout@v4"
with:
submodules: recursive
submodules: "recursive"

- name: Setup Go
uses: actions/setup-go@v5
- name: "Setup Go"
uses: "actions/setup-go@v5"
with:
go-version: ${{ matrix.go }}
go-version: "${{ matrix.go }}"

- name: Macos: install clang/llvm
if: ${{ 'macos-latest' == matrix.os }}
- name: "Macos: install clang/llvm"
if: |
${{ "macos-latest" == matrix.os }}
run: |
brew update
brew install llvm
- name: Linux: install clang/llvm
if: ${{ 'ubuntu-latest' == matrix.os }}
- name: "Linux: install clang/llvm"
if: |
${{ "ubuntu-latest" == matrix.os }}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://apt.llvm.org/llvm.sh | bash -s -- 16 all
curl --proto "=https" --tlsv1.2 -sSf https://apt.llvm.org/llvm.sh | bash -s -- 16 all
- run: find cpp/src -type f | xargs clang-format-16 -i
- name: "Clang format"
run: |
find cpp/src -type f | xargs clang-format-16 -i
- run: find cpp/src -type f | xargs clang-tidy-16
- name: "Clang tidy"
run: |
find cpp/src -type f | xargs clang-tidy-16
70 changes: 36 additions & 34 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: "Test"
on:
pull_request:
push:
Expand All @@ -8,55 +8,57 @@ jobs:
package-test:
strategy:
matrix:
go: ['1.23']
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
go: ["1.23"]
os: ["ubuntu-latest", "macos-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Checkout"
uses: "actions/checkout@v4"

- name: Setup Go
uses: actions/setup-go@v5
- name: "Setup Go"
uses: "actions/setup-go@v5"
with:
go-version: ${{ matrix.go }}
go-version: "${{ matrix.go }}"

- name: Go build
run: go clean -cache && go build ./...

- name: Unit tests
run: go test -count=1 ./...
- name: "Unit tests"
run: |
go clean -cache
go test -count=1 ./...
full-build-test:
strategy:
matrix:
go: ['1.23']
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
go: ["1.23"]
os: ["ubuntu-latest", "macos-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Checkout"
uses: "actions/checkout@v4"
with:
submodules: recursive
submodules: "recursive"

- name: Setup Go
uses: actions/setup-go@v5
- name: "Setup Go"
uses: "actions/setup-go@v5"
with:
go-version: ${{ matrix.go }}
go-version: "${{ matrix.go }}"

- name: Macos: install clang/llvm
if: ${{ 'macos-latest' == matrix.os }}
- name: "Macos: install clang/llvm"
if: |
${{ "macos-latest" == matrix.os }}
run: |
brew update
brew install llvm
- name: Remove packaged c++ libraries and go code
run: rm ./lib/* ./**/*_string.go

- name: Install stringer for go generate
run: go install golang.org/x/tools/cmd/stringer@latest
- name: "Remove packaged c++ libraries and go code"
run: |
rm ./lib/* ./**/*_string.go
- name: Generate go code and build+install c++ library
run: go clean -cache && go generate ./...
- name: "Generate go code and build+install c++ library"
run: |
go install golang.org/x/tools/cmd/stringer@latest
go generate ./...
- name: Unit tests
run: go test -count=1 ./...
- name: "Unit tests"
run: |
go clean -cache
go test -count=1 ./...
29 changes: 14 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ issues:
linters:
disable-all: true
enable:
- gocritic
- goimports
- govet
- ineffassign
- nakedret
- revive
- staticcheck
- stylecheck
- unused
- "gocritic"
- "goimports"
- "govet"
- "ineffassign"
- "nakedret"
- "revive"
- "staticcheck"
- "stylecheck"
- "unused"

linters-settings:
gocritic:
disabled-checks:
# Appears to cause a false positive for Cgo calls
- dupSubExpr
# Appears to cause a false positive for Cgo calls
- "dupSubExpr"
goimports:
# Put imports beginning with prefix after 3rd-party packages.
local-prefixes: github.com/y-scope/clp-ffi-go
local-prefixes: "github.com/y-scope/clp-ffi-go"
nakedret:
# Completely disallow naked returns
max-func-lines: 0
revive:
rules:
- name: line-length-limit
severity: warning
- name: "line-length-limit"
severity: "warning"
disabled: false
arguments: [100]
staticcheck:
Expand All @@ -48,4 +48,3 @@ linters-settings:
# Redundant variable declaration (non-default)
- "-ST1023"
initialisms: [""]

0 comments on commit ae27a04

Please sign in to comment.