Skip to content

Commit a00fba1

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

3 files changed

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

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

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/version-test.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Version
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+
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+
46+
- name: Setup git
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get -y install git
50+
51+
git config --global user.name "Dr. John Doe"
52+
git config --global user.email jdoe@example.com
53+
54+
- name: Update to version with a phase
55+
run: |
56+
./update_version.sh 12 1 0 beta1
57+
58+
git show
59+
git tag --points-at HEAD > actual
60+
echo v12.1.0-beta1 > expected
61+
diff expected actual
62+
63+
- name: Update to version without a phase
64+
run: |
65+
./update_version.sh 12 1 0
66+
67+
git show
68+
git tag --points-at HEAD > actual
69+
echo v12.1.0 > expected
70+
71+
diff expected actual
72+
73+
- name: Update to version with a phase again
74+
run: |
75+
./update_version.sh 12 2 0 alpha1
76+
77+
git show
78+
git tag --points-at HEAD > actual
79+
echo v12.2.0-alpha1 > expected
80+
81+
diff expected actual

0 commit comments

Comments
 (0)