From f359aa6cfafcacab057a7446e2b6c2202e185ab8 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Mon, 11 Jul 2022 13:40:30 +0200 Subject: [PATCH 1/3] Run Selenium as an independent workflow --- .github/workflows/flask.yml | 15 ------- .github/workflows/selenium.yml | 78 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/selenium.yml diff --git a/.github/workflows/flask.yml b/.github/workflows/flask.yml index ec42536f..16086b5b 100644 --- a/.github/workflows/flask.yml +++ b/.github/workflows/flask.yml @@ -49,10 +49,6 @@ jobs: python -m pip install --upgrade pip pip install flake8 pytest coverage pip install -r requirements.txt - pip install -e . - mkdir bin - wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz - tar xf geckodriver-v0.30.0-linux64.tar.gz -C bin/ - name: Prepare database env: @@ -66,17 +62,6 @@ jobs: psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION citext SCHEMA public;" psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pg_trgm SCHEMA public;" - - name: Selenium tests - env: - SECRET_KEY: 'f00046306835001b55c230092e3a7990485beda0bc3bf732088d1ba1b5b74110e22e3f9ec3a24890272554b37d4' - DB_DATABASE: dh_test - FLASK_APP: examples/app.py - dhi: dbtest - run: | - alembic -x inventory=dbtest upgrade head - dh dummy --yes - flask run & pytest tests/test_selenium.py - - name: Lint with flake8 run: | # stop the build if: diff --git a/.github/workflows/selenium.yml b/.github/workflows/selenium.yml new file mode 100644 index 00000000..4e1e987a --- /dev/null +++ b/.github/workflows/selenium.yml @@ -0,0 +1,78 @@ +name: Selenium + +on: + push: + branches: [master, testing] + pull_request: + branches: [master, testing] + +jobs: + build: + runs-on: ubuntu-latest + + # Service containers to run with `container-job` + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres:11 + ports: + - 5432:5432 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: dh_test + POSTGRES_USER: dhub + POSTGRES_PASSWORD: ereuse + + strategy: + max-parallel: 4 + matrix: + python-version: [3.7] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + sudo apt-get update -qy + sudo apt-get -y install postgresql-client --no-install-recommends + python -m pip install --upgrade pip + pip install flake8 pytest coverage + pip install -r requirements.txt + pip install -e . + mkdir bin + wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz + tar xf geckodriver-v0.30.0-linux64.tar.gz -C bin/ + + - name: Prepare database + env: + POSTGRES_DB: dh_test + POSTGRES_USER: dhub + POSTGRES_PASSWORD: ereuse + run: | + export PGPASSWORD=$POSTGRES_PASSWORD + psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pgcrypto SCHEMA public;" + psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION ltree SCHEMA public;" + psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION citext SCHEMA public;" + psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pg_trgm SCHEMA public;" + + - name: Selenium tests + env: + SECRET_KEY: 'f00046306835001b55c230092e3a7990485beda0bc3bf732088d1ba1b5b74110e22e3f9ec3a24890272554b37d4' + DB_DATABASE: dh_test + FLASK_APP: examples/app.py + dhi: dbtest + run: | + alembic -x inventory=dbtest upgrade head + dh dummy --yes + flask run & pytest tests/test_selenium.py From d6a2dc0a141f19b25bb4ff0972e3a3bf7f20c955 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Mon, 11 Jul 2022 13:46:52 +0200 Subject: [PATCH 2/3] Bump actions versions --- .github/workflows/eslint.yml | 4 ++-- .github/workflows/flask.yml | 4 ++-- .github/workflows/selenium.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 7e42feaf..b82a0f32 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -16,10 +16,10 @@ on: branches: [master, testing] jobs: - build: + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v1 with: node-version: '16' diff --git a/.github/workflows/flask.yml b/.github/workflows/flask.yml index 16086b5b..787e7479 100644 --- a/.github/workflows/flask.yml +++ b/.github/workflows/flask.yml @@ -35,9 +35,9 @@ jobs: python-version: [3.7] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: 'pip' diff --git a/.github/workflows/selenium.yml b/.github/workflows/selenium.yml index 4e1e987a..ff7fc73f 100644 --- a/.github/workflows/selenium.yml +++ b/.github/workflows/selenium.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: 'pip' From 214fbb6e373d393d04d5c11ae0aca81d3cfff96a Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Mon, 11 Jul 2022 13:53:27 +0200 Subject: [PATCH 3/3] Bump to Python 3.9 on actions It's the version used on testing & production servers --- .github/workflows/flask.yml | 2 +- .github/workflows/selenium.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flask.yml b/.github/workflows/flask.yml index 787e7479..43fbe8e7 100644 --- a/.github/workflows/flask.yml +++ b/.github/workflows/flask.yml @@ -32,7 +32,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.7] + python-version: [3.9] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/selenium.yml b/.github/workflows/selenium.yml index ff7fc73f..f9209484 100644 --- a/.github/workflows/selenium.yml +++ b/.github/workflows/selenium.yml @@ -32,7 +32,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.7] + python-version: [3.9] steps: - uses: actions/checkout@v3