Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b2f24b9
Update requirements and dockerfile
nbirillo Jun 9, 2021
a962c6a
Use Dockerfile in Github Action
nbirillo Jun 9, 2021
b2e1230
Ignore a part of flake8 issues
nbirillo Jun 9, 2021
135ac5d
Ignore flake8 inspections
nbirillo Jun 9, 2021
fec2189
Separate docker file into two: for prod and for dev
nbirillo Jun 10, 2021
4879fe0
Delete `
nbirillo Jun 10, 2021
b569e7b
Fix test_range_of_lines
nbirillo Jun 10, 2021
c6a3cda
Fix pylint and flake8 tests
nbirillo Jun 10, 2021
9b0df6e
Fix pylint tests
nbirillo Jun 10, 2021
b048718
Check styles by flake8
nbirillo Jun 10, 2021
a5d7c50
Fix C408 issue
nbirillo Jun 10, 2021
442db7a
Move production Dockerfile
nbirillo Jun 16, 2021
88b5cd5
Fix Dockefile for production
nbirillo Jun 16, 2021
6f9efea
Set up Eslint in the DockerFile for production
nbirillo Jun 16, 2021
5a11885
Delete one case from flake8 tests
nbirillo Jun 16, 2021
8accd4e
Add pathlib into whitelist
nbirillo Jun 16, 2021
fa0b852
Delete Path from setup.py
nbirillo Jun 16, 2021
093c297
Ignore pathlib
nbirillo Jun 16, 2021
a774acb
Don't count INFO issues
nbirillo Jun 16, 2021
a94e833
Fix flake8 tests
nbirillo Jun 16, 2021
4b1483a
Small fix
nbirillo Jun 16, 2021
c036bc9
Delete pathlib from the whitelist
nbirillo Jun 16, 2021
edf684c
Merge branch 'fix-github-actions-main' into fix-github-actions
nbirillo Jun 16, 2021
bd60513
Try to add env variable
nbirillo Jun 16, 2021
d7c6561
Print env
nbirillo Jun 16, 2021
e2a29fb
Try to add specific version
nbirillo Jun 16, 2021
87e4218
Try to fix
nbirillo Jun 16, 2021
888b4f1
Try to use a const value
nbirillo Jun 16, 2021
ef9556d
Try to fix
nbirillo Jun 16, 2021
093fdf7
Try to use eval
nbirillo Jun 16, 2021
bf3b576
Try to fix
nbirillo Jun 16, 2021
6b691be
Try to read version from Version.md
nbirillo Jun 16, 2021
fb4f474
Try to fix
nbirillo Jun 16, 2021
7593373
Try to fix
nbirillo Jun 16, 2021
ebdaad6
Try to fix
nbirillo Jun 16, 2021
39eca46
Try to use docker 1.2.0 version
nbirillo Jun 16, 2021
ea63e20
Try to use 1.2.0 version directly
nbirillo Jun 16, 2021
8386a03
Fix flake8 config
nbirillo Jun 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,26 @@ jobs:

build:
runs-on: ubuntu-latest
container: nastyabirillo/hyperstyle

# Consistent with Version.md
container: nastyabirillo/hyperstyle:1.2.0

steps:

- name: Checkout
uses: actions/checkout@v1

# Note: The original Dockerfile for this action contains the following commands to install numpy and pandas.
# We exclude them from production to compress the docker image

# RUN apk add --no-cache python3-dev libstdc++ && \
# apk add --no-cache g++ && \
# ln -s /usr/include/locale.h /usr/include/xlocale.h && \
# pip3 install numpy && \
# pip3 install pandas

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=.git,__pycache__,docs/source/conf.py,old,build,dist,venv,test/resources,.eggs,review.egg-info,.pytest_cache,node_modules
# TODO: change max-complexity into 10 after refactoring
flake8 . --count --max-complexity=11 --max-line-length=120 --max-doc-length=120 --ignore=R504,A003,E800,E402,W503,WPS,H601 --statistics --exclude=.git,__pycache__,docs/source/conf.py,old,build,dist,venv,test/resources,.eggs,review.egg-info,.pytest_cache,node_modules

- name: Set up Eslint
run: |
npm install eslint --save-dev
./node_modules/.bin/eslint --init

- name: Test with pytest
run: |
pytest
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This Dockerfile is used only for production

FROM python:3.8.2-alpine3.11

RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \
Expand All @@ -8,9 +10,12 @@ RUN npm i -g eslint@7.5.0
RUN java -version
RUN ls /usr/lib/jvm

## Other dependencies
# Other dependencies
RUN apk add bash

# Set up Eslint
RUN npm install eslint --save-dev && ./node_modules/.bin/eslint --init

# Upgrade pip
RUN python3.8 -m pip install --upgrade pip

Expand All @@ -33,4 +38,4 @@ RUN pip3 install --no-cache-dir ./review
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"

CMD ["/bin/bash"]
CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ __Note__: If you have `ModuleNotFoundError` while you try to run tests, please c
__Note__: We use [eslint](https://eslint.org/) and [open-jdk 11](https://openjdk.java.net/projects/jdk/11/)
in the tests. Please, set up the environment before running the tests.
You can see en example of the environment configuration in
the [build.yml](./.github/workflows/build.yml) file.
the [Dockerfile](./docker/dev/Dockerfile) file.

Use `pytest` from the root directory to run __ALL__ tests.

37 changes: 37 additions & 0 deletions docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM python:3.8.2-alpine3.11

RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \
&& apk add --update nodejs npm

RUN npm i -g eslint@7.5.0

RUN java -version
RUN ls /usr/lib/jvm

# Install numpy and pandas for tests
RUN apk add --no-cache python3-dev libstdc++ && \
apk add --no-cache g++ && \
ln -s /usr/include/locale.h /usr/include/xlocale.h && \
pip3 install numpy && \
pip3 install pandas

# Other dependencies
RUN apk add bash

# Dependencies and package installation
WORKDIR /

COPY requirements-test.txt review/requirements-test.txt
RUN pip3 install --no-cache-dir -r review/requirements-test.txt

COPY requirements.txt review/requirements.txt
RUN pip3 install --no-cache-dir -r review/requirements.txt

COPY . review
RUN pip3 install --no-cache-dir ./review

# Container's enviroment variables
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"

CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ radon==4.5.0
# extra libraries and frameworks
django==3.2
requests==2.25.1
argparse==1.4.0
argparse==1.4.0
6 changes: 1 addition & 5 deletions src/python/review/inspectors/flake8/issue_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
'C818': IssueType.CODE_STYLE,
'C819': IssueType.CODE_STYLE,

# flake8-spellcheck
'SC100': IssueType.INFO,
'SC200': IssueType.INFO,

# WPS: Naming
'WPS117': IssueType.CODE_STYLE, # Forbid naming variables self, cls, or mcs.
'WPS125': IssueType.ERROR_PRONE, # Forbid variable or module names which shadow builtin names.
Expand Down Expand Up @@ -111,7 +107,7 @@

'F': IssueType.BEST_PRACTICES, # standard flake8
'C': IssueType.BEST_PRACTICES, # flake8-comprehensions
'SC': IssueType.BEST_PRACTICES, # flake8-spellcheck
'SC': IssueType.INFO, # flake8-spellcheck

'WPS1': IssueType.CODE_STYLE, # WPS type: Naming
'WPS2': IssueType.COMPLEXITY, # WPS type: Complexity
Expand Down
4 changes: 3 additions & 1 deletion src/python/review/reviewers/perform_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from src.python.review.application_config import ApplicationConfig
from src.python.review.common.language import Language
from src.python.review.inspectors.issue import IssueType
from src.python.review.reviewers.common import perform_language_review
from src.python.review.reviewers.python import perform_python_review
from src.python.review.reviewers.review_result import ReviewResult
Expand Down Expand Up @@ -66,7 +67,8 @@ def perform_and_print_review(path: Path,
else:
print_review_result_as_text(review_result, path)

return len(review_result.all_issues)
# Don't count INFO issues too
return len(list(filter(lambda issue: issue.type != IssueType.INFO, review_result.all_issues)))


def perform_review(path: Path, config: ApplicationConfig) -> ReviewResult:
Expand Down