Skip to content

Commit 6fa99d1

Browse files
committed
Move configuration around
- more convenient changes - root BUILD is tied to individual image config - add check to see if any diffs in build config occur (tag:rule) Signed-off-by: Appu Goundan <[email protected]>
1 parent 40f9b1e commit 6fa99d1

File tree

30 files changed

+488
-347
lines changed

30 files changed

+488
-347
lines changed

.github/workflows/config-diff.yaml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Config Check
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: ["main"]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
pull-requests: write
14+
15+
jobs:
16+
diff:
17+
runs-on: distroless-ci-large-ubuntu-22.04
18+
steps:
19+
- name: Set up Go
20+
uses: actions/setup-go@v6
21+
with:
22+
go-version: "1.25"
23+
- uses: actions/cache@v4
24+
with:
25+
path: |
26+
~/.cache/bazel-repo
27+
key: bazel-cache-deps-ci2-${{ github.sha }}
28+
restore-keys: |
29+
bazel-cache-deps-ci2-${{ github.sha }}
30+
bazel-cache-deps-ci2-
31+
32+
- name: Checkout PR Branch
33+
uses: actions/checkout@v5
34+
with:
35+
ref: ${{ github.event.pull_request.head.sha }}
36+
path: pr_branch
37+
38+
- name: Build :sign_and_push.query for PR
39+
run: |
40+
cd pr_branch
41+
bazel build :sign_and_push.query
42+
cp bazel-bin/sign_and_push_query ../pr_query_output.txt
43+
cd ..
44+
45+
- name: Checkout main Branch
46+
uses: actions/checkout@v5
47+
with:
48+
ref: main
49+
path: main_branch
50+
51+
- name: Build :sign_and_push.query for main
52+
run: |
53+
cd main_branch
54+
bazel build :sign_and_push.query
55+
cp bazel-bin/sign_and_push_query ../main_query_output.txt
56+
cd ..
57+
58+
- name: Diff the query outputs
59+
id: diff
60+
run: |
61+
# diff may exit with non-zero
62+
DIFF_OUTPUT=$(diff -u main_query_output.txt pr_query_output.txt) || true
63+
64+
if [ -z "$DIFF_OUTPUT" ]; then
65+
echo "HAS_DIFF=false" >> $GITHUB_ENV
66+
else
67+
echo "HAS_DIFF=true" >> $GITHUB_ENV
68+
echo "$DIFF_OUTPUT" > diff_output.txt
69+
echo "changed_build<<EOF" >> $GITHUB_OUTPUT
70+
echo "$DIFF_OUTPUT" >> $GITHUB_OUTPUT
71+
echo "EOF" >> $GITHUB_OUTPUT
72+
fi
73+
74+
- uses: actions/upload-artifact@v5
75+
id: report
76+
with:
77+
name: "Report"
78+
path: ./diff_output.txt
79+
80+
- uses: peter-evans/find-comment@v4
81+
id: fc
82+
if: ${{ !github.event.pull_request.head.repo.fork }}
83+
with:
84+
issue-number: ${{ github.event.pull_request.number }}
85+
comment-author: "github-actions[bot]"
86+
body-includes: 🌳 🔧 Config Check
87+
88+
- name: Report diff
89+
if: ${{ !github.event.pull_request.head.repo.fork && env.HAS_DIFF }}
90+
uses: peter-evans/create-or-update-comment@v5
91+
with:
92+
comment-id: ${{ steps.fc.outputs.comment-id }}
93+
issue-number: ${{ github.event.pull_request.number }}
94+
body: |
95+
🌳 🔧 Config Check
96+
97+
This pull request has modified the root BUILD
98+
99+
```diff
100+
${{steps.diff.outputs.changed_build}}
101+
```
102+
103+
You can check the details in the report [here](${{steps.report.outputs.artifact-url}})
104+
edit-mode: replace
105+
106+
- name: Report no diff
107+
if: ${{ !github.event.pull_request.head.repo.fork && !steps.diff.outputs.changed_targets }}
108+
uses: peter-evans/create-or-update-comment@v5
109+
with:
110+
comment-id: ${{ steps.fc.outputs.comment-id }}
111+
issue-number: ${{ github.event.pull_request.number }}
112+
body: |
113+
🌳 🔧 Config Check
114+
115+
This pull request has not modified the root BUILD
116+
edit-mode: replace

0 commit comments

Comments
 (0)