-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
81 lines (69 loc) · 2.17 KB
/
.gitlab-ci.yml
File metadata and controls
81 lines (69 loc) · 2.17 KB
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
# GitLab CI/CD Pipeline for Python Client-Server Demo
# This pipeline works with GitHub repos mirrored to GitLab
stages:
- lint
- test
- build
# Use Python 3.11 as the base image
image: python:3.11-slim
# Cache pip dependencies between jobs
cache:
paths:
- .cache/pip
- venv/
# Setup virtual environment before each job
before_script:
- python -m venv venv
- source venv/bin/activate
- pip install --cache-dir .cache/pip -r requirements.txt
# =============================================================================
# LINT STAGE
# =============================================================================
lint:flake8:
stage: lint
script:
- echo "Running flake8 linter..."
- flake8 server/ client/ tests/ --max-line-length=100 --ignore=E501
allow_failure: false
lint:black:
stage: lint
script:
- echo "Checking code formatting with black..."
- black --check --diff server/ client/ tests/
allow_failure: true # Formatting is advisory
# =============================================================================
# TEST STAGE
# =============================================================================
test:unit:
stage: test
script:
- echo "Running unit tests..."
- pytest tests/ -v --cov=server --cov-report=term-missing --cov-report=xml:coverage.xml
coverage: '/TOTAL.*\s+(\d+%)/'
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- coverage.xml
expire_in: 30 days
test:import:
stage: test
script:
- echo "Verifying imports work correctly..."
- python -c "from server.app import app; print('Server import OK')"
- python -c "from client.client import DemoClient; print('Client import OK')"
# =============================================================================
# BUILD STAGE
# =============================================================================
build:verify:
stage: build
script:
- echo "Verifying the application can start..."
- python -c "from server.app import app; app.config['TESTING'] = True; print('Build verification passed!')"
only:
- main
- master
- merge_requests