-
Notifications
You must be signed in to change notification settings - Fork 30
69 lines (57 loc) · 2.07 KB
/
check-api-changes.yaml
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
name: "Check for changes in Controller APIs"
on:
pull_request:
branches: [ "api-changes-pipeline-test" ]
types:
- "opened"
- "reopened"
- "synchronize"
- "labeled"
- "unlabeled"
jobs:
check-api-diff:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'confirm/api-changes') }}
name: Check API diff
runs-on: ubuntu-latest
steps:
- name: Checkout PR ref of lifecycle-manager
uses: actions/checkout@v4
- name: Copy PR CRDs to temp dir
run: mkdir -p /tmp/pr-crds && cp ./config/crd/bases/* /tmp/pr-crds/
- name: Checkout main of lifecycle-manager
uses: actions/checkout@v4
with:
ref: main
- name: Copy main CRDs to temp dir
run: mkdir -p /tmp/main-branch-crds && cp ./config/crd/bases/* /tmp/main-branch-crds/
- name: Compare Number of CRD files
working-directory: /tmp
run: |
pr_files=$(ls ./pr-crds)
main_files=$(ls ./main-branch-crds)
if [[ "$pr_files" != "$main_files" ]]; then
echo "Number of CRD files do not match"
echo "Differences between pr-crds and main-branch-crds:"
diff -r pr-crds main-branch-crds || true
exit 1
fi
echo "Number of CRD files match"
- name: Compare API versions in CRD files
working-directory: /tmp
run: |
compare_versions() {
pr_file=$1
main_file=$2
pr_versions=$(yq e '.spec.versions[].name' "$pr_file" | sort)
main_versions=$(yq e '.spec.versions[].name' "$main_file" | sort)
if [[ "$pr_versions" != "$main_versions" ]]; then
echo "API versions do not match in $pr_file"
echo "Versions in PR: $pr_versions"
echo "Versions on main: $main_versions"
exit 1
fi
}
for file in $(ls ./pr-crds); do
compare_versions "./pr-crds/$file" "./main-branch-crds/$file"
done
echo "API versions match in all CRD files"