diff --git a/.github/workflows/test_prs.yml b/.github/workflows/test_prs.yml index f38a7b0bd..0e063c240 100644 --- a/.github/workflows/test_prs.yml +++ b/.github/workflows/test_prs.yml @@ -1,20 +1,28 @@ name: CI +# Controls when the action will run. on: pull_request: branches: - develop - main + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build: + # The type of runner that the job will run on runs-on: ubuntu-20.04 env: FLASK_APP: OpenOversight.app strategy: matrix: python-version: ["3.11", "3.12"] + # Steps represent a sequence of tasks that will be executed as part of the job steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 - name: Run tests run: PYTHON_VERSION=${{ matrix.python-version }} make test_with_version diff --git a/Makefile b/Makefile index 34c0d9084..3acd46a48 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ build_with_version: create_empty_secret .PHONY: test_with_version test_with_version: build_with_version assets - docker-compose run --rm web-test pytest --cov=OpenOversight --cov-report xml:OpenOversight/tests/coverage.xml --doctest-modules -n 4 --dist=loadfile -v OpenOversight/tests/ + ENV=testing docker-compose run --rm web pytest --cov=OpenOversight --cov-report xml:OpenOversight/tests/coverage.xml --doctest-modules -n 4 --dist=loadfile -v OpenOversight/tests/ .PHONY: start start: build ## Run containers @@ -48,9 +48,9 @@ populate: create_db ## Build and run containers .PHONY: test test: start ## Run tests if [ -z "$(name)" ]; then \ - docker-compose run --rm web-test pytest --cov --doctest-modules -n auto --dist=loadfile -v OpenOversight/tests/; \ + ENV=testing docker-compose run --rm web-test pytest --cov --doctest-modules -n auto --dist=loadfile -v OpenOversight/tests/; \ else \ - docker-compose run --rm web-test pytest --cov --doctest-modules -v OpenOversight/tests/ -k $(name); \ + ENV=testing docker-compose run --rm web-test pytest --cov --doctest-modules -v OpenOversight/tests/ -k $(name); \ fi .PHONY: lint diff --git a/dockerfiles/web/Dockerfile b/dockerfiles/web/Dockerfile index ac6d01cc7..7bf74f804 100644 --- a/dockerfiles/web/Dockerfile +++ b/dockerfiles/web/Dockerfile @@ -10,7 +10,7 @@ ENV DEBIAN-FRONTEND noninteractive ENV DISPLAY=:1 # install apt dependencies -RUN apt-get update && apt-get install -y xvfb libpq-dev python3-dev \ +RUN apt-get update && apt-get install -y xvfb firefox-esr libpq-dev python3-dev \ && apt-get clean # install node @@ -21,6 +21,16 @@ RUN echo "${NODE_SETUP_SHA} setup_12.x" | sha256sum --check - RUN bash setup_12.x RUN apt-get install -y nodejs +# install geckodriver +ENV GECKODRIVER_VERSION="v0.26.0" +ENV GECKODRIVER_SHA=d59ca434d8e41ec1e30dd7707b0c95171dd6d16056fb6db9c978449ad8b93cc0 +ENV GECKODRIVER_BASE_URL="https://github.com/mozilla/geckodriver/releases/download" +RUN curl ${CURL_FLAGS} \ + ${GECKODRIVER_BASE_URL}/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz +RUN echo "${GECKODRIVER_SHA} geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz" | sha256sum --check - +RUN mkdir geckodriver +RUN tar -xzf geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -C geckodriver + # install yarn RUN npm install -g yarn RUN mkdir /var/www ./node_modules /.cache /.yarn /.mozilla @@ -29,14 +39,19 @@ COPY yarn.lock /usr/src/app/ RUN chmod -R 777 /usr/src/app/ /var/lib/xkb /.cache /.yarn /.mozilla -COPY requirements.txt /usr/src/app/ +COPY requirements.txt dev-requirements.txt /usr/src/app/ RUN pip3 install --no-cache-dir -r requirements.txt +RUN test "${DOCKER_BUILD_ENV}" = production || pip3 install --no-cache-dir -r dev-requirements.txt + COPY package.json /usr/src/app/ RUN yarn COPY test_data.py /usr/src/app/ +COPY mypy.ini /usr/src/app/ +EXPOSE 3000 +ENV PATH="/usr/src/app/geckodriver:${PATH}" ENV SECRET_KEY 4Q6ZaQQdiqtmvZaxP1If ENV SQLALCHEMY_DATABASE_URI postgresql://openoversight:terriblepassword@postgres/openoversight-dev