From 30afec9161cce0de6bc8ff4e34fc4af783fcd225 Mon Sep 17 00:00:00 2001 From: George Schneeloch Date: Tue, 26 Jan 2021 15:35:40 -0500 Subject: [PATCH] Add selenium to github actions (#4730) * Add selenium to github actions * Try a docker approach * Remove Travis env vars * Fix obscure dockerfile error by eliminating two COPY in a row https://github.com/moby/moby/issues/37965#issuecomment-426853382 * WIP * Add trailing slash * Use .env.example * docker-compose.travis.yml was deleted * Copy .env file * Add a bug just to make sure it fails the test * Success, remove the bug --- .github/workflows/ci.yml | 16 ++++++++++++++++ Dockerfile | 3 +-- scripts/test/run_selenium_tests_travis.sh | 2 +- travis/Dockerfile-travis-watch | 6 +----- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2032ae1846..13b8a8be38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,3 +153,19 @@ jobs: with: file: coverage/lcov.info fail_ci_if_error: true + + selenium-tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Selenium + run: | + cp .env.example .env + docker build -t micromasters_watch -f ./Dockerfile-node . + docker build -t travis-watch -f ./travis/Dockerfile-travis-watch . + docker run --name travis-watch-container --env-file .env -e NODE_ENV=production -t travis-watch ./webpack_if_prod.sh + docker cp travis-watch-container:/src/webpack-stats.json . + docker cp travis-watch-container:/src/static/bundles ./static/bundles + ./scripts/test/run_selenium_tests_travis.sh diff --git a/Dockerfile b/Dockerfile index 2f06ac5bcf..fa14b475cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,8 +20,7 @@ RUN adduser --disabled-password --gecos "" mitodl RUN mkdir /var/media && chown -R mitodl:mitodl /var/media # Install project packages -COPY requirements.txt /tmp/requirements.txt -COPY test_requirements.txt /tmp/test_requirements.txt +COPY *requirements.txt /tmp/ RUN pip install -r requirements.txt -r test_requirements.txt # Add project diff --git a/scripts/test/run_selenium_tests_travis.sh b/scripts/test/run_selenium_tests_travis.sh index 4067aa0f2e..4bb44206ab 100755 --- a/scripts/test/run_selenium_tests_travis.sh +++ b/scripts/test/run_selenium_tests_travis.sh @@ -8,5 +8,5 @@ then echo "webpack-stats.json must exist before running the selenium tests. Run webpack to create it." exit 1 fi -docker-compose -f docker-compose.yml -f docker-compose.travis.yml -f docker-compose.selenium.yml run \ +docker-compose -f docker-compose.yml -f docker-compose.selenium.yml run \ selenium py.test ./selenium_tests diff --git a/travis/Dockerfile-travis-watch b/travis/Dockerfile-travis-watch index 418ab9467c..1bf4bed842 100644 --- a/travis/Dockerfile-travis-watch +++ b/travis/Dockerfile-travis-watch @@ -2,11 +2,7 @@ FROM micromasters_watch WORKDIR /src -COPY package.json /src - -COPY yarn.lock /src - -ADD ./webpack_if_prod.sh /src +COPY ./webpack_if_prod.sh yarn.lock package.json /src/ USER root