diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..40cdc058 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,60 @@ +image: python:3.8 + +variables: + POSTGRES_DB: fittrackee_test + POSTGRES_USER: fittrackee + POSTGRES_PASSWORD: fittrackee + POSTGRES_HOST: postgres + APP_SETTINGS: fittrackee_api.config.TestingConfig + DATABASE_TEST_URL: postgres://fittrackee:fittrackee@postgres:5432/fittrackee_test + EMAIL_URL: smtp://none:none@0.0.0.0:1025 + FLASK_APP: fittrackee_api/server.py + SENDER_EMAIL: fittrackee@example.com + +services: + - name: postgres:latest + alias: postgres + +stages: + - tests + - selenium + +.python: + stage: tests + before_script: + - pip install --quiet poetry + - poetry config virtualenvs.create false + - poetry install --no-interaction --quiet + script: + - pytest fittrackee_api -p no:warnings --cov fittrackee_api --cov-report term-missing + +lint: + extends: .python + script: + - pytest --flake8 --isort --black -m "flake8 or isort or black" fittrackee_api e2e --ignore=fittrackee_api/migrations + +python-3.7: + extends: .python + image: python:3.7 + +python-3.8: + extends: .python + +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_api/migrations + - flask initdata + - 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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c212738e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: node_js -node_js: '13' - -dist: trusty -sudo: required - -addons: - chrome: stable - apt: - update: true - packages: - - dpkg - - fluxbox - -services: - - docker - -env: - global: - - DOCKER_COMPOSE_VERSION=1.22.0 - -before_install: - - stty cols 80 - - sudo rm /usr/local/bin/docker-compose - - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - - chmod +x docker-compose - - sudo mv docker-compose /usr/local/bin - -before_script: - - export DATABASE_TEST_URL=postgres://postgres:@localhost:5432/fittrackee_test - - export APP_SETTINGS=fittrackee_api.config.TestingConfig - - export REACT_APP_API_URL=http://127.0.0.1 - - export NODE_ENV=development - - export TEST_URL=http://127.0.0.1 - - export UI_URL=http://127.0.0.1:3000 - - export EMAIL_URL=smtp://none:none@0.0.0.0:1025 - - export SENDER_EMAIL=fittrackee@example.com - - export DISPLAY=:99.0 - - export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi) - - sh -e /etc/init.d/xvfb start - - sleep 3 - - fluxbox >/dev/null 2>&1 & - - docker-compose -f docker-compose-ci.yml up --build -d - -script: - - sh test.sh - -after_script: - - docker-compose down diff --git a/Makefile b/Makefile index 3f9ea61d..bb138cd8 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ make-p: # Launch all P targets in parallel and exit as soon as one exits. set -m; (for p in $(P); do ($(MAKE) $$p || kill 0)& done; wait) -build-client: +build-client: lint-react $(NPM) build clean-install: diff --git a/docker-compose-ci.yml b/docker-compose-ci.yml deleted file mode 100644 index a93682e6..00000000 --- a/docker-compose-ci.yml +++ /dev/null @@ -1,59 +0,0 @@ -version: '3.3' - -services: - - fittrackee-db: - container_name: fittrackee-db - build: https://github.com/SamR1/FitTrackee.git#${BRANCH}:fittrackee_api/db - ports: - - 5435:5432 - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - fittrackee-api: - container_name: fittrackee-api - build: https://github.com/SamR1/FitTrackee.git#${BRANCH}:fittrackee_api - ports: - - 5001:5000 - environment: - - DATABASE_URL=postgres://postgres:postgres@fittrackee-db:5432/fittrackee - - DATABASE_TEST_URL=postgres://postgres:postgres@fittrackee-db:5432/fittrackee_test - - UI_URL=http://127.0.0.1:3000 - - EMAIL_URL=smtp://none:none@0.0.0.0:1025 - - SENDER_EMAIL=fittrackee@example.com - - FLASK_APP=server.py - - FLASK_DEBUG=1 - - APP_SETTINGS=fittrackee_api.config.TestingConfig - depends_on: - - fittrackee-db - links: - - fittrackee-db - - fittrackee-client: - container_name: fittrackee-client - build: - context: https://github.com/SamR1/FitTrackee.git#${BRANCH} - dockerfile: ./fittrackee_client/Dockerfile - args: - - NODE_ENV=development - - REACT_APP_API_URL=${REACT_APP_API_URL} - - CI=true - ports: - - 3007:3000 - depends_on: - - fittrackee-api - links: - - fittrackee-api - - nginx: - container_name: nginx - build: ./nginx - restart: always - ports: - - 80:80 - depends_on: - - fittrackee-api - - fittrackee-client - links: - - fittrackee-api