From 57521c3708298de45b4dfc27bcbf645db37d84ff Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 26 Mar 2022 14:45:19 +0100 Subject: [PATCH 1/6] CI - remove gitlab config --- .gitlab-ci.yml | 100 ------------------------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 884434da..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,100 +0,0 @@ -image: python:3.9 - -variables: - POSTGRES_DB: fittrackee_test - POSTGRES_USER: fittrackee - POSTGRES_PASSWORD: fittrackee - POSTGRES_HOST: postgres - APP_SETTINGS: fittrackee.config.TestingConfig - DATABASE_TEST_URL: postgresql://fittrackee:fittrackee@postgres:5432/fittrackee_test - EMAIL_URL: smtp://none:none@0.0.0.0:1025 - FLASK_APP: fittrackee/__main__.py - SENDER_EMAIL: fittrackee@example.com - -services: - - name: postgres:latest - alias: postgres - -stages: - - lint - - tests - - selenium - -.python: - stage: tests - before_script: - - pip install --quiet poetry - - poetry config virtualenvs.create false - - poetry install --no-interaction --quiet - script: - - pytest fittrackee -p no:warnings --cov fittrackee --cov-report term-missing - - -.javascript: - stage: tests - before_script: - - apt-get update && apt-get install -y nodejs npm - - npm install --global yarn - - cd fittrackee_client - - yarn install - -python-lint: - stage: lint - extends: .python - script: - - pytest --flake8 --isort --black -m "flake8 or isort or black" fittrackee e2e --ignore=fittrackee/migrations - -python-type-check: - stage: lint - extends: .python - script: - - mypy fittrackee - -eslint: - stage: lint - extends: .javascript - script: - - yarn lint - -python-3.7: - extends: .python - image: python:3.7 - -python-3.8: - extends: .python - image: python:3.8 - -python-3.9: - extends: .python - -python-3.10: - extends: .python - image: python:3.10 - -typescript: - stage: tests - before_script: - - apt-get update && apt-get install -y nodejs npm - - npm install --global yarn - - cd fittrackee_client - - yarn install - script: - - yarn test:unit - -firefox: - stage: selenium - services: - - name: postgres:latest - alias: postgres - - name: selenium/standalone-firefox - alias: selenium - before_script: - - pip install --quiet poetry - - poetry config virtualenvs.create false - - poetry install --no-interaction --quiet - - flask db upgrade --directory fittrackee/migrations - - setsid nohup flask run --with-threads -h 0.0.0.0 -p 5000 >> nohup.out 2>&1 & - - export TEST_APP_URL=http://$(hostname --ip-address):5000 - - sleep 5 - script: - - pytest e2e --driver Remote --capability browserName firefox --host selenium --port 4444 \ No newline at end of file From 64cc5689585e30133eaf03e9d64fd863c271a111 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 26 Mar 2022 14:45:36 +0100 Subject: [PATCH 2/6] CI - init tests workflow w/ github actions --- .github/workflows/.tests.yml | 69 ++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/.tests.yml diff --git a/.github/workflows/.tests.yml b/.github/workflows/.tests.yml new file mode 100644 index 00000000..71ff4d65 --- /dev/null +++ b/.github/workflows/.tests.yml @@ -0,0 +1,69 @@ +name: FitTrackee tests + +on: [push, pull_request] + +env: + APP_SETTINGS: fittrackee.config.TestingConfig + DATABASE_TEST_URL: "postgresql://fittrackee:fittrackee@postgres:5432/fittrackee_test" + EMAIL_URL: "smtp://none:none@0.0.0.0:1025" + FLASK_APP: fittrackee/__main__.py + SENDER_EMAIL: fittrackee@example.com + +jobs: + python: + name: python ${{ matrix.python-version }} + runs-on: ubuntu-latest + container: python:${{ matrix.python-version }} + services: + postgres: + image: postgres:latest + env: + POSTGRES_DB: fittrackee_test + POSTGRES_USER: fittrackee + POSTGRES_PASSWORD: fittrackee + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + strategy: + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10" ] + steps: + - uses: actions/checkout@v2 + - name: Install Poetry and Dependencies + run: | + python -m pip install --upgrade pip + pip install --quiet poetry + poetry config virtualenvs.create false + poetry install --no-interaction --quiet + - name: Lint + if: matrix.python-version == '3.10' + run: pytest --flake8 --isort --black -m "flake8 or isort or black" fittrackee e2e --ignore=fittrackee/migrations -p no:warnings + - name: Mypy + if: matrix.python-version == '3.10' + run: mypy fittrackee + - name: Pytest + run: pytest fittrackee -p no:warnings --cov fittrackee --cov-report term-missing + + javascript: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 17.x + uses: actions/setup-node@v2 + with: + node-version: "17.x" + - name: Install yarn and dependencies + run: | + npm install --global yarn + cd fittrackee_client + yarn install + - name: Lint + run: | + cd fittrackee_client + yarn lint + - name: Tests + run: | + cd fittrackee_client + yarn test:unit From 600c5ab8c6a9b1ffad5c2de66419f63b31386fdc Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 26 Mar 2022 14:57:31 +0100 Subject: [PATCH 3/6] CI - add end-2-end tests job --- .github/workflows/.tests.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/.tests.yml b/.github/workflows/.tests.yml index 71ff4d65..587f3a68 100644 --- a/.github/workflows/.tests.yml +++ b/.github/workflows/.tests.yml @@ -67,3 +67,38 @@ jobs: run: | cd fittrackee_client yarn test:unit + + end2end: + runs-on: ubuntu-latest + needs: ["python", "javascript"] + container: python:3.10 + services: + postgres: + image: postgres:latest + env: + POSTGRES_DB: fittrackee_test + POSTGRES_USER: fittrackee + POSTGRES_PASSWORD: fittrackee + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + selenium: + image: selenium/standalone-firefox + steps: + - uses: actions/checkout@v2 + - name: Install Poetry and Dependencies + run: | + python -m pip install --upgrade pip + pip install --quiet poetry + poetry config virtualenvs.create false + poetry install --no-interaction --quiet + - name: Run migrations + run: flask db upgrade --directory fittrackee/migrations + - name: Start application and run tests with Selenium + run: | + setsid nohup flask run --with-threads -h 0.0.0.0 -p 5000 >> nohup.out 2>&1 & + export TEST_APP_URL=http://$(hostname --ip-address):5000 + sleep 5 + pytest e2e --driver Remote --capability browserName firefox --host selenium --port 4444 From 1074272ac0dc2ce09b894f193e92eff7c29c5ea9 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 26 Mar 2022 15:48:34 +0100 Subject: [PATCH 4/6] CI - split jobs into 2 workflows --- .github/workflows/.tests-javascript.yml | 34 +++++++++++++++++++ .../{.tests.yml => .tests-python.yml} | 32 ++++------------- 2 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/.tests-javascript.yml rename .github/workflows/{.tests.yml => .tests-python.yml} (81%) diff --git a/.github/workflows/.tests-javascript.yml b/.github/workflows/.tests-javascript.yml new file mode 100644 index 00000000..1ad23aa4 --- /dev/null +++ b/.github/workflows/.tests-javascript.yml @@ -0,0 +1,34 @@ +name: Javascript CI + +on: + push: + paths: ['fittrackee_client'] + pull_request: + paths: ['fittrackee_client'] + +env: + working-directory: fittrackee_client + +jobs: + javascript: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 17.x + uses: actions/setup-node@v2 + with: + node-version: "17.x" + - name: Install yarn and dependencies + working-directory: ${{env.working-directory}} + run: | + npm install --global yarn + yarn install + - name: Lint + working-directory: ${{env.working-directory}} + run: yarn lint + - name: Tests + working-directory: ${{env.working-directory}} + run: yarn test:unit + - name: Build + working-directory: ${{env.working-directory}} + run: yarn build diff --git a/.github/workflows/.tests.yml b/.github/workflows/.tests-python.yml similarity index 81% rename from .github/workflows/.tests.yml rename to .github/workflows/.tests-python.yml index 587f3a68..4990fb53 100644 --- a/.github/workflows/.tests.yml +++ b/.github/workflows/.tests-python.yml @@ -1,6 +1,10 @@ -name: FitTrackee tests +name: Python CI -on: [push, pull_request] +on: + push: + paths-ignore: ['docs/**', 'docsrc/**', 'fittrackee_client', '*.md'] + pull_request: + paths-ignore: ['docs/**', 'docsrc/**', 'fittrackee_client', '*.md'] env: APP_SETTINGS: fittrackee.config.TestingConfig @@ -46,31 +50,9 @@ jobs: - name: Pytest run: pytest fittrackee -p no:warnings --cov fittrackee --cov-report term-missing - javascript: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Use Node.js 17.x - uses: actions/setup-node@v2 - with: - node-version: "17.x" - - name: Install yarn and dependencies - run: | - npm install --global yarn - cd fittrackee_client - yarn install - - name: Lint - run: | - cd fittrackee_client - yarn lint - - name: Tests - run: | - cd fittrackee_client - yarn test:unit - end2end: runs-on: ubuntu-latest - needs: ["python", "javascript"] + needs: ["python"] container: python:3.10 services: postgres: From 8e8c25bce99f8736d5fed1cb0298401081a2aeb1 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 26 Mar 2022 16:06:46 +0100 Subject: [PATCH 5/6] update documentation --- CONTRIBUTING.md | 8 +++----- README.md | 11 +++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cede5bc7..c9a8529c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,8 +20,6 @@ The **GitHub** repository contains: - tests, - documentation (source and build). -Continuous integration pipeline runs on **Gitlab CI**. - ### How to install FitTrackee see [Installations instructions](https://samr1.github.io/FitTrackee/installation.html) @@ -54,12 +52,10 @@ Please make your changes from the development branch (`dev`). ```shell $ make check-all ``` - There are some end-to-end tests, to run them: + There are some end-to-end tests, to run them (needs a running application): ```shell $ make test-e2e ``` - Note: For now, pull requests from forks don't trigger pipelines on GitLab CI (see [current issue](https://gitlab.com/gitlab-org/gitlab/-/issues/5667)). - So make sure that checks don't return errors locally. * If needed, add or update tests. @@ -74,5 +70,7 @@ Please make your changes from the development branch (`dev`). * Ensure the pull requests description clearly describes the problem and solution. Include the relevant issue number if applicable. +* If needed, [update your branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/keeping-your-pull-request-in-sync-with-the-base-branch). + Thanks. \ No newline at end of file diff --git a/README.md b/README.md index 73411cf6..3606757b 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ [![Vue Version](https://img.shields.io/badge/vue-3.2-brightgreen.svg)](https://v3.vuejs.org/) [![Typescript Version](https://img.shields.io/npm/types/typescript)](https://www.typescriptlang.org/) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/290a285f22e94132904dc13b4dd19d1d)](https://www.codacy.com/app/SamR1/FitTrackee) -[![pipeline status](https://gitlab.com/SamR1/FitTrackee/badges/master/pipeline.svg)](https://gitlab.com/SamR1/FitTrackee/-/commits/master) -[![coverage report](https://gitlab.com/SamR1/FitTrackee/badges/master/coverage.svg)](https://gitlab.com/SamR1/FitTrackee/-/commits/master) 1 +![pipeline status](https://github.com/SamR1/FitTrackee/actions/workflows/.tests-python.yml/badge.svg?branch=master) +![pipeline status](https://github.com/SamR1/FitTrackee/actions/workflows/.tests-javascript.yml/badge.svg?branch=master) + --- @@ -30,8 +30,3 @@ It is also possible to add a workout without a gpx file. (see [issues](https://github.com/SamR1/FitTrackee/issues) and [documentation](https://samr1.github.io/FitTrackee) for more information) ![FitTrackee Dashboard Screenshot](https://samr1.github.io/FitTrackee/_images/fittrackee_screenshot-01.png) - ---- - -Notes: -_1. Test coverage: only for Python API_ From 7f467dbaf112947ad2288fd8649fe2c4316f8a00 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 26 Mar 2022 16:10:21 +0100 Subject: [PATCH 6/6] CI - fix paths --- .github/workflows/.tests-javascript.yml | 4 ++-- .github/workflows/.tests-python.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/.tests-javascript.yml b/.github/workflows/.tests-javascript.yml index 1ad23aa4..dc950024 100644 --- a/.github/workflows/.tests-javascript.yml +++ b/.github/workflows/.tests-javascript.yml @@ -2,9 +2,9 @@ name: Javascript CI on: push: - paths: ['fittrackee_client'] + paths: ['fittrackee_client/**'] pull_request: - paths: ['fittrackee_client'] + paths: ['fittrackee_client/**'] env: working-directory: fittrackee_client diff --git a/.github/workflows/.tests-python.yml b/.github/workflows/.tests-python.yml index 4990fb53..e019e23a 100644 --- a/.github/workflows/.tests-python.yml +++ b/.github/workflows/.tests-python.yml @@ -2,9 +2,9 @@ name: Python CI on: push: - paths-ignore: ['docs/**', 'docsrc/**', 'fittrackee_client', '*.md'] + paths-ignore: ['docs/**', 'docsrc/**', 'fittrackee_client/**', '*.md'] pull_request: - paths-ignore: ['docs/**', 'docsrc/**', 'fittrackee_client', '*.md'] + paths-ignore: ['docs/**', 'docsrc/**', 'fittrackee_client/**', '*.md'] env: APP_SETTINGS: fittrackee.config.TestingConfig