Skip to content

Commit 8550023

Browse files
committed
fix ci/cd for github
1 parent 9ae08b7 commit 8550023

File tree

1 file changed

+69
-83
lines changed

1 file changed

+69
-83
lines changed

.github/workflows/ci.yaml

Lines changed: 69 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -3,114 +3,100 @@ name: CI Pipeline
33
on:
44
push:
55
branches:
6-
- main
7-
- staging
8-
- documentation
6+
- "main"
7+
- "staging"
8+
- "documentation"
99
pull_request:
1010
branches:
11-
- main
12-
- staging
13-
- documentation
11+
- "main"
12+
- "staging"
13+
- "documentation"
14+
workflow_dispatch: # Allows manual triggering
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
env:
21+
FORCE_COLOR: 3 # Enables colored output
1422

1523
jobs:
16-
17-
# ----------------------
18-
# 1. Setup Job (Creates venv and Uploads)
19-
# ----------------------
20-
setup:
24+
detect-ci-trigger:
25+
name: Detect CI Trigger
2126
runs-on: ubuntu-latest
2227
steps:
23-
- name: Checkout Code
24-
uses: actions/checkout@v4
25-
26-
- name: Setup Python Virtual Environment
27-
run: |
28-
python -m venv .venv
29-
. .venv/bin/activate
30-
pip install --no-cache-dir -e .
31-
pip install flake8 pytest-flake8 pytest-cov coverage
32-
python -c "import gedidb; print(gedidb.__version__)"
33-
34-
- name: Verify Virtual Environment
35-
run: |
36-
if [ ! -d ".venv" ]; then
37-
echo "Error: .venv directory does not exist!" && exit 1
38-
fi
39-
40-
- name: Upload Virtual Environment
41-
uses: actions/upload-artifact@v4
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 2
31+
- uses: gedidb-contrib/ci-trigger@v1
32+
id: detect-trigger
4233
with:
43-
name: python-env
44-
path: .venv/**
34+
keyword: "[skip-ci]"
35+
outputs:
36+
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
4537

46-
# ----------------------
47-
# 2. Unit Test Job (Downloads venv and Runs Tests)
48-
# ----------------------
4938
test:
50-
runs-on: ubuntu-latest
51-
needs: setup # Run only after setup completes
39+
name: ${{ matrix.os }} | py${{ matrix.python-version }}
40+
runs-on: ${{ matrix.os }}
41+
needs: detect-ci-trigger
42+
if: needs.detect-ci-trigger.outputs.triggered == 'false'
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
47+
python-version: ["3.8", "3.10", "3.12"]
48+
5249
steps:
5350
- name: Checkout Code
5451
uses: actions/checkout@v4
52+
with:
53+
fetch-depth: 0
5554

56-
- name: Download Virtual Environment
57-
uses: actions/download-artifact@v4
55+
- name: Setup Python Environment
56+
uses: actions/setup-python@v5
5857
with:
59-
name: python-env
60-
path: .venv
58+
python-version: ${{ matrix.python-version }}
59+
cache: "pip"
6160

62-
- name: Verify Downloaded Virtual Environment
61+
- name: Install Dependencies
6362
run: |
64-
if [ ! -d ".venv" ]; then
65-
echo "Error: .venv directory missing after download!" && exit 1
66-
fi
63+
python -m pip install --upgrade pip
64+
python -m pip install --no-cache-dir -e .
65+
python -m pip install pytest pytest-cov flake8 pytest-xdist
6766
68-
- name: Install Coverage Dependencies
69-
run: |
70-
. .venv/bin/activate
71-
pip install pytest-cov
67+
- name: Run Linting (Flake8)
68+
run: flake8 gedidb
7269

7370
- name: Run Tests
7471
run: |
75-
. .venv/bin/activate
76-
pytest --cov=gedidb --cov-branch --cov-report=xml --cov-report=term
72+
pytest -n 4 --timeout=180 \
73+
--cov=gedidb --cov-branch --cov-report=xml --cov-report=term \
74+
--junitxml=pytest.xml
7775
78-
- name: Upload Coverage Report (Optional)
76+
- name: Upload Test Results
77+
if: always()
7978
uses: actions/upload-artifact@v4
8079
with:
81-
name: coverage-report
82-
path: coverage.xml
80+
name: Test Results (${{ matrix.os }} - py${{ matrix.python-version }})
81+
path: pytest.xml
8382

84-
- name: Upload Results to Codecov
85-
uses: codecov/codecov-action@v5
83+
- name: Upload Code Coverage to Codecov
84+
uses: codecov/codecov-action@v5.3.1
85+
env:
86+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8687
with:
87-
token: ${{ secrets.CODECOV_TOKEN }}
88-
files: coverage.xml
89-
fail_ci_if_error: true
90-
91-
# ----------------------
92-
# 3. Linting Job (Downloads venv and Runs Linting)
93-
# ----------------------
94-
lint:
88+
file: ./coverage.xml
89+
flags: unittests
90+
env_vars: RUNNER_OS,PYTHON_VERSION
91+
name: codecov-umbrella
92+
fail_ci_if_error: false
93+
94+
event_file:
95+
name: "Event File"
9596
runs-on: ubuntu-latest
96-
needs: setup
9797
steps:
98-
- name: Checkout Code
99-
uses: actions/checkout@v4
100-
101-
- name: Download Virtual Environment
102-
uses: actions/download-artifact@v4
98+
- name: Upload GitHub Event File
99+
uses: actions/upload-artifact@v4
103100
with:
104-
name: python-env
105-
path: .venv
106-
107-
- name: Verify Downloaded Virtual Environment
108-
run: |
109-
if [ ! -d ".venv" ]; then
110-
echo "Error: .venv directory missing after download!" && exit 1
111-
fi
112-
113-
- name: Run Flake8 Linting
114-
run: |
115-
. .venv/bin/activate
116-
flake8
101+
name: Event File
102+
path: ${{ github.event_path }}

0 commit comments

Comments
 (0)