From d22bf1bc773dddcc35878987b036ac849537ae9f Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 6 Aug 2023 20:33:17 +0200 Subject: [PATCH] CI - replace Gitlab CI w/ GitHub Actions --- .github/workflows/.tests-javascript.yml | 27 +++++++++ .github/workflows/.tests-python.yml | 74 +++++++++++++++++++++++++ .gitlab-ci.yml | 65 ---------------------- 3 files changed, 101 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/.tests-javascript.yml create mode 100644 .github/workflows/.tests-python.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/.tests-javascript.yml b/.github/workflows/.tests-javascript.yml new file mode 100644 index 0000000..4f508a5 --- /dev/null +++ b/.github/workflows/.tests-javascript.yml @@ -0,0 +1,27 @@ +name: Javascript CI + +on: + push: + paths: ['rdltr_front/**'] + pull_request: + paths: ['rdltr_front/**'] + +env: + working-directory: rdltr_front + +jobs: + javascript: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install yarn and dependencies + working-directory: ${{env.working-directory}} + run: | + npm install --global yarn + yarn install --ignore-engines + - name: Lint + working-directory: ${{env.working-directory}} + run: yarn lint + - name: Build + working-directory: ${{env.working-directory}} + run: yarn build diff --git a/.github/workflows/.tests-python.yml b/.github/workflows/.tests-python.yml new file mode 100644 index 0000000..acaf64b --- /dev/null +++ b/.github/workflows/.tests-python.yml @@ -0,0 +1,74 @@ +name: Python CI + +on: + push: + paths-ignore: ['docs/**', 'docsrc/**', 'rdltr_front/**', '*.md'] + pull_request: + paths-ignore: ['docs/**', 'docsrc/**', 'rdltr_front/**', '*.md'] + +jobs: + python: + name: python ${{ matrix.python-version }} + runs-on: ubuntu-latest + container: python:${{ matrix.python-version }} + strategy: + matrix: + python-version: [ "3.8", "3.9", "3.10", "3.11" ] + env: + RDLTR_SETTINGS: 'rdltr.config.TestingConfig' + steps: + - uses: actions/checkout@v3 + - name: Create and source virtual environment + run: | + python3 -m venv .venv + . .venv/bin/activate + - name: Install dependencies + run: python3 -m pip install -e .[test] + - name: Bandit + if: matrix.python-version == '3.11' + run: bandit -r rdltr -c pyproject.toml + - name: Lint (flake8, isort & black) + if: matrix.python-version == '3.11' + run: | + pytest --isort --black -m "isort or black" rdltr + flake8 rdltr + - name: Mypy + if: matrix.python-version == '3.11' + run: mypy rdltr + - name: Pytest + run: pytest rdltr/tests/tests --cov rdltr --cov-report term-missing + + end2end: + name: e2e tests + runs-on: ubuntu-latest + needs: ["python"] + container: python:3.11 + services: + selenium: + image: selenium/standalone-firefox + env: + RDLTR_HOST: '0.0.0.0' + RDLTR_SETTINGS: 'rdltr.config.TestingConfig' + RDLTR_DB_TEST_URL: 'sqlite:////tmp/rdltr_test.db' + steps: + - uses: actions/checkout@v3 + - name: Update pip and install build + run: python3 -m pip install --upgrade pip build + - name: Create and source virtual environment + run: | + python3 -m venv .venv + . .venv/bin/activate + - name: Build rdltr package + run: python3 -m build + - name: Install rdltr package + run: python3 -m pip install dist/rdltr-$(cat VERSION).tar.gz + - name: Run migrations + run: rdltr_db + - name: Install pytest and selenium + run: python3 -m pip install pytest==7.4.0 pytest-selenium==4.0.1 selenium==4.9.0 + - name: Start application and run tests with Selenium + run: | + setsid nohup rdltr >> nohup.out 2>&1 & + export RDLTR_HOST=$(hostname --ip-address) + sleep 5 + pytest rdltr/tests/ui_tests --driver Remote --capability browserName firefox --selenium-host selenium --selenium-port 4444 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 13a8986..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,65 +0,0 @@ -image: python:3.11 - -stages: - - tests - - selenium - -.python: - stage: tests - before_script: - - pip install -e .[test] - script: - - pytest rdltr/tests/tests --cov rdltr --cov-report term-missing - -lint: - extends: .python - script: - - pytest --isort --black -m "isort or black" rdltr - - flake8 rdltr - -type-check: - extends: .python - script: - - mypy rdltr - -python-3.8: - extends: .python - image: python:3.8 - -python-3.9: - extends: .python - image: python:3.9 - -python-3.10: - extends: .python - image: python:3.10 - -python-3.11: - stage: tests - before_script: - - pip install -e .[test] - - pip install coveralls - - echo "FAILED" > .job_status - script: - - pytest rdltr/tests/tests --cov rdltr --cov-report term-missing - - echo "SUCCESS" > .job_status - after_script: - - if [ "$(cat .job_status)" == "SUCCESS" ]; then GIT_BRANCH="${CI_COMMIT_REF_NAME}" coveralls; fi - -firefox: - stage: selenium - services: - - name: selenium/standalone-firefox - alias: selenium - variables: - RDLTR_HOST: '0.0.0.0' - RDLTR_SETTINGS: 'rdltr.config.TestingConfig' - RDLTR_DB_TEST_URL: 'sqlite:////tmp/rdltr_test.db' - before_script: - - pip install -e .[test] - script: - - rdltr_db - - setsid nohup rdltr > nohup.out & - - export RDLTR_HOST=$(hostname --ip-address) - - sleep 5 - - pytest rdltr/tests/ui_tests --driver Remote --capability browserName firefox --selenium-host selenium --selenium-port 4444