-
Notifications
You must be signed in to change notification settings - Fork 37.6k
test: add an easy way to run linters locally #26906
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# See test/lint/README.md for usage. | ||
# | ||
# This container basically has to live in this directory in order to pull in the CI | ||
# install scripts. If it lived in the root directory, it would have to pull in the | ||
# entire repo as docker context during build; if it lived elsewhere, it wouldn't be | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Would you have preferred it lived in root? I think it makes more sense in git diffdiff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 000000000..142df6af9
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,2 @@
+*
+!/ci/lint
\ No newline at end of file
diff --git a/ci/lint/Dockerfile b/Dockerfile
similarity index 91%
rename from ci/lint/Dockerfile
rename to Dockerfile
index 03c20c728..87c9bb85a 100644
--- a/ci/lint/Dockerfile
+++ b/Dockerfile
@@ -16,8 +16,8 @@ ENV LC_ALL=C.UTF-8
ENV SKIP_PYTHON_INSTALL=1
# Must be built from ./ci/lint/ for these paths to work.
-COPY ./docker-entrypoint.sh /entrypoint.sh
-COPY ./04_install.sh /install.sh
+COPY ./ci/lint/docker-entrypoint.sh /entrypoint.sh
+COPY ./ci/lint/04_install.sh /install.sh
RUN /install.sh && \
echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For reference, you can avoid passing the full context by using buildkit or podman. See |
||
# able to make back-references to pull in the install scripts. So here it lives. | ||
|
||
FROM python:3.7-buster | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV LC_ALL=C.UTF-8 | ||
|
||
# This is used by the 04_install.sh script; we can't read the Python version from | ||
# .python-version for the same reasons as above, and it's more efficient to pull a | ||
# preexisting Python image than it is to build from source. | ||
ENV SKIP_PYTHON_INSTALL=1 | ||
|
||
# Must be built from ./ci/lint/ for these paths to work. | ||
COPY ./docker-entrypoint.sh /entrypoint.sh | ||
COPY ./04_install.sh /install.sh | ||
|
||
RUN /install.sh && \ | ||
echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \ | ||
jamesob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
chmod 755 /entrypoint.sh && \ | ||
rm -rf /var/lib/apt/lists/* | ||
maflcko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
WORKDIR /bitcoin | ||
ENTRYPOINT ["/entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
export LC_ALL=C | ||
|
||
# Fixes permission issues when there is a container UID/GID mismatch with the owner | ||
# of the mounted bitcoin src dir. | ||
git config --global --add safe.directory /bitcoin | ||
|
||
if [ -z "$1" ]; then | ||
LOCAL_BRANCH=1 bash -ic "./ci/lint/06_script.sh" | ||
else | ||
exec "$@" | ||
fi |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,23 @@ | ||||||
This folder contains lint scripts. | ||||||
|
||||||
Running locally | ||||||
=============== | ||||||
|
||||||
To run linters locally with the same versions as the CI environment, use the included | ||||||
Dockerfile: | ||||||
|
||||||
```sh | ||||||
cd ./ci/lint | ||||||
docker build -t bitcoin-linter . | ||||||
|
||||||
cd /root/of/bitcoin/repo | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we're already assuming starting in the root 2 lines up, I'd just replace this with
Suggested change
|
||||||
docker run --rm -v $(pwd):/bitcoin -it bitcoin-linter | ||||||
``` | ||||||
|
||||||
After building the container once, you can simply run the last command any time you | ||||||
want to lint. | ||||||
|
||||||
|
||||||
check-doc.py | ||||||
============ | ||||||
Check for missing documentation of command line options. | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.