Skip to content

Commit fa57a96

Browse files
committed
Add test for version numbers in pom.xml
The tools tests have been updated to validate that the version numbers in pom.xml match the version number in RPM spec.
1 parent 93a2d11 commit fa57a96

3 files changed

Lines changed: 99 additions & 54 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-number-test:
92+
name: Version number
93+
uses: ./.github/workflows/version-number-test.yml

.github/workflows/update-version-test.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Version number
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
name: Test
9+
runs-on: ubuntu-latest
10+
env:
11+
SHARED: /tmp/workdir/pki
12+
steps:
13+
- name: Install dependencies
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get -y install xmlstarlet
17+
18+
- name: Clone repository
19+
uses: actions/checkout@v7
20+
21+
- name: Get version number from RPM spec
22+
run: |
23+
MAJOR_VERSION=$(sed -n 's/^%global *major_version *\(.*\)$/\1/p' pki.spec)
24+
echo "MAJOR_VERSION=$MAJOR_VERSION" | tee -a $GITHUB_ENV
25+
26+
MINOR_VERSION=$(sed -n 's/^%global *minor_version *\(.*\)$/\1/p' pki.spec)
27+
echo "MINOR_VERSION=$MINOR_VERSION" | tee -a $GITHUB_ENV
28+
29+
UPDATE_VERSION=$(sed -n 's/^%global *update_version *\(.*\)$/\1/p' pki.spec)
30+
echo "UPDATE_VERSION=$UPDATE_VERSION" | tee -a $GITHUB_ENV
31+
32+
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$UPDATE_VERSION
33+
echo "VERSION=$VERSION" | tee -a $GITHUB_ENV
34+
35+
- name: Check version numbers in pom.xml
36+
run: |
37+
echo -n "$VERSION-SNAPSHOT" > expected
38+
39+
for filename in $(find . -name pom.xml); do
40+
echo "Checking version number in $filename"
41+
42+
if [ "$filename" == "./pom.xml" ]; then
43+
xmlstarlet sel -t -v '/_:project/_:version' $filename > actual
44+
else
45+
xmlstarlet sel -t -v '/_:project/_:parent/_:version' $filename > actual
46+
fi
47+
48+
diff expected actual
49+
done
50+
51+
- name: Setup git
52+
run: |
53+
sudo apt-get update
54+
sudo apt-get -y install git
55+
56+
git config --global user.name "Dr. John Doe"
57+
git config --global user.email jdoe@example.com
58+
59+
- name: Update to version with a phase
60+
run: |
61+
NEXT_MAJOR_VERSION=$((MAJOR_VERSION + 1))
62+
63+
./update_version.sh $NEXT_MAJOR_VERSION 0 0 beta1
64+
65+
git show
66+
67+
git tag --points-at HEAD > actual
68+
echo v$NEXT_MAJOR_VERSION.0.0-beta1 > expected
69+
70+
diff expected actual
71+
72+
- name: Update to version without a phase
73+
run: |
74+
NEXT_MAJOR_VERSION=$((MAJOR_VERSION + 1))
75+
76+
./update_version.sh $NEXT_MAJOR_VERSION 0 0
77+
78+
git show
79+
80+
git tag --points-at HEAD > actual
81+
echo v$NEXT_MAJOR_VERSION.0.0 > expected
82+
83+
diff expected actual
84+
85+
- name: Update to version with a phase again
86+
run: |
87+
NEXT_MAJOR_VERSION=$((MAJOR_VERSION + 1))
88+
89+
./update_version.sh $NEXT_MAJOR_VERSION 1 0 alpha1
90+
91+
git show
92+
93+
git tag --points-at HEAD > actual
94+
echo v$NEXT_MAJOR_VERSION.1.0-alpha1 > expected
95+
96+
diff expected actual

0 commit comments

Comments
 (0)