Skip to content

Commit 2b78404

Browse files
committed
Add test for version numbers in pom.xml
1 parent 93a2d11 commit 2b78404

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

.github/workflows/tools-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ jobs:
8888
needs: build
8989
uses: ./.github/workflows/rpminspect-test.yml
9090

91-
update-version-test:
92-
name: Update Version
93-
uses: ./.github/workflows/update-version-test.yml
91+
version-test:
92+
name: Version
93+
uses: ./.github/workflows/version-test.yml
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update Version
1+
name: Version
22

33
on:
44
workflow_call:
@@ -10,9 +10,39 @@ jobs:
1010
env:
1111
SHARED: /tmp/workdir/pki
1212
steps:
13+
- name: Install dependencies
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get -y install xmlstarlet
17+
1318
- name: Clone repository
1419
uses: actions/checkout@v7
1520

21+
- name: Get version number from RPM spec
22+
run: |
23+
MAJOR_VERSION=$(sed -n 's/^%global *major_version *\(.*\)$/\1/p' pki.spec)
24+
MINOR_VERSION=$(sed -n 's/^%global *minor_version *\(.*\)$/\1/p' pki.spec)
25+
UPDATE_VERSION=$(sed -n 's/^%global *update_version *\(.*\)$/\1/p' pki.spec)
26+
27+
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$UPDATE_VERSION
28+
echo "VERSION=$VERSION" | tee -a $GITHUB_ENV
29+
30+
- name: Check version numbers in pom.xml
31+
run: |
32+
echo -n "$VERSION-SNAPSHOT" > expected
33+
34+
for filename in $(find . -name pom.xml); do
35+
echo "Checking version number in $filename"
36+
37+
if [ "$filename" == "./pom.xml" ]; then
38+
xmlstarlet sel -t -v '/_:project/_:version' $filename > actual
39+
else
40+
xmlstarlet sel -t -v '/_:project/_:parent/_:version' $filename > actual
41+
fi
42+
43+
diff expected actual
44+
done
45+
1646
- name: Setup git
1747
run: |
1848
sudo apt-get update

0 commit comments

Comments
 (0)