Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Enable trunk superlinter #407

Merged
merged 3 commits into from
Nov 9, 2022
Merged

Enable trunk superlinter #407

merged 3 commits into from
Nov 9, 2022

Conversation

dapirian
Copy link
Contributor

@dapirian dapirian commented Nov 5, 2022

Trunk (docs) is a tool to run dozens of linters, formatters, static analyzers, and security checking tools.

This PR turns on 21 linters. About ~6 of them were already in use, the rest are new. Trunk handles the installation, versioning, hermeticity, and upgrading of them.

It has a bunch of features that no similar projects have (unified reporting, batching, caching, pre-existing issue detection on PRs, git-aware, git hooks management, & more). If you'd like to try for yourself w/ this PR: curl https://get.trunk.io -fsSL | bash

I've integrated some of the checks Trunk doesn't yet have, or which are specific to this repo:

  • Support for 'check/go/mod'
  • Support for goreleaser check

Trunk is a plugin-able system, so these other integrations can happen if this PR lands:

  • Integrate the Trunk GitHub Action to the CI workflow(s)
  • Support for helm lint
  • Support for tk fmt

There are a couple things to discuss too:

  • Trunk also supports "config hiding": you can put linter configs in .trunk/config instead of your repo root and as long as the linter is run through trunk, it'll pick it up. This is optional, you can also put linter configs in the root, up to you.
  • Whether to turn on trunk githooks management (decision: no for now, maybe later after this lands)

For now, this just adds the trunk config files, there for optional use either by folks using trunk check and trunk fmt from the trunk command line tool, or via the trunk vscode extension.


trunk-phlare

full disclosure: Trunk is my project, and I'm trying to spread the word, but I legit think it will help phlare a lot!

@CLAassistant
Copy link

CLAassistant commented Nov 5, 2022

CLA assistant check
All committers have signed the CLA.

@cyriltovena
Copy link
Collaborator

cyriltovena commented Nov 7, 2022

Do you think we could include check/go/mod target too ? I also don't want to have the requirement to install anything if possible we should place trunk in .bin/ the first time if not there.

@cyriltovena
Copy link
Collaborator

FYI prettier seems to go nuts:

  [error] Invalid configuration file `grafana/phlare-datasource/CHANGELOG.md`: Cannot find module './node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json'
        [error] Require stack:
        [error] - /Users/cyril/work/phlare/grafana/phlare-datasource/.prettierrc.js
        [error] - /Users/cyril/.cache/trunk/linters/prettier/2.7.1-f62fd92d0515490388e6d5c6ff0f24a0/node_modules/prettier/third-party.js
        [error] - /Users/cyril/.cache/trunk/linters/prettier/2.7.1-f62fd92d0515490388e6d5c6ff0f24a0/node_modules/prettier/index.js
        [error] - /Users/cyril/.cache/trunk/linters/prettier/2.7.1-f62fd92d0515490388e6d5c6ff0f24a0/node_modules/prettier/cli.js
        [error] - /Users/cyril/.cache/trunk/linters/prettier/2.7.1-f62fd92d0515490388e6d5c6ff0f24a0/node_modules/prettier/bin-prettier.js

@dapirian
Copy link
Contributor Author

dapirian commented Nov 7, 2022

Do you think we could include check/go/mod target too ?

yes! done

if possible we should place trunk in .bin/ the first time if not there.

👌 done. Also note for vscode users, if they have the trunk vscode extension installed it'll just work

FYI prettier seems to go nuts:

Since you use prettier plugins in 2 subdirectories, and prettier works by looking for plugins installed in the nearest node_modules to what it's linting, you need to yarn install in those 2 directories for prettier to work in them

@dapirian
Copy link
Contributor Author

dapirian commented Nov 8, 2022

@cyriltovena I think this is good to go if you want to try it out again.

I'm also improving the tool on our end for the next release for a few rough edges this exposed:

  • The issue you hit switching from a trunk-enabled-with-githooks branch to a non-trunk-enabled branch
  • More obvious messaging when using prettier plugins (in this case, telling you to yarn install and why, and perhaps make this automatic too in the future)

Thanks!

Copy link
Collaborator

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

let's give it a go.

@cyriltovena cyriltovena merged commit 23b5705 into grafana:main Nov 9, 2022
@simonswine simonswine mentioned this pull request Jun 7, 2023
simonswine added a commit to simonswine/phlare that referenced this pull request Jun 7, 2023
Was contributed as part of grafana#407, not kept up-to-date since.
cyriltovena pushed a commit that referenced this pull request Jun 7, 2023
Was contributed as part of #407, not kept up-to-date since.
simonswine pushed a commit to simonswine/pyroscope that referenced this pull request Jun 30, 2023
simonswine added a commit to simonswine/pyroscope that referenced this pull request Jun 30, 2023
Was contributed as part of grafana/phlare#407, not kept up-to-date since.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants