Repository navigation
122 lines (100 loc) · 3.12 KB
/
Copy pathci.yml
File metadata and controls
122 lines (100 loc) · 3.12 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: CI
on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, main ]
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pylint black isort mypy
pip install -r requirements.txt
- name: Run Black formatter check
run: black --check --diff .
- name: Run isort check
run: isort --check-only --diff .
- name: Run flake8
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Run pylint
run: pylint *.py --disable=all --enable=E,F
continue-on-error: true
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov pytest-asyncio
pip install -r requirements.txt
- name: Run tests
run: |
pytest tests/ -v --cov=. --cov-report=xml --cov-report=term
continue-on-error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
fail_ci_if_error: false
continue-on-error: true
validate-k8s:
name: Validate Kubernetes Manifests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install kubeval
run: |
wget https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz
tar xf kubeval-linux-amd64.tar.gz
sudo mv kubeval /usr/local/bin
- name: Validate CRDs
run: |
for file in crds/*.yaml; do
echo "Validating $file"
kubeval --ignore-missing-schemas "$file" || true
done
- name: Validate deployment
run: kubeval --ignore-missing-schemas deployment.yaml || true
build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [lint, validate-k8s]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: nico-operator:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Save Docker image
run: docker save nico-operator:${{ github.sha }} | gzip > nico-operator.tar.gz
- name: Upload Docker image artifact
uses: actions/upload-artifact@v4
with:
name: docker-image
path: nico-operator.tar.gz
retention-days: 7