From 2fb6332677c336aeb6d1ee553def34792b2ad375 Mon Sep 17 00:00:00 2001 From: Rootul P Date: Fri, 15 Nov 2024 13:37:25 -0500 Subject: [PATCH] ci: fix lint, markdown links, and build (#282) Closes https://github.com/celestiaorg/nmt/issues/269, https://github.com/celestiaorg/nmt/issues/275, https://github.com/celestiaorg/nmt/issues/279, https://github.com/celestiaorg/nmt/issues/222 (b/c no longer relevant) Note: this PR removes code coverage. If we want it back, IMO it should be a separate workflow. ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced new Makefile targets for linting and markdown link checking. - **Bug Fixes** - Improved test reliability by ensuring correct variable capture in test cases. - **Documentation** - Updated README files for clarity and accuracy, including installation instructions and resource links. - **Chores** - Updated Go version in project configuration. - Streamlined workflow configurations for building and testing processes. --- .github/workflows/go.yml | 23 +++++++---------------- .github/workflows/lint.yml | 2 +- .golangci.yml | 2 +- Makefile | 13 +++++++++++++ README.md | 2 -- go.mod | 2 +- nmt_quint_model/README.md | 8 +++----- subrootpaths_test.go | 1 - 8 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7b681959..35d54a59 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,32 +12,23 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up Go 1.21 + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21 + go-version-file: 'go.mod' id: go - - name: Check out code into the Go module directory - uses: actions/checkout@v4 - - name: Get dependencies run: | go get -v -t -d ./... - - name: Format - run: diff -u <(echo -n) <(gofmt -d .) - - name: Build run: go build -v . - - name: Test and Coverage + - name: Test run: | export PATH=$PATH:$(go env GOPATH)/bin - go test -v -coverpkg=./... -covermode=atomic -coverprofile coverage.txt ./... - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true + go test -v ./... diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5e7fe76c..492acdca 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: .sum - uses: golangci/golangci-lint-action@v6 with: - version: latest + version: v1.61.0 args: --timeout 10m if: env.GIT_DIFF diff --git a/.golangci.yml b/.golangci.yml index 5ea76140..4109fa26 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: linters: enable: - - exportloopref + - copyloopvar - gofumpt - misspell - revive diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..ffaa58a9 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +## lint: Run all linters; golangci-lint, markdownlint. +lint: + @echo "--> Running golangci-lint" + @golangci-lint run + @echo "--> Running markdownlint" + @markdownlint --config .markdownlint.yaml '**/*.md' +.PHONY: lint + +## markdown-link-check: Check all markdown links. +markdown-link-check: + @echo "--> Running markdown-link-check" + @find . -name \*.md -print0 | xargs -0 -n1 markdown-link-check +.PHONY: markdown-link-check diff --git a/README.md b/README.md index 6d156707..e8f39ce8 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Namespaced Merkle Tree (NMT) -![Go version](https://img.shields.io/badge/go-1.21-blue.svg) [![Go Reference](https://pkg.go.dev/badge/github.com/celestiaorg/nmt.svg)](https://pkg.go.dev/github.com/celestiaorg/nmt) ![golangci-lint](https://github.com/celestiaorg/nmt/workflows/lint/badge.svg) ![Go](https://github.com/celestiaorg/nmt/workflows/Go/badge.svg) -![codecov.io](https://codecov.io/github/celestiaorg/nmt/coverage.svg?branch=main) A Namespaced Merkle Tree is > [...] an ordered Merkle tree that uses a modified hash function diff --git a/go.mod b/go.mod index b99ee4eb..749201e0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/celestiaorg/nmt -go 1.21 +go 1.23 require ( github.com/gogo/protobuf v1.3.2 diff --git a/nmt_quint_model/README.md b/nmt_quint_model/README.md index cdb83f51..7f792967 100644 --- a/nmt_quint_model/README.md +++ b/nmt_quint_model/README.md @@ -61,11 +61,9 @@ While this is not necessary, it is of great help when writing models. ## Basic resources -- a sequence of very gentle and fun tutorials -[here](https://github.com/informalsystems/quint/blob/main/tutorials/README.md) -- language [cheatsheet](https://github.com/informalsystems/quint/blob/main/doc/quint-cheatsheet.pdf) -- documentation for built-in operators -[here](https://github.com/informalsystems/quint/blob/main/doc/builtin.md) +- a sequence of [lessons](https://quint-lang.org/docs/lessons) +- language [cheatsheet](https://quint-lang.org/quint-cheatsheet.pdf) +- documentation for [built-in operators](https://quint-lang.org/docs/builtin) ## REPL diff --git a/subrootpaths_test.go b/subrootpaths_test.go index d2d2b677..c3205765 100644 --- a/subrootpaths_test.go +++ b/subrootpaths_test.go @@ -132,7 +132,6 @@ func TestPathGeneration(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.desc, func(t *testing.T) { paths, err := GetSubrootPaths(tc.input.squareSize, tc.input.startNode, tc.input.length) if !reflect.DeepEqual(pathResult(paths), tc.want) {