Skip to content

Commit 3b2d107

Browse files
authored
Refactor CI workflow for improved clarity
1 parent 27babb3 commit 3b2d107

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12+
1213
steps:
1314
- name: Checkout repository
1415
uses: actions/checkout@v4
@@ -34,38 +35,42 @@ jobs:
3435
echo "Repository root:"
3536
ls -la
3637
37-
- name: Detect languages and install/build/test
38+
- name: Detect languages and install / build / test
3839
run: |
3940
set -e
4041
echo "Repository contents:"
4142
ls -la || true
4243
43-
# NODE: prefer lockfile installs, fall back to normal install
44+
# -------- Node.js --------
4445
if [ -f package.json ]; then
4546
echo ""
4647
echo "Detected Node.js project (package.json found)"
48+
4749
if [ -f package-lock.json ]; then
48-
echo "Found package-lock.json → running: npm ci"
50+
echo "Found package-lock.json -> running: npm ci"
51+
npm ci
52+
elif [ -f npm-shrinkwrap.json ]; then
53+
echo "Found npm-shrinkwrap.json -> running: npm ci"
4954
npm ci
5055
elif [ -f pnpm-lock.yaml ]; then
51-
echo "Found pnpm-lock.yaml running: pnpm install --frozen-lockfile"
56+
echo "Found pnpm-lock.yaml -> running: pnpm install --frozen-lockfile"
5257
npm i -g pnpm || true
5358
pnpm install --frozen-lockfile || pnpm install
5459
elif [ -f yarn.lock ]; then
55-
echo "Found yarn.lock running: yarn install --frozen-lockfile"
60+
echo "Found yarn.lock -> running: yarn install --frozen-lockfile"
5661
yarn install --frozen-lockfile || yarn install
5762
else
58-
echo "No lockfile found running: npm install (will create package-lock.json locally)"
63+
echo "No lockfile found -> running: npm install (safe fallback)"
5964
npm install
6065
fi
6166
62-
# build if script exists
67+
# run build script if present
6368
if npm run | sed -n '1,200p' | grep -q " build"; then
6469
echo "Running npm run build"
6570
npm run build || true
6671
fi
6772
68-
# run tests if any
73+
# run tests if present
6974
if npm test --silent 2>/dev/null; then
7075
echo "Running npm test"
7176
npm test || true
@@ -74,7 +79,7 @@ jobs:
7479
echo "No package.json found, skipping Node steps"
7580
fi
7681
77-
# PYTHON
82+
# -------- Python --------
7883
if [ -f requirements.txt ] || [ -f pyproject.toml ] || [ -f setup.py ]; then
7984
echo ""
8085
echo "Detected Python project"
@@ -97,7 +102,7 @@ jobs:
97102
echo "No Python packaging files detected"
98103
fi
99104
100-
# GO
105+
# -------- Go --------
101106
if ls *.go >/dev/null 2>&1 || [ -d cmd ]; then
102107
echo ""
103108
echo "Detected Go project"
@@ -109,10 +114,10 @@ jobs:
109114
echo "No Go files detected"
110115
fi
111116
112-
# Makefile
117+
# -------- Makefile --------
113118
if [ -f Makefile ]; then
114119
echo ""
115-
echo "Makefile found — running build/test if present"
120+
echo "Makefile found — running build/test targets if present"
116121
if grep -qE '^build:' Makefile; then
117122
make build || true
118123
fi

0 commit comments

Comments
 (0)