Skip to content

Commit c889a3d

Browse files
fix: agent-ci.yml — handle repos without lockfile
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 49df84b commit c889a3d

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

.github/workflows/agent-ci.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
issues:
99
types: [opened, labeled]
1010
schedule:
11-
- cron: '0 6 * * 1' # Weekly Monday 6am audit
11+
- cron: '0 6 * * 1'
1212

1313
permissions:
1414
contents: write
@@ -30,7 +30,7 @@ jobs:
3030
has_tests: ${{ steps.detect.outputs.has_tests }}
3131
steps:
3232
- uses: actions/checkout@v4
33-
33+
3434
- name: Detect Framework
3535
id: detect
3636
run: |
@@ -41,32 +41,46 @@ jobs:
4141
else echo "framework=node" >> $GITHUB_OUTPUT; fi
4242
if grep -q '"test"' package.json; then echo "has_tests=true" >> $GITHUB_OUTPUT
4343
else echo "has_tests=false" >> $GITHUB_OUTPUT; fi
44+
if [ -f "package-lock.json" ] || [ -f "yarn.lock" ] || [ -f "pnpm-lock.yaml" ]; then
45+
echo "has_lockfile=true" >> $GITHUB_OUTPUT
46+
else
47+
echo "has_lockfile=false" >> $GITHUB_OUTPUT
48+
fi
4449
elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
4550
echo "framework=python" >> $GITHUB_OUTPUT
4651
if [ -d "tests" ] || [ -d "test" ]; then echo "has_tests=true" >> $GITHUB_OUTPUT
4752
else echo "has_tests=false" >> $GITHUB_OUTPUT; fi
53+
echo "has_lockfile=false" >> $GITHUB_OUTPUT
4854
elif [ -f "go.mod" ]; then
4955
echo "framework=go" >> $GITHUB_OUTPUT
5056
echo "has_tests=true" >> $GITHUB_OUTPUT
57+
echo "has_lockfile=false" >> $GITHUB_OUTPUT
5158
else
5259
echo "framework=static" >> $GITHUB_OUTPUT
5360
echo "has_tests=false" >> $GITHUB_OUTPUT
61+
echo "has_lockfile=false" >> $GITHUB_OUTPUT
5462
fi
55-
56-
- name: Setup Node
57-
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework)
63+
64+
- name: Setup Node (with cache)
65+
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework) && steps.detect.outputs.has_lockfile == 'true'
5866
uses: actions/setup-node@v4
5967
with:
6068
node-version: '22'
6169
cache: 'npm'
62-
70+
71+
- name: Setup Node (no cache)
72+
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework) && steps.detect.outputs.has_lockfile == 'false'
73+
uses: actions/setup-node@v4
74+
with:
75+
node-version: '22'
76+
6377
- name: Install & Build (Node)
6478
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework)
6579
run: |
6680
npm ci --ignore-scripts 2>/dev/null || npm install
6781
npm run build --if-present
6882
continue-on-error: true
69-
83+
7084
- name: Test (Node)
7185
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework) && steps.detect.outputs.has_tests == 'true'
7286
run: npm test -- --passWithNoTests 2>/dev/null || npm test
@@ -77,7 +91,7 @@ jobs:
7791
uses: actions/setup-python@v5
7892
with:
7993
python-version: '3.12'
80-
94+
8195
- name: Install & Test (Python)
8296
if: steps.detect.outputs.framework == 'python'
8397
run: |

0 commit comments

Comments
 (0)