-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (89 loc) · 3.33 KB
/
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: CI
on:
push:
branches: [development]
pull_request:
branches: [development]
workflow_dispatch: # Manual trigger
jobs:
test:
runs-on: ubuntu-latest
env: # Define environment variables here
PYTHON_VERSION: "3.11"
COVERAGE_THRESHOLD: 20 # Set to 80% in production
BRANCH: development
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache Poetry dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Cache virtual environment
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-venv-
- name: Install dependencies
run: |
poetry install --no-interaction --with dev
- name: Display installed packages
run: |
poetry show
- name: Investigate Pinecone library
run: |
echo "Pinecone library content:"
cat .venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/pinecone/control/pinecone.py
- name: Run unit tests with coverage report
run: |
poetry run python -m pytest -v --cov=./src --cov-report term-missing:skip-covered tests || echo "Some tests failed, but continuing workflow"
- name: Check coverage
run: |
poetry run coverage report -m
COVERAGE=$(poetry run coverage report -m | grep -Po '^TOTAL.*\s(\d+%)$' | awk '{sub("%", "", $NF); print $NF}')
echo "Coverage is $COVERAGE%"
if [ "$COVERAGE" -lt "${{ env.COVERAGE_THRESHOLD }}" ]; then
echo "Warning: Coverage is below ${{ env.COVERAGE_THRESHOLD }}%"
fi
- name: Python Semantic Release
if: github.event_name == 'push' && github.ref == 'refs/heads/development'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions
git config user.email [email protected]
poetry run semantic-release version
poetry run semantic-release publish
- name: Check if release was created
if: github.event_name == 'push' && github.ref == 'refs/heads/development'
id: check-release
run: |
if [ -n "$(git tag --points-at HEAD)" ]; then
echo "RELEASE_CREATED=true" >> $GITHUB_ENV
else
echo "RELEASE_CREATED=false" >> $GITHUB_ENV
fi
- name: Merge development into main if release created
if: github.event_name == 'push' && github.ref == 'refs/heads/development' && env.RELEASE_CREATED == 'true'
run: |
git checkout main
git merge --ff-only ${{ env.BRANCH }}
git push origin main