Skip to content

Commit

Permalink
Move gitlab steps to ci-scripts so we can re-use them.
Browse files Browse the repository at this point in the history
  • Loading branch information
grigorescu committed Jan 5, 2024
1 parent ebc5778 commit 6bc006f
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 19 deletions.
Empty file modified .ci-scripts/create_user.py
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions .ci-scripts/flake8_before.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

pip install -q flake8
5 changes: 5 additions & 0 deletions .ci-scripts/flake8_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

flake8
5 changes: 5 additions & 0 deletions .ci-scripts/pytest_after.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

make clean
12 changes: 12 additions & 0 deletions .ci-scripts/pytest_before.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions .ci-scripts/pytest_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

make coverage.xml
21 changes: 14 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Python package
on: [push]

jobs:
build:
lint:

runs-on: ubuntu-latest
strategy:
Expand All @@ -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
17 changes: 5 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,21 @@ 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
image: docker:24.0.6-dind
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:
Expand Down

0 comments on commit 6bc006f

Please sign in to comment.