Skip to content

Commit 1889196

Browse files
authored
Refactor CI workflow for clearer language setup
1 parent bac6369 commit 1889196

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ jobs:
1313
- name: Checkout repository
1414
uses: actions/checkout@v4
1515

16-
- name: Set up Node.js 18 (if present)
16+
- name: Set up Node.js
1717
uses: actions/setup-node@v4
1818
with:
1919
node-version: '18'
2020
cache: 'npm'
2121

22-
- name: Set up Python 3.x (if present)
22+
- name: Set up Python
2323
uses: actions/setup-python@v4
2424
with:
2525
python-version: '3.x'
2626

27-
- name: Set up Go 1.20 (if present)
27+
- name: Set up Go
2828
uses: actions/setup-go@v4
2929
with:
3030
go-version: '1.20'
@@ -34,23 +34,37 @@ jobs:
3434
echo "Repository root:"
3535
ls -la
3636
37-
- name: Detect languages and build/test
37+
- name: Detect languages and install/build/test
3838
run: |
3939
set -e
40-
4140
echo "Repository contents:"
4241
ls -la || true
4342
44-
# Node.js
43+
# NODE: prefer lockfile installs, fall back to normal install
4544
if [ -f package.json ]; then
4645
echo ""
4746
echo "Detected Node.js project (package.json found)"
48-
npm ci || npm install || true
49-
# run build if script exists
47+
if [ -f package-lock.json ]; then
48+
echo "Found package-lock.json → running: npm ci"
49+
npm ci
50+
elif [ -f pnpm-lock.yaml ]; then
51+
echo "Found pnpm-lock.yaml → running: pnpm install --frozen-lockfile"
52+
npm i -g pnpm || true
53+
pnpm install --frozen-lockfile || pnpm install
54+
elif [ -f yarn.lock ]; then
55+
echo "Found yarn.lock → running: yarn install --frozen-lockfile"
56+
yarn install --frozen-lockfile || yarn install
57+
else
58+
echo "No lockfile found → running: npm install (will create package-lock.json locally)"
59+
npm install
60+
fi
61+
62+
# build if script exists
5063
if npm run | sed -n '1,200p' | grep -q " build"; then
5164
echo "Running npm run build"
5265
npm run build || true
5366
fi
67+
5468
# run tests if any
5569
if npm test --silent 2>/dev/null; then
5670
echo "Running npm test"
@@ -60,7 +74,7 @@ jobs:
6074
echo "No package.json found, skipping Node steps"
6175
fi
6276
63-
# Python
77+
# PYTHON
6478
if [ -f requirements.txt ] || [ -f pyproject.toml ] || [ -f setup.py ]; then
6579
echo ""
6680
echo "Detected Python project"
@@ -83,7 +97,7 @@ jobs:
8397
echo "No Python packaging files detected"
8498
fi
8599
86-
# Go
100+
# GO
87101
if ls *.go >/dev/null 2>&1 || [ -d cmd ]; then
88102
echo ""
89103
echo "Detected Go project"
@@ -116,7 +130,6 @@ jobs:
116130
paths="$paths $p"
117131
fi
118132
done
119-
# include common archives
120133
for a in *.tar.gz *.zip *.exe; do
121134
if ls $a >/dev/null 2>&1; then
122135
paths="$paths $a"

0 commit comments

Comments
 (0)