Skip to content

Commit 9634e80

Browse files
committed
Add test for version numbers in pom.xml
The tools tests have been updated to ensure that the version numbers in pom.xml match the version number in RPM spec.
1 parent e8fc572 commit 9634e80

3 files changed

Lines changed: 96 additions & 54 deletions

File tree

.github/workflows/tools-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ jobs:
7373
needs: build
7474
uses: ./.github/workflows/rpminspect-test.yml
7575

76-
update-version-test:
77-
name: Update Version
78-
uses: ./.github/workflows/update-version-test.yml
76+
version-number-test:
77+
name: Version number
78+
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: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 git
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+
git config --global user.name "Dr. John Doe"
54+
git config --global user.email jdoe@example.com
55+
56+
- name: Update to version with a phase
57+
run: |
58+
NEXT_MAJOR_VERSION=$((MAJOR_VERSION + 1))
59+
60+
./update_version.sh $NEXT_MAJOR_VERSION 0 0 beta1
61+
62+
git show
63+
64+
git tag --points-at HEAD > actual
65+
echo v$NEXT_MAJOR_VERSION.0.0-beta1 > expected
66+
67+
diff expected actual
68+
69+
- name: Update to version without a phase
70+
run: |
71+
NEXT_MAJOR_VERSION=$((MAJOR_VERSION + 1))
72+
73+
./update_version.sh $NEXT_MAJOR_VERSION 0 0
74+
75+
git show
76+
77+
git tag --points-at HEAD > actual
78+
echo v$NEXT_MAJOR_VERSION.0.0 > expected
79+
80+
diff expected actual
81+
82+
- name: Update to version with a phase again
83+
run: |
84+
NEXT_MAJOR_VERSION=$((MAJOR_VERSION + 1))
85+
86+
./update_version.sh $NEXT_MAJOR_VERSION 1 0 alpha1
87+
88+
git show
89+
90+
git tag --points-at HEAD > actual
91+
echo v$NEXT_MAJOR_VERSION.1.0-alpha1 > expected
92+
93+
diff expected actual

0 commit comments

Comments
 (0)