-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
81 lines (74 loc) · 1.97 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main"'
when: always
- when: never
default:
image: python:3.11
before_script:
- apt-get update -qq && apt-get install -y curl
- curl -L https://fly.io/install.sh | sh
- export FLYCTL_INSTALL="/root/.fly"
- export PATH="$FLYCTL_INSTALL/bin:$PATH"
- python --version
- python -m pip install virtualenv
- python -m venv .venv
variables:
PYTHONPATH: "$CI_PROJECT_DIR"
stages:
- install
- test
- code_quality
- deploy
install_dependencies:
stage: install
script:
- source .venv/bin/activate
- python -m pip install -r app/requirements/requirements-dev.txt
- python -m pip install -r app/requirements/requirements.txt
- python -m pip install pre-commit
rules:
- changes:
- Makefile
- base.in
- requirements-requirements-test.in
- requirements-dev.in
- requirements.in
- pyproject.toml
when: never
- when: always
config_changes:
stage: test
image: python:3.11
script:
- source .venv/bin/activate
rules:
- changes:
- Makefile
- requirements-dev.in
- requirements.in
- pyproject.toml
when: never
- when: always
bandit:
stage: code_quality
script:
- source .venv/bin/activate
- python -m pip install pre-commit
- pre-commit run bandit --all-files
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main"'
- when: always
deploy-backend:
stage: deploy
script:
- echo "Deploy backend app from $CI_COMMIT_BRANCH branch"
- flyctl auth token $FLY_API_TOKEN
- flyctl deploy --ha=false --config fly.toml --dockerfile Dockerfile -a insight-ai-api
environment: production
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
- when: manual
- if: $CI_MERGE_REQUEST_TITLE =~ /^Draft:/
when: never