Skip to content

Commit be0ebf6

Browse files
robtaylorclaude
andcommitted
Make Claude-based tests conditional on API key presence
- Added checks for ANTHROPIC_API_KEY secret availability - Skip Claude-based API calls when key is not available - Added helpful warnings in workflow summaries when tests are skipped - Made artifact uploads conditional on API key availability This allows the workflows to pass when run in forks or environments without the API key configured. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 93722fd commit be0ebf6

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.github/workflows/tutorial-comprehension-test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,29 @@ jobs:
103103
104104
chmod +x analyze_tutorial.js
105105
106+
- name: Check ANTHROPIC_API_KEY is set
107+
id: check_api_key
108+
run: |
109+
if [ -n "${{ secrets.ANTHROPIC_API_KEY }}" ]; then
110+
echo "API key is set, proceeding with Claude analysis"
111+
echo "has_api_key=true" >> $GITHUB_OUTPUT
112+
else
113+
echo "ANTHROPIC_API_KEY is not set. Skipping Claude analysis."
114+
echo "has_api_key=false" >> $GITHUB_OUTPUT
115+
echo "## ⚠️ Warning - Claude Analysis Skipped" >> $GITHUB_STEP_SUMMARY
116+
echo "* ANTHROPIC_API_KEY secret is not configured in this repository" >> $GITHUB_STEP_SUMMARY
117+
echo "* Analysis will be skipped for now" >> $GITHUB_STEP_SUMMARY
118+
echo "* This test will run automatically once the secret is configured" >> $GITHUB_STEP_SUMMARY
119+
fi
120+
106121
- name: Analyze tutorial with Claude
122+
if: steps.check_api_key.outputs.has_api_key == 'true'
107123
env:
108124
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
109125
run: node analyze_tutorial.js
110126

111127
- name: Archive analysis results
128+
if: steps.check_api_key.outputs.has_api_key == 'true'
112129
uses: actions/upload-artifact@v4
113130
with:
114131
name: tutorial-analysis

.github/workflows/tutorial-execution-test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,29 @@ jobs:
236236
237237
chmod +x execute_tutorial.js
238238
239+
- name: Check ANTHROPIC_API_KEY is set
240+
id: check_api_key
241+
run: |
242+
if [ -n "${{ secrets.ANTHROPIC_API_KEY }}" ]; then
243+
echo "API key is set, proceeding with Claude execution test"
244+
echo "has_api_key=true" >> $GITHUB_OUTPUT
245+
else
246+
echo "ANTHROPIC_API_KEY is not set. Skipping Claude-based execution."
247+
echo "has_api_key=false" >> $GITHUB_OUTPUT
248+
echo "## ⚠️ Warning - Claude Execution Test Skipped" >> $GITHUB_STEP_SUMMARY
249+
echo "* ANTHROPIC_API_KEY secret is not configured in this repository" >> $GITHUB_STEP_SUMMARY
250+
echo "* Execution test will be skipped for now" >> $GITHUB_STEP_SUMMARY
251+
echo "* This test will run automatically once the secret is configured" >> $GITHUB_STEP_SUMMARY
252+
fi
253+
239254
- name: Execute tutorial with Claude
255+
if: steps.check_api_key.outputs.has_api_key == 'true'
240256
env:
241257
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
242258
run: node execute_tutorial.js
243259

244260
- name: Archive execution results
261+
if: steps.check_api_key.outputs.has_api_key == 'true'
245262
uses: actions/upload-artifact@v4
246263
with:
247264
name: tutorial-execution-results

0 commit comments

Comments
 (0)