diff --git a/.ci-scripts/create_user.py b/.ci-scripts/create_user.py old mode 100644 new mode 100755 diff --git a/.ci-scripts/flake8_before.sh b/.ci-scripts/flake8_before.sh new file mode 100755 index 00000000..230dad7b --- /dev/null +++ b/.ci-scripts/flake8_before.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +pip install -q flake8 diff --git a/.ci-scripts/flake8_run.sh b/.ci-scripts/flake8_run.sh new file mode 100755 index 00000000..8766b950 --- /dev/null +++ b/.ci-scripts/flake8_run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +flake8 diff --git a/.ci-scripts/pytest_after.sh b/.ci-scripts/pytest_after.sh new file mode 100755 index 00000000..6ccbe1f4 --- /dev/null +++ b/.ci-scripts/pytest_after.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +make clean diff --git a/.ci-scripts/pytest_before.sh b/.ci-scripts/pytest_before.sh new file mode 100755 index 00000000..c2b7180f --- /dev/null +++ b/.ci-scripts/pytest_before.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +apk add make +docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY +export COMPOSE_PROJECT_NAME=$CI_PIPELINE_ID +.ci-scripts/pull_images.sh +make build +.ci-scripts/push_images.sh +make migrate +make run diff --git a/.ci-scripts/pytest_run.sh b/.ci-scripts/pytest_run.sh new file mode 100755 index 00000000..b9998799 --- /dev/null +++ b/.ci-scripts/pytest_run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +make coverage.xml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 94f58a96..24d69f21 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ name: Python package on: [push] jobs: - build: + lint: runs-on: ubuntu-latest strategy: @@ -18,10 +18,17 @@ jobs: with: python-version: ${{ matrix.python }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest pytest-cov + - name: [flake8] before + run: ./.ci-scripts/flake8_before.sh - - name: Test with Flake8 - run: flake8 + - name: [flake8] run + run: ./.ci-scripts/flake8_run.sh + + - name: [pytest] before + run: ./.ci-scripts/pytest_before.sh + + - name: [pytest] run + run: ./.ci-scripts/pytest_run.sh + + - name: [pytest] after + run: ./.ci-scripts/pytest_after.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 84164efa..acba6914 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,9 +18,9 @@ flake8: stage: lint image: python:3.8-alpine before_script: - - pip install -q flake8 + - ./.ci_scripts/flake8_before.sh script: - - flake8 + - ./.ci_scripts/flake8_run.sh pytest: stage: test @@ -28,18 +28,11 @@ pytest: services: - docker:dind before_script: - - apk add make - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - export COMPOSE_PROJECT_NAME=$CI_PIPELINE_ID - - ".ci-scripts/pull_images.sh" - - make build - - ".ci-scripts/push_images.sh" - - make migrate - - make run + - ./.ci_scripts/pytest_before.sh script: - - make coverage.xml + - ./.ci_scripts/pytest_run.sh after_script: - - make clean + - ./.ci_scripts/pytest_after.sh artifacts: reports: coverage_report: