diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc87d98f..1c58dc7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,8 @@ jobs: build: runs-on: ubuntu-latest - container: nastyabirillo/hyperstyle + # Consistent with Version.md + container: nastyabirillo/hyperstyle:1.1.0 steps: diff --git a/Dockerfile b/Dockerfile index 41f14cdb..3f1d9c96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,14 @@ -# This Dockerfile is used only for production +FROM python:3.8-buster -FROM python:3.8.2-alpine3.11 +RUN apt-get update && \ + apt-get install -y openjdk-11-jdk && \ + apt-get install -y nodejs npm -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 npm i npm@latest -g RUN java -version RUN ls /usr/lib/jvm -# Other dependencies -RUN apk add bash - -# Set up Eslint -RUN npm install eslint --save-dev && ./node_modules/.bin/eslint --init - # Dependencies and package installation WORKDIR / @@ -28,6 +21,9 @@ RUN pip3 install --no-cache-dir -r review/requirements.txt COPY . review RUN pip3 install --no-cache-dir ./review +# Set up Eslint +RUN npm install --prefix ./review eslint@7.5.0 --save-dev && ./review/node_modules/.bin/eslint --init + # Container's enviroment variables ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk ENV PATH="$JAVA_HOME/bin:${PATH}" diff --git a/README.md b/README.md index 42c05b5c..4f9856dc 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,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 [Dockerfile](./docker/dev/Dockerfile) file. +the [Dockerfile](Dockerfile) file. Use `pytest` from the root directory to run __ALL__ tests. diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile deleted file mode 100644 index 0b51d5c7..00000000 --- a/docker/dev/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -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"] \ No newline at end of file diff --git a/requirements-test.txt b/requirements-test.txt index a9b0bfb6..6614bff4 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -5,4 +5,5 @@ jsonschema~=3.2.0 django~=3.2 pylint~=2.7.4 requests~=2.25.1 -setuptools~=56.0.0 \ No newline at end of file +setuptools~=56.0.0 +pandas \ No newline at end of file diff --git a/src/python/review/inspectors/eslint/eslint.py b/src/python/review/inspectors/eslint/eslint.py index ff9f9a67..486286ec 100644 --- a/src/python/review/inspectors/eslint/eslint.py +++ b/src/python/review/inspectors/eslint/eslint.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from typing import List @@ -20,9 +21,20 @@ class ESLintInspector(BaseInspector): r'complexity of (\d+)' } + @classmethod + def _get_eslint_local_path(cls) -> str: + common_path = 'node_modules/.bin/eslint' + standard_path = f'./{common_path}' + prod_path = f'./review/{common_path}' + if os.path.exists(standard_path): + return standard_path + elif os.path.exists(prod_path): + return prod_path + raise FileNotFoundError('Eslint was not configured!') + @classmethod def _create_command(cls, path: Path, output_path: Path, is_local: bool = False) -> List[str]: - eslint_command = 'eslint' if not is_local else './node_modules/.bin/eslint' + eslint_command = 'eslint' if not is_local else cls._get_eslint_local_path() return [ eslint_command, '-c', PATH_ESLINT_CONFIG,