forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (145 loc) · 5.1 KB
/
sync-release.yml
File metadata and controls
165 lines (145 loc) · 5.1 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
165
name: Sync release/10.0 → bazel
on:
schedule:
- cron: '0 6 * * *' # Daily at 6:00 UTC
workflow_dispatch:
inputs:
skip_copilot_fix:
description: 'Skip Copilot SDK auto-fix job'
type: boolean
default: false
skip_equivalence:
description: 'Skip equivalence check'
type: boolean
default: false
permissions:
contents: write
pull-requests: write
jobs:
sync:
name: Sync Upstream
runs-on: ubuntu-latest
outputs:
has_new_commits: ${{ steps.run-sync.outputs.has_new_commits }}
sync_branch: ${{ steps.run-sync.outputs.sync_branch }}
classification: ${{ steps.run-sync.outputs.classification }}
pr_number: ${{ steps.run-sync.outputs.pr_number }}
steps:
- name: Checkout bazel branch
uses: actions/checkout@v5
with:
ref: bazel
fetch-depth: 0
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Mount Bazel cache
uses: actions/cache@v4
with:
path: ~/.cache/bazel-disk
key: bazel-sync-${{ hashFiles('MODULE.bazel', '.bazelrc') }}-${{ github.sha }}
restore-keys: |
bazel-sync-${{ hashFiles('MODULE.bazel', '.bazelrc') }}-
bazel-sync-
- name: Install Paket
run: dotnet tool install -g paket --add-source https://api.nuget.org/v3/index.json
- name: Run sync
id: run-sync
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
chmod +x src/tools/bazel/sync-upstream.sh src/tools/bazel/detect-upstream-changes.sh &&
src/tools/bazel/sync-upstream.sh
--repo "${{ github.repository }}"
--output-file "$GITHUB_OUTPUT"
copilot-fix:
name: Copilot Auto-Fix
needs: sync
if: >-
needs.sync.result == 'success' &&
needs.sync.outputs.has_new_commits == 'true' &&
(needs.sync.outputs.classification == 'build-changes' || needs.sync.outputs.classification == 'conflict') &&
github.event.inputs.skip_copilot_fix != 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout sync branch
uses: actions/checkout@v5
with:
ref: ${{ needs.sync.outputs.sync_branch }}
fetch-depth: 0
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Install Copilot CLI
run: npm install -g @github/copilot
- name: Run change detection
run: >-
chmod +x src/tools/bazel/detect-upstream-changes.sh &&
src/tools/bazel/detect-upstream-changes.sh origin/bazel HEAD
--report-file /tmp/sync-report.md || true
- name: Run Copilot auto-fix
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
run: |
if [[ ! -f /tmp/sync-report.md ]]; then
echo "No report file — skipping auto-fix."
exit 0
fi
cd src/tools/bazel
if dotnet run CopilotFixSync.cs -- /tmp/sync-report.md; then
cd "$GITHUB_WORKSPACE"
if ! git diff --quiet; then
echo "Copilot produced changes:"
git diff --stat
git add -A
git commit -m "Auto-fix BUILD.bazel files for upstream sync
Applied by Copilot SDK based on detection report.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>"
git push
else
echo "Copilot produced no changes."
fi
else
echo "::warning::CopilotFixSync.cs failed."
fi
equivalence-check:
name: Equivalence Check
needs: sync
if: needs.sync.result == 'success' && github.event.inputs.skip_equivalence != 'true'
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- name: Checkout bazel branch
uses: actions/checkout@v5
with:
ref: bazel
fetch-depth: 0
- name: Install dependencies
run: sudo apt-get update -qq && sudo apt-get install -qq -y clang-18 lld libkrb5-dev liblttng-ust-dev
- name: Mount Bazel cache
uses: actions/cache@v4
with:
path: ~/.cache/bazel-disk
key: bazel-equiv-${{ hashFiles('MODULE.bazel', '.bazelrc') }}-${{ github.sha }}
restore-keys: |
bazel-equiv-${{ hashFiles('MODULE.bazel', '.bazelrc') }}-
bazel-equiv-
- name: Run equivalence check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
chmod +x src/tools/bazel/equivalence-check.sh &&
src/tools/bazel/equivalence-check.sh
--repo "${{ github.repository }}"
--bazel-disk-cache ~/.cache/bazel-disk