Commit Graph

83 Commits

Author SHA1 Message Date
Ava Chow
f640b323bd
Merge bitcoin/bitcoin#30723: lint: Speed up and fix flake8 checks
fafdb7df34 lint: Speed up flake8 checks (MarcoFalke)
faf17df7fb lint: Document missing py_lint dependency (MarcoFalke)
faebeb828f lint: Remove python whitespace and shadowing lint rules (MarcoFalke)
7777047835 lint: Remove python lint rules that are SyntaxError (MarcoFalke)
faaf3e53f0 test: [refactor] Fix F841 flake8 (MarcoFalke)
444421db69 test: [refactor] Fix E714 pycodestyle (MarcoFalke)

Pull request description:

  The checks have many issues:

  * Some checks that could in theory hide bugs are not applied -> Fix them and apply them going forward
  * Some checks are redundant Python 2 checks, or of low value -> Remove them
  * The checks are slow -> Speed them up from ~10 seconds to about ~20 milliseconds

ACKs for top commit:
  davidgumberg:
    review and tested reACK fafdb7df34
  kevkevinpal:
    ACK [fafdb7d](fafdb7df34)
  achow101:
    ACK fafdb7df34

Tree-SHA512: a0488b722cfaf7071bd6848cd3be002e0b6c38af80d8b5cbb08613c0b174ef63277289f960db8ac31adb09fe563a4973203b8fb10b83cbcfdc6f0ef39bd04410
2024-09-04 15:35:52 -04:00
fanquake
a865494dee
lint: remove autotools packages 2024-08-29 16:06:34 +01:00
MarcoFalke
fafdb7df34
lint: Speed up flake8 checks
Previously they may have taken more than 10 seconds. Now they should
finish in less than one second.

This also allows to drop one dependency to be installed.
2024-08-29 07:03:42 +02:00
MarcoFalke
fac7b7ff7f
lint: Find function calls in default arguments 2024-08-09 08:11:16 +02:00
MarcoFalke
fa7bee13bf
lint: Use git clone --depth=1
No need to download and store more than that.
2024-07-22 17:30:12 +02:00
MarcoFalke
fa8d73e86e
lint: Use consistent out-of-tree build for python and test_runner
This mirrors the build by ./ci/lint_imagefile, which is done out-of-tree
in "/".

Otherwise, there could be errors due to a dirty tree.
2024-07-22 14:01:24 +02:00
MarcoFalke
fa9ad59f87
lint: Use $CI_RETRY_EXE when building ./ci/lint_imagefile
Previous code was confusing and brittle. For example, the full import
"source ./ci/test/00_setup_env.sh" and $PATH overwrite was not needed.

Fix it by simply copying the exe to /ci_retry and use that in
$CI_RETRY_EXE.

This is also a fix, because previously ci/lint_imagefile did use an
empty $CI_RETRY_EXE.
2024-07-22 13:20:24 +02:00
willcl-ark
4d942547a8
lint: ignore files ignored by git in mlc
Updating to MLC v0.18.0 includes a new feature which will ignore all
files ignored by git: `--gitignore`.

This helps avoid false-positives flagged by this linter in non-project
files, such as a developer might expect to have in their directory (e.g.
guix-builds, python venvs, etc.)
2024-07-03 09:46:15 +01:00
willcl-ark
4b7d984269
lint: add markdown hyperlink checker
This adds a markdown hyperlink check task to the lint test_runner. It
relies on having the [`mlc`](https://crates.io/crates/mlc) binary found
on $PATH, but will fail with `success` if the binary is not found.

`mlc` is also added to the ci/04_install.sh script run by the
containerfile.

Note that broken markdown hyperlinks will be detected in untracked
markdown files found in a dirty working directory (including e.g.
.venv).
2024-05-24 12:11:50 +01:00
fanquake
601edd8ee8
ci: use codespell 2.2.6 2024-03-26 16:51:46 +00:00
MarcoFalke
fa1146d01b
lint: Fix COMMIT_RANGE issues 2024-03-21 20:15:08 +01:00
MarcoFalke
fa31908ea8
lint: Check for missing or redundant bitcoin-config.h includes 2024-02-20 15:03:23 +01:00
MarcoFalke
faff3e3b46
lint: Report all lint errors instead of early exit 2023-11-13 18:08:10 +01:00
fanquake
6342348072
Merge bitcoin/bitcoin#28076: util: Replace std::filesystem with util/fs.h
bbbbdb0cd5 ci: Add filesystem lint check (MarcoFalke)
fada2f9110 refactor: Replace <filesystem> with <util/fs.h> (MarcoFalke)

Pull request description:

  Using `std::filesystem` is problematic:

  * There is a `fs` namespace wrapper for it. So having two ways to achieve the same is confusing.
  * Not using the `fs` wrapper is dangerous and buggy, because it disables known bugs by deleting problematic functions.

  Fix all issues by removing use of it and adding a linter to avoid using it again in the future.

ACKs for top commit:
  TheCharlatan:
    ACK  bbbbdb0cd5
  fanquake:
    ACK bbbbdb0cd5 🦀

Tree-SHA512: 0e2d49742b08eb2635e6fce41485277cb9c40fe20b81017c391d3472a43787db1278a236825714ca1e41c9d2f59913865cfb0c649e3c8ab1fb598c849f80c660
2023-11-13 14:10:54 +00:00
MarcoFalke
6889a80766
ci: Add missing CI_RETRY_EXE before git clone 2023-10-13 10:37:34 +01:00
MarcoFalke
bbbbdb0cd5
ci: Add filesystem lint check 2023-09-14 18:58:44 +02:00
Jon Atack
bee2d57a65 script: update flake8 to 6.1.0
and touch up the spelling returned by lint-spelling.py
2023-07-31 12:14:06 -06:00
MarcoFalke
fa8dcdcc8b
ci: Set PATH inside the CI env
This is needed for the next commit.

This also requires dropping CI_RETRY from the docker build step, which
is fine, because CI_RETRY should be called inside the build script, not
outside.

Also, fix a doc typo.
2023-07-24 16:14:24 +02:00
MarcoFalke
ffff4b5dc5
lint: Add missing set -ex to ci/lint/06_script.sh
This is needed for the container-entrypoint.sh

Also, remove unused `source` from ci/lint_run_all.sh, since it is the
last step.
2023-07-19 11:39:50 +02:00
MarcoFalke
fadc5232f4
doc: Add doc comment to ci/test_imagefile
(Similar to the doc comment in ci/lint_imagefile)

Also, rename docker-entrypoint.sh to container-entrypoint.sh

Also, add copyright header to touched files.
2023-07-19 11:27:28 +02:00
MarcoFalke
fa2f18ad8e
ci: Use DOCKER_BUILDKIT for lint image
Can be reviewed with:
--color-moved=dimmed-zebra  --ignore-all-space
2023-07-16 13:18:18 +02:00
Jon Atack
146c861da2 script: update linter dependencies 2023-06-29 16:14:07 -06:00
fanquake
015cc5e588
lint: stop ignoring LIEF imports
Type stubs are now available as of 0.13.0.
See https://github.com/lief-project/LIEF/issues/650.
2023-05-29 10:23:52 +01:00
MarcoFalke
fac395e5eb
ci: Bump ci/lint/Dockerfile
This bump should not be needed, see discussion starting at
https://github.com/bitcoin/bitcoin/pull/27483#issuecomment-1517739626
2023-04-21 14:31:13 +02:00
MarcoFalke
250598a905
Merge bitcoin/bitcoin#26906: test: add an easy way to run linters locally
b68e5a7fef lint: specify the right commit range when running locally (James O'Beirne)
dff7ed5732 test: add an easy way to run linters locally (James O'Beirne)

Pull request description:

  Adds a Dockerfile configuration ~~(originally written mostly by fanquake)~~ that allows straightforward running of linters with compatible versions locally. This removes a ton of annoyance when trying to appease CI, because many of the linter versions are quite old and difficult to maintain locally.

  I realize that people may not be thrilled to add more ancillary tooling to the repo, but I think this makes a lot of sense given the linter versions listed in this container configuration are dictated by this repo (within the CI configuration), so having these things live in two separate places is a recipe for version mismatches.

  Eventually we can likely just use this container on CI directly to avoid any chance of inconsistencies between local dev experience and CI.

ACKs for top commit:
  aureleoules:
    ACK b68e5a7fef
  stickies-v:
    ACK b68e5a7fe
  john-moffett:
    ACK b68e5a7fef

Tree-SHA512: 7ef7a5dae023d81fdb6296d5d92dfa074ee321c7993e607c9f014d0f21c91558611aa00fc3ce1edc7b5e68371aea0d27fa1931291a79bb867a6c783bb536775f
2023-01-19 19:01:28 +01:00
James O'Beirne
b68e5a7fef lint: specify the right commit range when running locally
When running lints on Cirrus, a special envvar is set ($CIRRUS_PR);
emulate this when running linters locally by setting $LOCAL_BRANCH
to any value.
2023-01-18 09:48:14 -05:00
James O'Beirne
dff7ed5732 test: add an easy way to run linters locally
Adds a Dockerfile configuration
that allows straightforward running of linters with compatible versions
locally. This removes a ton of annoyance when trying to appease CI,
because many of the linter versions are quite old and difficult to
maintain locally.

I realize that people may not be thrilled to more ancillary tooling to
the repo, but I think this makes a lot of sense given the linter
versions listed in this container configuration are dictated by this
repo (within the CI configuration), so having these things live in
two separate places is a recipe for version mismatches.

Eventually we can likely just use this container on CI directly to avoid
any chance of inconsistencies between local dev experience and CI.
2023-01-18 09:48:08 -05:00
MarcoFalke
fa87d71872
ci: Add missing lint dependency 2023-01-17 19:09:44 +01:00
MarcoFalke
01ec5308bf
Merge bitcoin/bitcoin#26716: ci: Build python from source in "lint" task
123043e99c ci: Bump lint task image to Ubuntu Jammy (Hennadii Stepanov)
9b86114058 ci: Use pyenv's `python-build` to install Python in lint task (Hennadii Stepanov)

Pull request description:

  This PR:
  - is an alternative to bitcoin/bitcoin#26581 and bitcoin/bitcoin#26637
  - closes bitcoin/bitcoin#26548

  Key advantages of this PR over others:
  - it uses pyenv's `python-build` [standalone](https://github.com/pyenv/pyenv/tree/master/plugins/python-build#using-python-build-standalone)
  - requires no additional computational resources

  Note for testing. The lint task must success regardless of whether the `python_cache` is populated or invalidated.

ACKs for top commit:
  MarcoFalke:
    ACK 123043e99c
  fanquake:
    ACK 123043e99c

Tree-SHA512: ba0fcdd4f2939a59692b173dcd1f5704444cfcfbb8111538c6f8160056d0536bba250e4f9b0f8c66f8b454e52034bf36ffe6afae76cdc0f7cc5b58b576d790ba
2023-01-17 18:35:47 +01:00
Hennadii Stepanov
123043e99c
ci: Bump lint task image to Ubuntu Jammy 2023-01-16 13:30:00 +00:00
Hennadii Stepanov
9b86114058
ci: Use pyenv's python-build to install Python in lint task 2023-01-16 13:29:44 +00:00
MarcoFalke
bf3b589413
Merge bitcoin/bitcoin#26791: ci: Properly set COMMIT_RANGE in lint task
fa5cbf2290 ci: Properly set COMMIT_RANGE in lint task (MarcoFalke)

Pull request description:

  Currently the variable holds (apart from the commits in the pull request) all commits to master since the pull was opened.

  This is problematic, because already merged commits are linted in unrelated pulls, leading to:

  * Wasted resources. For example, currently the lint task may take 9 minutes, when it should take 1. See https://cirrus-ci.com/task/6032782770569216?logs=lint#L1449
  * False failures. For example, when a "wrong" commit is in master it can lead to some pulls failing unrelatedly, and others not.

  Now that the CI has the `/merge` commit (since commit fad7281d78), `COMMIT_RANGE` can simply be set to `HEAD~..HEAD` to only hold the changes in the pull.

ACKs for top commit:
  fanquake:
    ACK fa5cbf2290

Tree-SHA512: e85fca4ca9d2615ddd2544403485e06885769a3f70bca297e23eefda2a1d28f47c5271f6adfa6ce0e5e972335c78098b76e0db4b109f59d0986bf508cef7528f
2023-01-04 13:56:45 +01:00
Jon Atack
1e5e87cec3 script: update python linter dependencies 2023-01-03 11:05:09 -08:00
MarcoFalke
fa5cbf2290
ci: Properly set COMMIT_RANGE in lint task 2023-01-02 14:05:23 +01:00
Hennadii Stepanov
306ccd4927
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
- 2021: f47dda2c58
- 2020: fa0074e2d8
- 2019: aaaaad6ac9
2022-12-24 23:49:50 +00:00
MarcoFalke
d415b7261c
Merge bitcoin/bitcoin#26588: ci: Skip COMMIT_RANGE if no CIRRUS_PR
fad1c55301 lint: Skip COMMIT_RANGE if no CIRRUS_PR (MarcoFalke)

Pull request description:

  It doesn't make sense to run this for non-PRs, because:

  * There are known whitespace "violations" in previous commits, so the lint may fail
  * Once the changes are merged, it is too late to fix them up (force pushes are illegal)
  * It isn't possible to determine which commits to run on if there is no reference branch (target branch of the pull request)

  Moreover, the test fails on non-master:

  * https://github.com/bitcoin/bitcoin/runs/8664441400

  Fix all issues by skipping it.

ACKs for top commit:
  hebasto:
    ACK fad1c55301, also tested in my personal Cirrus account.

Tree-SHA512: be15f00e2b2a9069583833545883e0e5968a33d2455dad59e6fb47c1102b4dd16ef932e9ba945e29e9d941e6c17bd531a02c66b0491097801be6bda476875537
2022-11-28 17:18:29 +01:00
MarcoFalke
fad1c55301
lint: Skip COMMIT_RANGE if no CIRRUS_PR 2022-11-28 11:09:30 +01:00
MacroFake
fa04376554
Remove clang-format from lint task
clang-format could be used in scripted diffs, but remained largely
unused.
2022-10-05 10:52:42 +02:00
Hennadii Stepanov
ac1d99240a
ci: Move git config commands into script where they are used 2022-10-04 08:51:55 +01:00
MacroFake
d8ded8bc08 ci: Use git2.34 for lint task 2022-09-28 19:58:13 +02:00
Jon Atack
8f2010de6e Bump codespell version to 2.2.1 2022-09-15 12:53:32 +02:00
fanquake
d873ff96e5
refactor: cleanups post unsubtree'ing univalue
Mostly changes to remove src/univalue exceptions from the various linters,
and the required code changes to make them happy. As well as minor doc
changes.
2022-06-15 12:56:44 +01:00
Martin Leitner-Ankerl
64d72c4c87 test: rename lint-all.py to all-lint.py
That way it is impossible for the script to call itself.
2022-06-07 10:22:45 +02:00
hiago
29f44fed36 Converting lint-all.sh to lint-all.py.
Converting `lint-all.sh` to `lint-all.py`.
2022-04-26 06:25:01 -03:00
fanquake
864772c4f7
lint: mypy 0.942 2022-04-07 12:50:54 +01:00
fanquake
38031adee8
lint: flake8 4.0.1 2022-04-07 12:50:10 +01:00
fanquake
eaf712c801
lint: codespell 2.1.0 2022-04-07 12:49:51 +01:00
Hennadii Stepanov
f47dda2c58
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
* 2020: fa0074e2d8
* 2019: aaaaad6ac9
2021-12-30 19:36:57 +02:00
Hennadii Stepanov
5202bd1dc0
test: Bump shellcheck version to 0.8.0 2021-11-30 21:15:40 +02:00
Hennadii Stepanov
fe0ff569ea
test: Enable SC2046 shellcheck rule 2021-11-13 18:05:26 +02:00