Skip to content

Commit 1a65438

Browse files
PVQ-3923 External action - add simple test to all
- added build step that test built JAR file with help and external action to verify JAR is working as expected
1 parent c85b974 commit 1a65438

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

.github/workflows/maven-release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
${{ runner.os }}-maven-
3333
3434
- name: Set env variables
35-
run: echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV
35+
run: echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV
3636

3737
- name: Download and unzip SDK JAR file
3838
run: |
@@ -52,6 +52,9 @@ jobs:
5252
mvn package
5353
# run: mvn clean install -DskipTests
5454

55+
- name: Run tests
56+
run: chmod +x test.sh && ./test.sh
57+
5558
- name: Prepare files for release
5659
id: prepare-for-release
5760
run: |

test.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# This is local jar test during build and push action.
4+
5+
# Colors for output into console
6+
GREEN='\033[0;32m'
7+
RED='\033[0;31m'
8+
PURPLE='\033[0;35m'
9+
NC='\033[0m' # No Color
10+
11+
# Function to print info messages
12+
info() { echo -e "${PURPLE}$1${NC}"; }
13+
14+
# Function to print success messages
15+
success() { echo -e "${GREEN}$1${NC}"; }
16+
17+
# Function to print error messages
18+
error() { echo -e "${RED}ERROR: $1${NC}"; }
19+
20+
# init
21+
pushd "$(dirname $0)" > /dev/null
22+
23+
EXIT_STATUS=0
24+
25+
info "List files in target directory"
26+
ls -l $(pwd)/target
27+
28+
info "Test #01: Show help"
29+
java -jar target/net.pdfix.validate-pdf-*.jar --help > /dev/null
30+
if [ $? -eq 0 ]; then
31+
success "passed"
32+
else
33+
error "Failed to run \"--help\" command"
34+
EXIT_STATUS=1
35+
fi
36+
37+
info "Test #02: Run validate MCID"
38+
OUTPUT=$(java -jar target/net.pdfix.validate-pdf-*.jar duplicate-mcid -i resources/test.pdf)
39+
COUNT=$(echo "$OUTPUT" | grep -c "Duplicate MCID Found")
40+
info "$OUTPUT"
41+
if [ "$COUNT" -eq 5 ]; then
42+
success "passed"
43+
else
44+
error "Validate MCID failed on resources/test.pdf. Expected 5 duplicate MCIDs, found $COUNT."
45+
EXIT_STATUS=1
46+
fi
47+
48+
popd > /dev/null
49+
50+
if [ $EXIT_STATUS -eq 1 ]; then
51+
error "One or more tests failed."
52+
exit 1
53+
else
54+
success "All tests passed."
55+
exit 0
56+
fi

update_version.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ version_short="${1#v}"
2929
echo "Version: $1"
3030
echo "Short version: ${version_short}"
3131

32+
# Update the version in pom.xml
3233
mvn versions:set -DnewVersion=${version_short}
3334

3435
# Replace "v0.0.0" placeholder with the provided argument in config.json

0 commit comments

Comments
 (0)