Skip to content

Commit 41f4ba1

Browse files
CBL-Mariner-Botrikenm1jslobodzian
authored
[AUTO-CHERRYPICK] Add PR package update check to fasttrack/2.0 - branch main (#14063)
Co-authored-by: Riken Maharjan <[email protected]> Co-authored-by: jslobodzian <[email protected]>
1 parent eec6850 commit 41f4ba1

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
name: Check Package Update Gate
5+
6+
on:
7+
push:
8+
branches: [main, 2.0*, 3.0*, fasttrack/*]
9+
pull_request:
10+
branches: [main, 2.0*, 3.0*, fasttrack/*]
11+
12+
jobs:
13+
14+
build:
15+
name: Check Package Update Gate
16+
runs-on: ubuntu-latest
17+
steps:
18+
19+
- name: Check out code
20+
uses: actions/checkout@v4
21+
22+
- name: Get base commit for PRs
23+
if: ${{ github.event_name == 'pull_request' }}
24+
run: |
25+
git fetch origin ${{ github.base_ref }}
26+
echo "base_sha=$(git rev-parse origin/${{ github.base_ref }})" >> $GITHUB_ENV
27+
echo "Merging ${{ github.sha }} into ${{ github.base_ref }}"
28+
29+
- name: Get base commit for Pushes
30+
if: ${{ github.event_name == 'push' }}
31+
run: |
32+
git fetch origin ${{ github.event.before }}
33+
echo "base_sha=${{ github.event.before }}" >> $GITHUB_ENV
34+
echo "Merging ${{ github.sha }} into ${{ github.event.before }}"
35+
36+
- name: Get the changed files
37+
run: |
38+
echo "Files changed: '$(git diff-tree --no-commit-id --name-only -r ${{ env.base_sha }} ${{ github.sha }})'"
39+
changed_specs=$(git diff-tree --diff-filter=d --no-commit-id --name-only -r ${{ env.base_sha }} ${{ github.sha }} | { grep "SPECS.*/.*\.spec$" || test $? = 1; })
40+
echo "Files to validate: '${changed_specs}'"
41+
echo "updated-specs=$(echo ${changed_specs})" >> $GITHUB_ENV
42+
43+
- name: Check each spec
44+
run: |
45+
46+
if [[ -z "${{ env.updated-specs }}" ]]; then
47+
echo "No spec files to validate. Exiting."
48+
exit 0
49+
fi
50+
51+
for spec in ${{ env.updated-specs }}
52+
do
53+
echo "Checking '$spec'."
54+
# Expand macros if present
55+
name=$(rpmspec --parse "$spec" | grep -E "^Name:\s*(.*)" | awk '{print $2}')
56+
version=$(rpmspec --parse "$spec" | grep -E "^Version:\s*(.*)" | awk '{print $2}')
57+
58+
# Read from packagelist-gate.csv and iterate each row
59+
# 1st column: package name
60+
# 2nd column: condition (>=, =,'')
61+
# 3rd column: version number
62+
63+
while IFS=, read -r package_name condition version_number; do
64+
if [[ "$name" == "$package_name" ]]; then
65+
case "$condition" in
66+
">=" | "=" )
67+
if [[ ("$condition" == ">=" && "$(printf '%s\n' "$version" "$version_number" | sort -V | head -n1)" == "$version_number") ||
68+
("$condition" == "=" && "$version" == "$version_number") ]]; then
69+
1>&2 echo "**** ERROR ****"
70+
1>&2 echo "Spec '$spec' version '$version' is not allowed in Azure Linux. Error:'$spec $condition $version_number'."
71+
1>&2 echo "**** ERROR ****"
72+
error_found=1
73+
fi
74+
;;
75+
*)
76+
1>&2 echo "**** ERROR ****"
77+
1>&2 echo "Spec $spec is not allowed in Azure Linux"
78+
1>&2 echo "**** ERROR ****"
79+
error_found=1
80+
;;
81+
esac
82+
fi
83+
done < .github/workflows/packagelist-gate.csv
84+
done
85+
86+
if [[ -n $error_found ]]
87+
then
88+
exit 1
89+
fi
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fdk-aac-free,,
2+
opus,,
3+
opus-file,,
4+
packer,>=,1.10.0
5+
redis,>=,7.4
6+
terraform,>=,1.6.0

0 commit comments

Comments
 (0)