Skip to content

Commit cff4e39

Browse files
committed
cicd: get skip and build values from pyproject
When cicd disables tests it also overrides skip and build values. To make it work we need to populate them back via environment. Let's read them from pyproject.tom which will not require keep them in sync.
1 parent 377777e commit cff4e39

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

.github/workflows/lib-build-and-push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ jobs:
9898
echo "CIBW_TEST_COMMAND=true" >> $GITHUB_ENV;
9999
echo "CIBW_TEST_COMMAND_WINDOWS=(exit 0)" >> $GITHUB_ENV;
100100
echo "CIBW_TEST_SKIP=*" >> $GITHUB_ENV;
101-
echo "CIBW_SKIP=cp2* cp36* pp36* cp37* pp37* cp38* pp38* cp39* pp39* *i686 *musllinux*" >> $GITHUB_ENV;
102-
echo "CIBW_BUILD=cp3* pp3*" >> $GITHUB_ENV;
101+
echo "CIBW_SKIP=`scripts/get-pyproject-value.sh tool.cibuildwheel skip`" >> $GITHUB_ENV;
102+
echo "CIBW_BUILD=`scripts/get-pyproject-value.sh tool.cibuildwheel build`" >> $GITHUB_ENV;
103103
echo "CIBW_BEFORE_TEST=true" >> $GITHUB_ENV;
104104
echo "CIBW_BEFORE_TEST_WINDOWS=(exit 0)" >> $GITHUB_ENV;
105105

scripts/get-pyproject-value.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
TARGET_SECTION=${1:?section name like tool.cibuildwheel}
5+
TARGET_FIELD=${2:?field name like skip or build-frontend}
6+
7+
# Resolve pyproject.toml relative to script location
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
PYPROJECT_FILE="$SCRIPT_DIR/../pyproject.toml"
10+
11+
awk -v sec="$TARGET_SECTION" -v field="$TARGET_FIELD" '
12+
/^\[/ {
13+
# exact match on section header, treat dots literally
14+
in_section = ($0 == "[" sec "]")
15+
}
16+
17+
in_section {
18+
# Match "field = ..."
19+
if (match($0, "^[ \t]*" field "[ \t]*=")) {
20+
rhs = substr($0, RSTART + RLENGTH)
21+
gsub(/^[ \t]+/, "", rhs)
22+
23+
if (rhs ~ /^\[/) {
24+
# Multiline or inline array
25+
buf = rhs
26+
while (buf !~ /\]/ && (getline > 0)) buf = buf " " $0
27+
if (match(buf, /\[(.*)\]/, m)) {
28+
s = m[1]
29+
gsub(/["'\'' ,]/, " ", s)
30+
gsub(/[ \t]+/, " ", s)
31+
gsub(/^[ \t]+|[ \t]+$/, "", s)
32+
print s
33+
exit
34+
}
35+
} else {
36+
# Scalar string or number, like "build[uv]"
37+
s = rhs
38+
gsub(/^["'\'' ]+|["'\'' ]+$/, "", s)
39+
print s
40+
exit
41+
}
42+
}
43+
}
44+
' "$PYPROJECT_FILE"

0 commit comments

Comments
 (0)