Skip to content

Commit 2a8bb66

Browse files
authored
Refactor CI workflow for improved readability
1 parent 9da3f7a commit 2a8bb66

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

.github/workflows/ci.yml

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

43
on:
@@ -55,7 +54,7 @@ jobs:
5554
npm ci
5655
elif [ -f pnpm-lock.yaml ]; then
5756
echo "Found pnpm-lock.yaml -> running: pnpm install --frozen-lockfile"
58-
npm i -g pnpm@latest || true
57+
npm i -g pnpm || true
5958
pnpm install --frozen-lockfile || pnpm install
6059
elif [ -f yarn.lock ]; then
6160
echo "Found yarn.lock -> running: yarn install --frozen-lockfile"
@@ -65,14 +64,14 @@ jobs:
6564
npm install
6665
fi
6766
68-
# run build script if present in package.json
69-
if grep -q '"build"' package.json >/dev/null 2>&1; then
67+
# run build script if present
68+
if npm run | sed -n '1,200p' | grep -q " build"; then
7069
echo "Running npm run build"
7170
npm run build || true
7271
fi
7372
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
73+
# run tests if present
74+
if npm test --silent 2>/dev/null; then
7675
echo "Running npm test"
7776
npm test || true
7877
fi
@@ -95,10 +94,9 @@ jobs:
9594
if [ -f setup.py ]; then
9695
pip install . || true
9796
fi
98-
# run pytest if tests exist
9997
if [ -d tests ] || ls *_test.py >/dev/null 2>&1; then
10098
pip install pytest || true
101-
python -m pytest -q || true
99+
pytest || true
102100
fi
103101
else
104102
echo "No Python packaging files detected"
@@ -131,21 +129,19 @@ jobs:
131129
- name: Collect common artifact paths
132130
id: collect
133131
run: |
134-
# enable nullglob so patterns that don't match are removed (no literal globs)
135-
shopt -s nullglob
136132
paths=""
137133
for p in build dist out; do
138134
if [ -d "$p" ]; then
139135
paths="$paths $p"
140136
fi
141137
done
142138
for a in *.tar.gz *.zip *.exe; do
143-
for f in $a; do
144-
paths="$paths $f"
145-
done
139+
if ls $a >/dev/null 2>&1; then
140+
paths="$paths $a"
141+
fi
146142
done
147-
# Trim leading/trailing whitespace
148-
paths="$(echo "$paths" | sed -e 's/^ *//' -e 's/ *$//')"
143+
# Trim leading space
144+
paths="$(echo $paths | sed 's/^ *//')"
149145
echo "paths=$paths" >> $GITHUB_OUTPUT
150146
151147
- name: Upload build artifacts (if any)

0 commit comments

Comments
 (0)