Skip to content

Commit

Permalink
Fix CI upstream tests
Browse files Browse the repository at this point in the history
Remove unnecessary 'gem' packaging during upstream gem installation.

* Bump 'com.github.jruby-gradle.base' to v2.0.1
* Bump 'gem-maven-plugin' to v2.0.1
* Remove some unnecessary test files and configurations

Fixes asciidoctor#1171
  • Loading branch information
abelsromero committed Apr 15, 2023
1 parent 0240f02 commit 7cc417e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Build Improvement::
* Run tests on Java 19 (#1563)
* Fix upstream tests forcing SNAPSHOT on Asciidoctor gem installation (#1123) (@abelsromero)
* Fix upstream build removing the explicit plugin repository (#1131)
* Fix Asciidoctor upstream CI tests (#1178) (@abelsromero)

== 2.5.4 (2022-06-30)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
id "io.sdkman.vendors" version "2.0.0"
id "signing"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id 'com.github.jruby-gradle.base' version '2.0.0'
id 'com.github.jruby-gradle.base' version '2.0.1'
id 'codenarc'
}

Expand Down
6 changes: 2 additions & 4 deletions ci/asciidoctor-gem-installer.pom
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
<groupId>rubygems</groupId>
<artifactId>asciidoctor</artifactId>
<version></version>
<packaging>gem</packaging>
<name>Asciidoctor RubyGem Installer</name>
<description>Installs the upstream Asciidoctor RubyGem to the local repository.</description>
<url>http://asciidoctor.org</url>
<url>https://asciidoctor.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -17,8 +16,7 @@
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-maven-plugin</artifactId>
<version>1.1.8</version>
<extensions>true</extensions>
<version>2.0.1</version>
</plugin>
</plugins>
</build>
Expand Down
25 changes: 0 additions & 25 deletions ci/asciidoctor-pdf-gem-installer.pom

This file was deleted.

53 changes: 53 additions & 0 deletions ci/test-asciidoctor-upstream-fix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
# This script runs the AsciidoctorJ tests against the specified ref of the Asciidoctor Ruby gem.

set -euo pipefail

# to build against a tag, set REF to a git tag name (e.g., refs/tags/v1.5.2)
REF=${1:-refs/heads/main}
if [[ $REF != refs/* ]]; then
REF=refs/heads/$REF
fi
readonly BASE_REF="${REF##*/}"
readonly GEMS_INSTALL_PATH="asciidoctorj-core/build/.gems/gems"
readonly SRC_DIR="asciidoctor-${BASE_REF#v}"
# readonly WORKING_DIR="build/maven"

rm -rf $WORKING_DIR && mkdir -p $WORKING_DIR
# pushd $WORKING_DIR

download_gem(){
}

install_gem(){
./gradlew :asciidoctorj:jrubyPrepare

wget --quiet -O "${SRC_DIR}.zip" "https://github.com/asciidoctor/asciidoctor/archive/${REF}.zip"
unzip -q "${SRC_DIR}.zip" -d "$GEMS_INSTALL_PATH"

ASCIIDOCTOR_UPSTREAM_VERSION="$(grep 'VERSION' "$GEMS_INSTALL_PATH/$SRC_DIR/lib/asciidoctor/version.rb" | sed "s/.*'\(.*\)'.*/\1/" | sed "s/[.]dev$/.dev-SNAPSHOT/")-SNAPSHOT"
mv "$GEMS_INSTALL_PATH/$SRC_DIR" "$GEMS_INSTALL_PATH/asciidoctor-$ASCIIDOCTOR_UPSTREAM_VERSION"
# DELETE previous release to ensure nothing leaks
ASCIIDOCTOR_CURRENT_VERSION=$(./gradlew :asciidoctorj:properties | grep asciidoctorGemVersion | sed "s/.*:\s*\(.*\)\s*/\1/")
rm -rf "$GEMS_INSTALL_PATH/asciidoctor-$ASCIIDOCTOR_CURRENT_VERSION"
}

install_gem

./gradlew --no-daemon -S -Pskip.signing -PasciidoctorGemVersion="$ASCIIDOCTOR_UPSTREAM_VERSION" check

cp ../../ci/asciidoctor-gem-installer.pom $SRC_DIR/pom.xml
cd $SRC_DIR
# force SNAPSHOT trailing to keep always consistency, gem-maven-plugin adds it depending on version format, breaking the build
readonly ASCIIDOCTOR_VERSION="$(grep 'VERSION' ./lib/asciidoctor/version.rb | sed "s/.*'\(.*\)'.*/\1/" | sed "s/[.]dev$/.dev-SNAPSHOT/")-SNAPSHOT"
# we don't use sed -i here for compatibility with OSX
sed "s;<version></version>;<version>$ASCIIDOCTOR_VERSION</version>;" pom.xml > pom.xml.sedtmp && \
mv -f pom.xml.sedtmp pom.xml

# we override the jruby version here with one supported by java9, additionally java9 needs some add-opens arguments that need to be ignored on older jvms
mvn install -B --no-transfer-progress -Dgemspec="asciidoctor.gemspec" -Djruby.version=9.2.17.0 -Djruby.jvmargs="-XX:+IgnoreUnrecognizedVMOptions --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED"
popd

## Test against installed gem
./gradlew --no-daemon -S -Pskip.signing -PasciidoctorGemVersion="$ASCIIDOCTOR_VERSION" -PuseMavenLocal=true check
exit $?
2 changes: 1 addition & 1 deletion ci/test-asciidoctor-upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sed "s;<version></version>;<version>$ASCIIDOCTOR_VERSION</version>;" pom.xml > p
mv -f pom.xml.sedtmp pom.xml

# we override the jruby version here with one supported by java9, additionally java9 needs some add-opens arguments that need to be ignored on older jvms
mvn install -B --no-transfer-progress -Dgemspec="asciidoctor.gemspec" -Djruby.version=9.2.17.0 -Djruby.jvmargs="-XX:+IgnoreUnrecognizedVMOptions --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED"
mvn install -B --no-transfer-progress -Dgemspec="asciidoctor.gemspec"
popd

## Test against installed gem
Expand Down

0 comments on commit 7cc417e

Please sign in to comment.