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

ci: fix lint, markdown links, and build #282

Merged
merged 12 commits into from
Nov 15, 2024
Merged

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Nov 15, 2024

Closes #269, #275, #279, #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.

@rootulp rootulp self-assigned this Nov 15, 2024
Copy link

coderabbitai bot commented Nov 15, 2024

Walkthrough

The pull request introduces various changes to the workflow configurations and documentation for the Go project. The .github/workflows/go.yml file has been streamlined by reorganizing steps and removing unnecessary ones, particularly focusing on testing. The linting workflow in .github/workflows/lint.yml specifies a fixed version for the linter action. The .golangci.yml file modifies the enabled linters, while the Makefile adds new targets for linting and link checking. Documentation updates are made in several README files, and the Go version is upgraded in go.mod.

Changes

File Change Summary
.github/workflows/go.yml Reorganized steps; removed "Format" and "Test and Coverage"; updated Go setup to use go-version-file.
.github/workflows/lint.yml Updated golangci-lint-action version to v1.61.0.
.golangci.yml Removed exportloopref linter; added copyloopvar.
Makefile Added lint and markdown-link-check targets for running linters and checking Markdown links.
README.md Removed Go version and codecov badges; core content unchanged.
go.mod Updated Go version from 1.21 to 1.23.
nmt_quint_model/README.md Updated Quint specification documentation for clarity and accuracy.
subrootpaths_test.go Modified TestPathGeneration to ensure correct variable capture in test cases.

Assessment against linked issues

Objective Addressed Explanation
Fix dead links to informal quint (269)

Possibly related issues

  • fix dead links #275: The changes in the README files address the dead links to the Quint documentation, which are also flagged in this issue.

🐇 In the garden, I hop and play,
With changes made to brighten the day.
Linting and testing, all in a row,
A cleaner path for our code to grow!
🌱✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.54%. Comparing base (62ec215) to head (8d72690).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #282      +/-   ##
==========================================
+ Coverage   68.01%   69.54%   +1.52%     
==========================================
  Files           6        6              
  Lines        1138     1484     +346     
==========================================
+ Hits          774     1032     +258     
- Misses        337      425      +88     
  Partials       27       27              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rootulp rootulp marked this pull request as ready for review November 15, 2024 16:00
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (5)
Makefile (2)

1-7: Consider enhancing the lint target with additional features.

The lint target implementation is clean and well-documented. However, consider these improvements:

  1. Add checks for tool availability
  2. Allow running individual linters via sub-targets
  3. Make the markdown file pattern configurable
+MARKDOWN_FILES ?= '**/*.md'
+
 ## lint: Run all linters; golangci-lint, markdownlint.
-lint:
+lint: lint-go lint-markdown
+
+## lint-go: Run golangci-lint
+lint-go:
+	@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not installed" >&2; exit 1; }
 	@echo "--> Running golangci-lint"
 	@golangci-lint run
+
+## lint-markdown: Run markdownlint
+lint-markdown:
+	@command -v markdownlint >/dev/null 2>&1 || { echo "markdownlint not installed" >&2; exit 1; }
 	@echo "--> Running markdownlint"
-	@markdownlint --config .markdownlint.yaml '**/*.md'
-
-.PHONY: lint
+	@markdownlint --config .markdownlint.yaml $(MARKDOWN_FILES)
+
+.PHONY: lint lint-go lint-markdown

9-13: Enhance markdown-link-check with configuration and performance improvements.

The implementation handles filenames safely with -print0 and -0 flags. Consider these improvements:

  1. Add tool availability check
  2. Add configuration file support
  3. Add directory exclusions
  4. Enable parallel processing for faster checks
+MARKDOWN_EXCLUDE_DIRS ?= -not -path "./vendor/*" -not -path "./node_modules/*"
+
 ## markdown-link-check: Check all markdown links.
 markdown-link-check:
+	@command -v markdown-link-check >/dev/null 2>&1 || { echo "markdown-link-check not installed" >&2; exit 1; }
 	@echo "--> Running markdown-link-check"
-	@find . -name \*.md -print0 | xargs -0 -n1 markdown-link-check
+	@find . -name \*.md $(MARKDOWN_EXCLUDE_DIRS) -print0 | xargs -0 -n1 -P4 markdown-link-check -c .markdown-link-check.json

Also, consider creating a .markdown-link-check.json configuration file to customize behavior:

{
  "ignorePatterns": [
    {
      "pattern": "^https?://localhost"
    }
  ],
  "retryOn429": true,
  "retryCount": 3,
  "fallbackRetryDelay": "30s"
}
.github/workflows/lint.yml (1)

25-25: Add a comment explaining version choice

Consider adding a comment explaining why this specific version was chosen. This helps future maintainers understand the rationale behind version pinning decisions.

+          # Pinned to v1.61.0 for stability and reproducible builds
           version: v1.61.0
nmt_quint_model/README.md (2)

Line range hint 84-84: Consider making the hardcoded path reference more explicit.

The documentation mentions a hardcoded path in simulation_test.go but doesn't specify the actual path. Consider adding the complete path for better clarity.


Line range hint 84-84: Fix unclosed code block.

The markdown code block at the end of the file is missing its closing triple backticks.

Add the following at the end of the file:

+ ```
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 62ec215 and 6f830bd.

📒 Files selected for processing (8)
  • .github/workflows/go.yml (1 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • .golangci.yml (1 hunks)
  • Makefile (1 hunks)
  • README.md (0 hunks)
  • go.mod (1 hunks)
  • nmt_quint_model/README.md (1 hunks)
  • subrootpaths_test.go (0 hunks)
💤 Files with no reviewable changes (2)
  • README.md
  • subrootpaths_test.go
✅ Files skipped from review due to trivial changes (1)
  • go.mod
🧰 Additional context used
🪛 actionlint
.github/workflows/go.yml

32-32: shellcheck reported issue in this script: SC2155:warning:1:8: Declare and assign separately to avoid masking return values

(shellcheck)

🔇 Additional comments (4)
.golangci.yml (1)

7-7: LGTM! Good update to use the recommended linter.

The replacement of the deprecated exportloopref with copyloopvar is the correct approach, as copyloopvar is the modern recommended linter for detecting loop variable reference issues.

Let's verify there are no existing loop-related issues that might be caught by the new linter:

✅ Verification successful

Based on the shell script results, I can see several loop variable usages in the codebase. However, all the identified loops appear to be using variables safely:

  1. Most loops are using range-based iteration with proper scoping of variables
  2. The variable declarations inside loops are properly scoped and don't have potential closure issues
  3. No instances of loop variables being captured in goroutines or closures were found
  4. The loops primarily deal with test cases, data processing, and tree operations in a safe manner

The switch to copyloopvar linter is appropriate and no issues were found.

The codebase demonstrates good practices in loop variable handling, and the new linter will help maintain this standard going forward.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential loop variable reference issues that the new linter might catch
# Look for range loops with variable declarations that might be problematic

# Search for range loops with variable declarations
ast-grep --pattern 'for $_ := range $_ {
  $$$
  var $_ $_
  $$$
}'

# Search for range loops with short variable declarations
ast-grep --pattern 'for $_ := range $_ {
  $$$
  $_ := $_
  $$$
}'

Length of output: 20505

Makefile (1)

11-12: Verify tool effectiveness for known dead links.

Let's verify if the markdown-link-check tool can detect the specific dead links mentioned in issue #269.

.github/workflows/go.yml (1)

15-17: LGTM! Using latest checkout action version.

The checkout step is properly configured using the latest stable version (v4) of the actions/checkout action.

nmt_quint_model/README.md (1)

64-66: Verify accessibility of the updated documentation links.

The links have been updated to point to the official Quint documentation site instead of the GitHub repository. Let's verify these links are accessible.

✅ Verification successful

All documentation links are accessible and working correctly

All three updated URLs return HTTP 200 status codes, confirming they are valid and accessible:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the updated documentation links are accessible
# Expected: All URLs should return HTTP 200 status code

urls=(
  "https://quint-lang.org/docs/lessons"
  "https://quint-lang.org/quint-cheatsheet.pdf"
  "https://quint-lang.org/docs/builtin"
)

for url in "${urls[@]}"; do
  echo "Checking $url"
  status_code=$(curl -s -o /dev/null -w "%{http_code}" "$url")
  echo "Status code: $status_code"
done

Length of output: 946

Comment on lines +31 to +34
- 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 ./...
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix PATH export and document coverage removal.

  1. The current PATH export could mask return values. Let's fix that.
  2. The removal of code coverage aligns with the PR objectives to simplify the workflow.

Apply this change to fix the PATH export:

       - name: Test
         run: |
-          export PATH=$PATH:$(go env GOPATH)/bin
+          GOPATH_BIN="$(go env GOPATH)/bin"
+          export PATH=$PATH:$GOPATH_BIN
           go test -v ./...

Consider creating a separate workflow for code coverage reporting if needed in the future. This separation of concerns will make the workflows more maintainable and focused.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- 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 ./...
- name: Test
run: |
GOPATH_BIN="$(go env GOPATH)/bin"
export PATH=$PATH:$GOPATH_BIN
go test -v ./...
🧰 Tools
🪛 actionlint

32-32: shellcheck reported issue in this script: SC2155:warning:1:8: Declare and assign separately to avoid masking return values

(shellcheck)

.github/workflows/go.yml Show resolved Hide resolved
.github/workflows/lint.yml Show resolved Hide resolved
@rootulp rootulp merged commit 2fb6332 into celestiaorg:main Nov 15, 2024
6 checks passed
@rootulp rootulp deleted the rp/fix-ci branch November 15, 2024 18:37
This was referenced Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix links to informal quint
3 participants