From 9fd00db1fd6b7ee11d43d0731178023593268113 Mon Sep 17 00:00:00 2001 From: "Anastasiia.Birillo" Date: Tue, 6 Jul 2021 12:21:47 +0300 Subject: [PATCH 1/4] Update dev dockerfile --- docker/dev/Dockerfile | 22 ++++++++-------------- requirements-test.txt | 3 ++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 0b51d5c7..3f1d9c96 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -1,23 +1,14 @@ -FROM python:3.8.2-alpine3.11 +FROM python:3.8-buster -RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \ - && apk add --update nodejs npm +RUN apt-get update && \ + apt-get install -y openjdk-11-jdk && \ + apt-get install -y nodejs npm -RUN npm i -g eslint@7.5.0 +RUN npm i npm@latest -g 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 / @@ -30,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/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 From 2f6a25921f1f4e17d8f7ea3979557b8ac7af4bcd Mon Sep 17 00:00:00 2001 From: Nastya Birillo Date: Tue, 6 Jul 2021 12:22:43 +0300 Subject: [PATCH 2/4] Update docker image version --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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: From 371bfacb011a81b16b6b69dfd2939e2f2ff314e1 Mon Sep 17 00:00:00 2001 From: "Anastasiia.Birillo" Date: Tue, 6 Jul 2021 12:29:25 +0300 Subject: [PATCH 3/4] Use one Dockerfile for prod and dev --- Dockerfile | 20 ++++++++------------ README.md | 2 +- docker/dev/Dockerfile | 31 ------------------------------- 3 files changed, 9 insertions(+), 44 deletions(-) delete mode 100644 docker/dev/Dockerfile 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 3f1d9c96..00000000 --- a/docker/dev/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM python:3.8-buster - -RUN apt-get update && \ - apt-get install -y openjdk-11-jdk && \ - apt-get install -y nodejs npm - -RUN npm i npm@latest -g - -RUN java -version -RUN ls /usr/lib/jvm - -# 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 - -# 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}" - -CMD ["/bin/bash"] \ No newline at end of file From a7d130e0c759bc7a4b168e0f7b1422c0dc5050bb Mon Sep 17 00:00:00 2001 From: "Anastasiia.Birillo" Date: Tue, 6 Jul 2021 12:50:33 +0300 Subject: [PATCH 4/4] Fix eslint sources path --- src/python/review/inspectors/eslint/eslint.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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,