From 222f72d7dbd97e4f3bdc3ee343ae7885a4292185 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Sun, 12 May 2024 13:57:10 +0200 Subject: [PATCH 1/4] docs: update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2a06313..6121e870 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ My next focus areas: - [ ] Refactoring, polish and tests. - [ ] Make use of `pcall` to handle potential errors gracefully. -- [ ] Set up CI for linting, testing, require changes via PR. +- [x] Set up CI for linting, testing, require changes via PR. - [ ] Versioning and releases via release-please. - [x] Ability to debug test from sub-project (see [nvim-dap-go#80](https://github.com/leoluz/nvim-dap-go/issues/80)). From 638df1274a28800d781c1ec962c6120858b055fc Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Sun, 12 May 2024 13:17:29 +0200 Subject: [PATCH 2/4] feat: add lua linting --- .github/workflows/lint.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..6d0663a7 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,14 @@ +name: lint +on: [pull_request, workflow_dispatch] +jobs: + lua: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check formatting + uses: JohnnyMorganz/stylua-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . From aff2748f931b1078be882cf5f9db9253b85533c5 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Sun, 12 May 2024 13:21:27 +0200 Subject: [PATCH 3/4] feat: add go linting --- .github/workflows/format.yml | 38 ++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 15 ++++++++------ .github/workflows/test.yml | 12 ++++++++++++ .github/workflows/vuln.yml | 31 +++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/format.yml create mode 100644 .github/workflows/vuln.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..861ce68e --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,38 @@ +name: format +on: [pull_request, workflow_dispatch] +jobs: + lua: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check formatting + uses: JohnnyMorganz/stylua-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . + go: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.22 + - name: Run gci + run: | + go install github.com/daixiang0/gci@latest + gci write --skip-generated --skip-vendor -s standard -s default . + working-directory: ./tests/go + - name: Run golines + run: | + go install mvdan.cc/gofumpt@latest + go install github.com/segmentio/golines@latest + golines --base-formatter=gofumpt --ignore-generated --tab-len=1 --max-len=120 --write-output . + working-directory: ./tests/go + - name: Check git diff + run: | + git diff --exit-code + working-directory: ./tests/go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6d0663a7..27c16465 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,14 +1,17 @@ name: lint on: [pull_request, workflow_dispatch] jobs: - lua: + go: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Check formatting - uses: JohnnyMorganz/stylua-action@v2 + - name: Set up Go + uses: actions/setup-go@v2 with: - token: ${{ secrets.GITHUB_TOKEN }} - version: latest - args: --check . + go-version: 1.22 + - name: Run golangci-lint + run: | + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + golangci-lint run ./... + working-directory: ./tests/go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d76b68c4..c7704f39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,3 +23,15 @@ jobs: ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start - name: Run tests run: nvim --headless -c "PlenaryBustedDirectory test {minimal_init = 'tests/minimal_init.lua', sequential = true}" + go: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.22 + - name: Check tests + run: go test ./... + working-directory: ./tests/go diff --git a/.github/workflows/vuln.yml b/.github/workflows/vuln.yml new file mode 100644 index 00000000..2a58045c --- /dev/null +++ b/.github/workflows/vuln.yml @@ -0,0 +1,31 @@ +name: vuln +on: [pull_request, workflow_dispatch] +jobs: + lua: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check formatting + uses: JohnnyMorganz/stylua-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . + go: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.22 + - name: Go vet (vulnerabilities) + run: go vet ./... + working-directory: ./tests/go + - name: Run gosec (security) + run: | + go install github.com/securego/gosec/v2/cmd/gosec@latest + gosec ./... + working-directory: ./tests/go From 5d0f854e8260859f6bccf568ce7a0ee6eb5ca9f3 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Sun, 12 May 2024 14:16:15 +0200 Subject: [PATCH 4/4] fix: run on main branch --- .github/workflows/format.yml | 7 ++++++- .github/workflows/lint.yml | 7 ++++++- .github/workflows/test.yml | 7 ++++++- .github/workflows/vuln.yml | 18 ++++++------------ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 861ce68e..539587ef 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,5 +1,10 @@ name: format -on: [pull_request, workflow_dispatch] +on: + workflow_dispatch: + pull_request: + push: + branches: + - main jobs: lua: runs-on: ubuntu-latest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 27c16465..f67c49ed 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,10 @@ name: lint -on: [pull_request, workflow_dispatch] +on: + workflow_dispatch: + pull_request: + push: + branches: + - main jobs: go: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c7704f39..079fb51f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,10 @@ name: test -on: [pull_request, workflow_dispatch] +on: + workflow_dispatch: + pull_request: + push: + branches: + - main jobs: nvim: strategy: diff --git a/.github/workflows/vuln.yml b/.github/workflows/vuln.yml index 2a58045c..0daf0bc9 100644 --- a/.github/workflows/vuln.yml +++ b/.github/workflows/vuln.yml @@ -1,17 +1,11 @@ name: vuln -on: [pull_request, workflow_dispatch] +on: + workflow_dispatch: + pull_request: + push: + branches: + - main jobs: - lua: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Check formatting - uses: JohnnyMorganz/stylua-action@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: latest - args: --check . go: runs-on: ubuntu-latest steps: