-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (116 loc) · 3.87 KB
/
build.yaml
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: build_and_test
on:
push:
branches:
- main
tags:
- "*"
pull_request:
jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
with:
# Need to clone everything for the git tags.
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "setup.cfg"
- name: Update pip/wheel infrastructure
run: |
python -m pip install --upgrade pip
pip install uv
uv pip install --system wheel
- name: Install dependencies
run: |
uv pip install --system -r requirements.txt
# We have two cores so we can speed up the testing with xdist
- name: Install pytest packages
run: |
uv pip install --system pytest pytest-xdist pytest-cov
- name: List installed packages
run: |
uv pip list -v
- name: Build and install
run: |
uv pip install -v --system --no-deps -e .
- name: Run tests
run: |
pytest -r a -v -n 3 --cov=lsst.dax.obscore --cov=tests --cov-report=xml --cov-report=term --cov-branch \
--junitxml=junit.xml -o junit_family=legacy
butler obscore -h
- name: Upload coverage to codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
check-changes:
outputs:
skip: ${{ steps.check.outputs.skip }}
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if weekly changed
id: check
run: |
# Get SHA hashes for all weekly tags
weekly_sha=$(git tag -l 'w.*' | while read tag; do
git rev-list -n 1 "${tag}"
done)
echo "Weekly tag SHA ${weekly_sha}"
# Extract the current tag and its SHA
current_tag=${GITHUB_REF#refs/tags/}
echo "Current tag: ${current_tag}"
current_sha=$(git rev-list -1 "${current_tag}") || echo "no_value"
echo "Current sha: ${current_sha}"
# Count occurrences of the current SHA in the weekly SHA list
n=$(echo "${weekly_sha}" | grep -c "${current_sha}") || echo "0"
echo "Current tag ${current_tag} (${current_sha}) SHA found ${n} time(s)"
# Determine whether to skip the upload based on the count
if [ "${n}" -gt 1 ]; then
echo "Skip upload"
echo "skip=true" >> "${GITHUB_OUTPUT}"
else
echo "Enable upload"
echo "skip=false" >> "${GITHUB_OUTPUT}"
fi
pypi:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [build_and_test, check-changes]
permissions:
id-token: write
if: "${{ ! startsWith(github.ref, 'refs/tags/w.') || needs.check-changes.outputs.skip == 'false' }}"
steps:
- uses: actions/checkout@v4
with:
# Need to clone everything to embed the version.
fetch-depth: 0
- 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 --upgrade setuptools wheel build
- name: Build and create distribution
run: |
python -m build --skip-dependency-check
- name: Upload
uses: pypa/gh-action-pypi-publish@release/v1