Skip to content

Commit 0b9a975

Browse files
authored
Create main.yml
1 parent 9a4a1d1 commit 0b9a975

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

.github/workflows/main.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *' # Daily “At 00:00”
7+
8+
jobs:
9+
test:
10+
name: Python (${{ matrix.python-version }}, ${{ matrix.os }})
11+
runs-on: ${{ matrix.os }}
12+
defaults:
13+
run:
14+
shell: bash -l {0}
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: ["ubuntu-latest", "macos-latest", "macos-14", "windows-latest"]
20+
python-version: ["3.10", "3.11", "3.12", "3.13"]
21+
22+
steps:
23+
- name: Cancel previous runs
24+
uses: styfle/[email protected]
25+
with:
26+
access_token: ${{ github.token }}
27+
28+
- name: checkout
29+
uses: actions/checkout@v4
30+
with:
31+
token: ${{ github.token }}
32+
33+
# Conda
34+
- name: conda_setup (x64)
35+
if: matrix.os != 'macos-14'
36+
uses: conda-incubator/setup-miniconda@v3
37+
with:
38+
activate-environment: uxarray_build
39+
channel-priority: strict
40+
python-version: ${{ matrix.python-version }}
41+
channels: conda-forge
42+
environment-file: ci/environment.yml
43+
miniforge-variant: Miniforge3
44+
miniforge-version: latest
45+
46+
- name: conda_setup (ARM64)
47+
if: matrix.os == 'macos-14'
48+
uses: conda-incubator/setup-miniconda@v3
49+
with:
50+
activate-environment: uxarray_build
51+
channel-priority: strict
52+
python-version: ${{ matrix.python-version }}
53+
channels: conda-forge
54+
environment-file: ci/environment.yml
55+
installer-url: https://github.com/conda-forge/miniforge/releases/download/23.11.0-0/Miniforge3-23.11.0-0-MacOSX-arm64.sh
56+
57+
- name: Install uxarray
58+
run: |
59+
python -m pip install . --no-deps
60+
61+
- name: conda list
62+
run: conda list
63+
64+
# Namespace
65+
- name: Run Namespace Tests (timed + durations)
66+
run: |
67+
python - <<'PY'
68+
import subprocess, sys, time
69+
cmd = [sys.executable, "-m", "pytest", "test", "-q", "--durations=0"]
70+
t0 = time.time()
71+
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
72+
with open("pytest_durations_ns.txt", "w", encoding="utf-8") as f:
73+
for line in p.stdout:
74+
print(line, end="")
75+
f.write(line)
76+
rc = p.wait()
77+
dt = time.time() - t0
78+
with open("total_time_ns.txt", "w", encoding="utf-8") as f:
79+
f.write(f"{dt:.3f} seconds")
80+
sys.exit(rc)
81+
PY
82+
83+
# Coverage
84+
- name: Run Coverage Tests (timed + durations)
85+
env:
86+
NUMBA_DISABLE_JIT: 1
87+
run: |
88+
python - <<'PY'
89+
import subprocess, sys, time
90+
cmd = [sys.executable, "-m", "pytest", "test", "-v",
91+
"--cov=./uxarray", "--cov-report=xml", "--durations=0"]
92+
t0 = time.time()
93+
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
94+
with open("pytest_durations_cov.txt", "w", encoding="utf-8") as f:
95+
for line in p.stdout:
96+
print(line, end="")
97+
f.write(line)
98+
rc = p.wait()
99+
dt = time.time() - t0
100+
with open("total_time_cov.txt", "w", encoding="utf-8") as f:
101+
f.write(f"{dt:.3f} seconds")
102+
sys.exit(rc)
103+
PY
104+
105+
# Summary
106+
- name: Add timing summary
107+
if: always()
108+
run: |
109+
echo "## Test Timing Summary" >> "$GITHUB_STEP_SUMMARY"
110+
echo "" >> "$GITHUB_STEP_SUMMARY"
111+
echo "- **Namespace tests total**: \`$(cat total_time_ns.txt 2>/dev/null || echo N/A)\`" >> "$GITHUB_STEP_SUMMARY"
112+
echo "- **Coverage tests total**: \`$(cat total_time_cov.txt 2>/dev/null || echo N/A)\`" >> "$GITHUB_STEP_SUMMARY"
113+
echo "" >> "$GITHUB_STEP_SUMMARY"
114+
echo "<details><summary>Namespace: pytest --durations=0</summary>" >> "$GITHUB_STEP_SUMMARY"
115+
echo "" >> "$GITHUB_STEP_SUMMARY"
116+
sed 's/^/ /' pytest_durations_ns.txt >> "$GITHUB_STEP_SUMMARY" || true
117+
echo "" >> "$GITHUB_STEP_SUMMARY"
118+
echo "</details>" >> "$GITHUB_STEP_SUMMARY"
119+
echo "" >> "$GITHUB_STEP_SUMMARY"
120+
echo "<details><summary>Coverage: pytest --durations=0</summary>" >> "$GITHUB_STEP_SUMMARY"
121+
echo "" >> "$GITHUB_STEP_SUMMARY"
122+
sed 's/^/ /' pytest_durations_cov.txt >> "$GITHUB_STEP_SUMMARY" || true
123+
echo "" >> "$GITHUB_STEP_SUMMARY"
124+
echo "</details>" >> "$GITHUB_STEP_SUMMARY"
125+
126+
# Upload artifacts
127+
- name: Upload timing logs
128+
if: always()
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: timings-${{ matrix.os }}-py${{ matrix.python-version }}
132+
path: |
133+
pytest_durations_ns.txt
134+
total_time_ns.txt
135+
pytest_durations_cov.txt
136+
total_time_cov.txt
137+
138+
- name: Upload code coverage to Codecov
139+
if: github.repository == 'UXARRAY/uxarray'
140+
uses: codecov/[email protected]
141+
env:
142+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
143+
with:
144+
file: ./coverage.xml
145+
flags: unittests
146+
env_vars: OS,PYTHON
147+
name: codecov-umbrella
148+
fail_ci_if_error: false

0 commit comments

Comments
 (0)