-
Notifications
You must be signed in to change notification settings - Fork 6
164 lines (146 loc) · 5.28 KB
/
pull-request.yaml
File metadata and controls
164 lines (146 loc) · 5.28 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Pull Request
on:
pull_request:
workflow_dispatch:
inputs:
debug_cypress:
description: "Enable Cypress debug mode (videos, extra logs)"
type: boolean
default: false
permissions:
contents: read
id-token: write # Required for upload.yaml AWS OIDC authentication
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
jobs:
# Detect if any code files changed (to skip CI for docs-only PRs)
detect-changes:
runs-on: ubuntu-latest
outputs:
# has-code is true if ANY non-doc file changed
has-code: ${{ steps.check.outputs.has-code }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Need full history for diff
- name: Check for code changes
id: check
run: |
# Get the base ref for comparison
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
# For workflow_dispatch, compare with main
BASE_SHA="origin/main"
fi
# Get list of changed files
CHANGED_FILES=$(git diff --name-only "$BASE_SHA"...HEAD 2>/dev/null || git diff --name-only "$BASE_SHA" HEAD)
if [[ -z "$CHANGED_FILES" ]]; then
echo "No files changed"
echo "has-code=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Changed files:"
echo "$CHANGED_FILES"
echo ""
# Check if any file is NOT a doc file
# Doc files: *.md, LICENSE, .gitignore, .gitattributes
has_code="false"
while IFS= read -r file; do
case "$file" in
*.md|LICENSE|.gitignore|.gitattributes)
# This is a doc file, skip
;;
*)
# This is a code file
echo "Code file found: $file"
has_code="true"
break
;;
esac
done <<< "$CHANGED_FILES"
if [[ "$has_code" == "true" ]]; then
echo "has-code=true" >> $GITHUB_OUTPUT
echo "Code files changed"
else
echo "has-code=false" >> $GITHUB_OUTPUT
echo "Only documentation files changed"
fi
# Linting and formatting - always runs
lint:
uses: ./.github/workflows/lint.yaml
# Unit Tests - skip if no code changes
home-view-unit-tests:
needs: detect-changes
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/home-view-unit-test.yaml
agent:
needs: detect-changes
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/agent.yaml
vscode:
needs: detect-changes
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/vscode.yaml
interpreter-integration:
needs: detect-changes
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/interpreter-integration.yaml
connect-contract-tests:
needs: detect-changes
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/connect-contract-tests.yaml
# Build - skip if no code changes
build:
needs: detect-changes
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/build.yaml
package:
needs: [detect-changes, build]
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/package.yaml
archive:
needs: [detect-changes, build]
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/archive.yaml
# E2E Tests - skip if no code changes or if PR is from a fork
e2e:
needs: [detect-changes, home-view-unit-tests, agent, vscode, package]
if: |
always() &&
github.event.pull_request.head.repo.full_name == github.repository &&
needs.detect-changes.outputs.has-code == 'true' &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/e2e.yaml
with:
debug_cypress: ${{ inputs.debug_cypress || false }}
secrets:
CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }}
CONNECT_LICENSE_FILE: ${{ secrets.CONNECT_LICENSE_FILE }}
WORKBENCH_LICENSE: ${{ secrets.WORKBENCH_LICENSE }}
GH_DOWNLOAD_TOKEN: ${{ secrets.GH_DOWNLOAD_TOKEN }}
PCC_USER_CCQA3: ${{ secrets.PCC_USER_CCQA3 }}
# Upload artifacts - skip for fork PRs (no secret access) and dependabot
upload:
needs: [detect-changes, archive, package]
if: |
always() &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'dependabot[bot]' &&
needs.detect-changes.outputs.has-code == 'true' &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/upload.yaml
secrets:
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
# License generation - skip if no code changes
# Note: pr_changes=false means no secrets are needed (no PR will be created)
generate-licenses:
needs: detect-changes
if: needs.detect-changes.outputs.has-code == 'true'
uses: ./.github/workflows/generate-licenses.yaml
with:
pr_changes: false # No PRs on PRs, infinite loop
fail_on_forbidden: true