Skip to content

Commit 9da3f7a

Browse files
authored
Enhance CI workflow with pnpm and test conditions
Updated CI workflow to use the latest pnpm version and improved test execution checks.
1 parent 3b2d107 commit 9da3f7a

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
url=https://github.com/111byte111/byte/blob/3b2d1079454f49f390d872ff67976876031bac71/.github/workflows/ci.yml
12
name: CI
23

34
on:
@@ -54,7 +55,7 @@ jobs:
5455
npm ci
5556
elif [ -f pnpm-lock.yaml ]; then
5657
echo "Found pnpm-lock.yaml -> running: pnpm install --frozen-lockfile"
57-
npm i -g pnpm || true
58+
npm i -g pnpm@latest || true
5859
pnpm install --frozen-lockfile || pnpm install
5960
elif [ -f yarn.lock ]; then
6061
echo "Found yarn.lock -> running: yarn install --frozen-lockfile"
@@ -64,14 +65,14 @@ jobs:
6465
npm install
6566
fi
6667
67-
# run build script if present
68-
if npm run | sed -n '1,200p' | grep -q " build"; then
68+
# run build script if present in package.json
69+
if grep -q '"build"' package.json >/dev/null 2>&1; then
6970
echo "Running npm run build"
7071
npm run build || true
7172
fi
7273
73-
# run tests if present
74-
if npm test --silent 2>/dev/null; then
74+
# run tests if a test script is present (avoid running tests twice)
75+
if grep -q '"test"' package.json >/dev/null 2>&1 && ! grep -q '"test":[[:space:]]*"echo "package.json" >/dev/null 2>&1; then
7576
echo "Running npm test"
7677
npm test || true
7778
fi
@@ -94,9 +95,10 @@ jobs:
9495
if [ -f setup.py ]; then
9596
pip install . || true
9697
fi
98+
# run pytest if tests exist
9799
if [ -d tests ] || ls *_test.py >/dev/null 2>&1; then
98100
pip install pytest || true
99-
pytest || true
101+
python -m pytest -q || true
100102
fi
101103
else
102104
echo "No Python packaging files detected"
@@ -129,19 +131,21 @@ jobs:
129131
- name: Collect common artifact paths
130132
id: collect
131133
run: |
134+
# enable nullglob so patterns that don't match are removed (no literal globs)
135+
shopt -s nullglob
132136
paths=""
133137
for p in build dist out; do
134138
if [ -d "$p" ]; then
135139
paths="$paths $p"
136140
fi
137141
done
138142
for a in *.tar.gz *.zip *.exe; do
139-
if ls $a >/dev/null 2>&1; then
140-
paths="$paths $a"
141-
fi
143+
for f in $a; do
144+
paths="$paths $f"
145+
done
142146
done
143-
# Trim leading space
144-
paths="$(echo $paths | sed 's/^ *//')"
147+
# Trim leading/trailing whitespace
148+
paths="$(echo "$paths" | sed -e 's/^ *//' -e 's/ *$//')"
145149
echo "paths=$paths" >> $GITHUB_OUTPUT
146150
147151
- name: Upload build artifacts (if any)

0 commit comments

Comments
 (0)