-
Notifications
You must be signed in to change notification settings - Fork 4
104 lines (94 loc) · 3.55 KB
/
Copy pathai-build-test-backend.yml
File metadata and controls
104 lines (94 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Build & Test Backend
on:
workflow_call:
inputs:
run_tests:
description: "Whether to run tests"
required: false
type: boolean
default: true
fail_on_test_failure:
description: "Whether to fail the workflow if tests fail"
required: false
type: boolean
default: true
outputs:
backend_success:
description: "Whether backend build was successful"
value: ${{ jobs.backend.outputs.build_success }}
backend_tests_success:
description: "Whether backend tests were successful"
value: ${{ jobs.backend.outputs.tests_success }}
secrets:
APP_ID:
required: false
APP_PRIVATE_KEY:
required: false
jobs:
backend:
name: Backend Build & Test
runs-on: ubuntu-latest
outputs:
build_success: ${{ steps.backend-build.outcome == 'success' || steps.build-heal.outputs.fixed == 'true' }}
tests_success: ${{ steps.test-backend.outcome == 'success' || steps.test-heal.outputs.fixed == 'true' || !inputs.run_tests }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Bun with version scripts
uses: ./.github/actions/setup-bun-version
with:
checkout: 'false'
# === BACKEND BUILD PHASE ===
- name: Build Backend
id: backend-build
continue-on-error: true
run: |
echo "=== Building Backend ==="
cd backend
bun install
bun run build 2>&1 | tee ../backend-build.log
- name: 🤖 Copilot Self-Heal (Backend Build)
id: build-heal
if: false # disabled — ${{ steps.backend-build.outcome == 'failure' }}
uses: ./.github/actions/copilot-self-heal
with:
error-log: backend-build.log
phase: build
component: backend
client-id: ${{ secrets.APP_ID }}
app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
retry-command: 'cd backend && rm -rf dist/ && bun run build'
- name: Fail if Backend Build Unresolved
if: ${{ steps.backend-build.outcome == 'failure' && steps.build-heal.outputs.fixed != 'true' }}
run: |
echo "❌ Backend build failed and Copilot could not fix it"
cat backend-build.log
exit 1
# === BACKEND TEST PHASE ===
- name: Test Backend
if: ${{ inputs.run_tests }}
id: test-backend
continue-on-error: true
run: |
echo "=== Running Backend Tests ==="
cd backend
# --isolate is REQUIRED: test files use process-global mock.module()
# that collide across files without it (see docs/keycloak-features.md).
bun test --isolate 2>&1 | tee ../backend-test.log
- name: 🤖 Copilot Self-Heal (Backend Tests)
id: test-heal
if: false # disabled — ${{ inputs.run_tests && steps.test-backend.outcome == 'failure' }}
uses: ./.github/actions/copilot-self-heal
with:
error-log: backend-test.log
phase: test
component: backend
client-id: ${{ secrets.APP_ID }}
app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
retry-command: 'cd backend && bun test --isolate'
- name: Fail if Backend Tests Unresolved
if: ${{ inputs.run_tests && steps.test-backend.outcome == 'failure' && steps.test-heal.outputs.fixed != 'true' && inputs.fail_on_test_failure }}
run: |
echo "❌ Backend tests failed and Copilot could not fix them"
cat backend-test.log
exit 1