Skip to content

Commit 3e5d58c

Browse files
committed
fix: apply copilot-config, add fail-on-error, session-path output, test assertions
1 parent 0c36400 commit 3e5d58c

File tree

2 files changed

+57
-10
lines changed

2 files changed

+57
-10
lines changed

.github/workflows/test-copilot.yml

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v5
1414
- uses: austenstone/copilot-cli@notoken
15+
id: copilot
1516
with:
1617
prompt: "Say 'hello world' and nothing else."
1718
max-turns: 1
19+
- name: Verify exit code output
20+
run: |
21+
echo "Exit code: ${{ steps.copilot.outputs.exit-code }}"
22+
test "${{ steps.copilot.outputs.exit-code }}" = "0"
1823
19-
# Test autopilot + max-turns limit
24+
# Test autopilot + max-turns limit with tool use
2025
autopilot:
2126
runs-on: ubuntu-latest
2227
steps:
@@ -25,8 +30,12 @@ jobs:
2530
with:
2631
prompt: "Create a file called test.txt with the content 'autopilot works'. Then read it back to confirm."
2732
max-turns: 3
33+
- name: Verify file was created
34+
run: |
35+
test -f test.txt
36+
grep -q "autopilot works" test.txt
2837
29-
# Test silent mode
38+
# Test silent mode — no usage stats in output
3039
silent:
3140
runs-on: ubuntu-latest
3241
steps:
@@ -60,7 +69,7 @@ jobs:
6069
output-format: json
6170
max-turns: 1
6271

63-
# Test tool deny list
72+
# Test tool deny list — shell should be blocked
6473
denied-tools:
6574
runs-on: ubuntu-latest
6675
steps:
@@ -105,18 +114,22 @@ jobs:
105114
denied-urls: "evil.com"
106115
max-turns: 2
107116

108-
# Test share session to file
117+
# Test share session to file + verify output
109118
share:
110119
runs-on: ubuntu-latest
111120
steps:
112121
- uses: actions/checkout@v5
113122
- uses: austenstone/copilot-cli@notoken
123+
id: copilot
114124
with:
115125
prompt: "Say 'session sharing works'."
116126
share: true
117127
max-turns: 1
118-
- name: Check share file exists
119-
run: ls -la copilot-session-*.md || echo "No session file found"
128+
- name: Verify session file exists
129+
run: |
130+
echo "Session path: ${{ steps.copilot.outputs.session-path }}"
131+
test -f "${{ steps.copilot.outputs.session-path }}"
132+
cat "${{ steps.copilot.outputs.session-path }}"
120133
121134
# Test experimental flag
122135
experimental:
@@ -153,3 +166,37 @@ jobs:
153166
prompt: "What files are in this repo?"
154167
agent: explore
155168
max-turns: 2
169+
170+
# Test fail-on-error catches non-zero exit
171+
fail-on-error:
172+
runs-on: ubuntu-latest
173+
steps:
174+
- uses: actions/checkout@v5
175+
- uses: austenstone/copilot-cli@notoken
176+
id: copilot
177+
continue-on-error: true
178+
with:
179+
prompt: "Exit with error code 1 by running: exit 1"
180+
fail-on-error: true
181+
max-turns: 2
182+
- name: Verify exit code was captured
183+
run: |
184+
echo "Exit code: ${{ steps.copilot.outputs.exit-code }}"
185+
echo "Step outcome: ${{ steps.copilot.outcome }}"
186+
187+
# Test copilot-config is applied
188+
config:
189+
runs-on: ubuntu-latest
190+
steps:
191+
- uses: actions/checkout@v5
192+
- uses: austenstone/copilot-cli@notoken
193+
with:
194+
prompt: "Say 'config test passed'."
195+
copilot-config: |
196+
{
197+
"banner": "never",
198+
"render_markdown": false,
199+
"theme": "dark",
200+
"trusted_folders": []
201+
}
202+
max-turns: 1

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,16 @@ runs:
157157
158158
if [ -n "$MCP_CONFIG" ]; then
159159
echo "::group::Configure Copilot MCP"
160-
cat $XDG_CONFIG_HOME/.copilot/mcp-config.json || echo "No existing MCP config found"
161-
mkdir -p $XDG_CONFIG_HOME/.copilot
160+
cat $HOME/.copilot/mcp-config.json 2>/dev/null || echo "No existing MCP config found"
161+
mkdir -p $HOME/.copilot
162162
163163
BASE_MCP_CONFIG='{
164164
"mcpServers": { }
165165
}'
166166
167167
MERGED_MCP_CONFIG=$(echo "$BASE_MCP_CONFIG" | jq --argjson user "$MCP_CONFIG" '.mcpServers += $user.mcpServers')
168-
echo "$MERGED_MCP_CONFIG" > $XDG_CONFIG_HOME/.copilot/mcp-config.json
169-
cat $XDG_CONFIG_HOME/.copilot/mcp-config.json
168+
echo "$MERGED_MCP_CONFIG" > $HOME/.copilot/mcp-config.json
169+
cat $HOME/.copilot/mcp-config.json
170170
echo "::endgroup::"
171171
fi
172172

0 commit comments

Comments
 (0)