Skip to content

Commit 5bea462

Browse files
committed
Split linting, and lint in container
1 parent 24e90f8 commit 5bea462

File tree

6 files changed

+45
-19
lines changed

6 files changed

+45
-19
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
needs-python: ${{ true }}
1111
needs-node: ${{ false }}
1212
- name: Lint
13-
command: make lint BINDIR="$(dirname $(which python))"
13+
command: bin/lint
1414
needs-python: ${{ true }}
15-
needs-node: ${{ true }}
15+
needs-node: ${{ false }}
1616
- name: Documentation
1717
command: make docs BINDIR="$(dirname $(which python))"
1818
needs-python: ${{ true }}
@@ -33,6 +33,10 @@ jobs:
3333
command: bin/static_tests
3434
needs-python: ${{ false }}
3535
needs-node: ${{ true }}
36+
- name: Static Lint
37+
command: bin/static_lint
38+
needs-python: ${{ false }}
39+
needs-node: ${{ true }}
3640
- name: Static Pipeline
3741
command: bin/static_pipeline
3842
needs-python: ${{ false }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ RUN set -x \
111111
install --no-binary hiredis \
112112
-r /tmp/requirements/deploy.txt \
113113
-r /tmp/requirements/main.txt \
114-
$(if [ "$DEVEL" = "yes" ]; then echo '-r /tmp/requirements/tests.txt'; fi) \
114+
$(if [ "$DEVEL" = "yes" ]; then echo '-r /tmp/requirements/tests.txt -r /tmp/requirements/lint.txt'; fi) \
115115
$(if [ "$THEME_REPO" != "" ]; then echo '-r /tmp/requirements/theme.txt'; fi) \
116116
&& find /opt/warehouse -name '*.pyc' -delete
117117

Makefile

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,10 @@ reformat: .state/env/pyvenv.cfg
105105
$(BINDIR)/isort *.py warehouse/ tests/
106106
$(BINDIR)/black *.py warehouse/ tests/
107107

108-
lint: .state/env/pyvenv.cfg
109-
$(BINDIR)/flake8 .
110-
$(BINDIR)/black --check *.py warehouse/ tests/
111-
$(BINDIR)/isort --check *.py warehouse/ tests/
112-
$(BINDIR)/doc8 --allow-long-titles README.rst CONTRIBUTING.rst docs/ --ignore-path docs/_build/
113-
$(BINDIR)/curlylint ./warehouse/templates
114-
115-
ifneq ($(filter false,$(TRAVIS) $(GITHUB_ACTIONS)),)
116-
# We're either on Travis or GitHub Actions, so we can lint static files locally
117-
./node_modules/.bin/eslint 'warehouse/static/js/**' '**.js' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
118-
./node_modules/.bin/sass-lint --verbose
119-
else
120-
# We're not on Travis or GitHub Actions, so we should lint static files inside the static container
121-
docker-compose run --rm static ./node_modules/.bin/eslint 'warehouse/static/js/**' '**.js' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
122-
docker-compose run --rm static ./node_modules/.bin/sass-lint --verbose
123-
endif
108+
lint: .state/docker-build
109+
docker-compose run --rm web env -i ENCODING="C.UTF-8" \
110+
PATH="/opt/warehouse/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
111+
bin/lint && bin/static_lint
124112

125113
docs: .state/env/pyvenv.cfg
126114
$(MAKE) -C docs/ doctest SPHINXOPTS="-W" SPHINXBUILD="$(BINDIR)/sphinx-build"

bin/lint

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Click requires us to ensure we have a well configured environment to run
5+
# our click commands. So we'll set our environment to ensure our locale is
6+
# correct.
7+
export LC_ALL="${ENCODING:-en_US.UTF-8}"
8+
export LANG="${ENCODING:-en_US.UTF-8}"
9+
10+
COMMAND_ARGS=$@
11+
12+
# Print all the followng commands
13+
set -x
14+
15+
# Actually run our tests.
16+
python -m flake8 .
17+
python -m black --check *.py warehouse/ tests/
18+
python -m isort --check *.py warehouse/ tests/
19+
python -m doc8 --allow-long-titles README.rst CONTRIBUTING.rst docs/ --ignore-path docs/_build/
20+
python -m curlylint ./warehouse/templates

bin/static_lint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
set -x
4+
5+
# Click requires us to ensure we have a well configured environment to run
6+
# our click commands. So we'll set our environment to ensure our locale is
7+
# correct.
8+
export LC_ALL="${ENCODING:-en_US.UTF-8}"
9+
export LANG="${ENCODING:-en_US.UTF-8}"
10+
11+
# Actually run our tests.
12+
./node_modules/.bin/eslint 'warehouse/static/js/**' '**.js' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
13+
./node_modules/.bin/sass-lint --verbose

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ services:
8585
- ./htmlcov:/opt/warehouse/src/htmlcov:z
8686
- .coveragerc:/opt/warehouse/src/.coveragerc:z
8787
- packages:/var/opt/warehouse/packages
88+
- ./bin:/opt/warehouse/src/bin:z
8889
ports:
8990
- "80:8000"
9091

0 commit comments

Comments
 (0)