-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Github Actions and Checkstyle (#1)
Signed-off-by: Laird Nelson <[email protected]>
- Loading branch information
Showing
4 changed files
with
292 additions
and
3 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @ljnelson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
name: 'Workflow: Maven Release: Prepare and Perform' | ||
run-name: 'Workflow Run: Maven Release: Prepare and Perform' | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
dryRun: | ||
default: true | ||
description: 'Dry run?' | ||
type: 'boolean' | ||
mvnDebug: | ||
default: false | ||
description: 'Debug?' | ||
type: 'boolean' | ||
mvnTransferLogging: | ||
default: false | ||
description: 'Log Maven artifact transfers?' | ||
type: 'boolean' | ||
jobs: | ||
job-mvn-release-prepare-perform: | ||
name: 'Job: Maven Release: Prepare and Perform' | ||
permissions: | ||
contents: 'read' | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- id: 'checkout' | ||
name: 'Step: Check Out Project' | ||
uses: 'actions/checkout@v4' | ||
with: | ||
fetch-depth: 1 | ||
persist-credentials: false | ||
- id: 'setup-java' | ||
name: 'Step: Set Up Java and Maven' | ||
uses: 'actions/setup-java@v3' | ||
with: | ||
cache: 'maven' | ||
distribution: 'temurin' | ||
gpg-passphrase: 'GPG_PASSPHRASE' | ||
gpg-private-key: '${{ secrets.GPG_PRIVATE_KEY }}' | ||
java-version: '17' | ||
mvn-toolchain-id: 'Temurin 17' | ||
mvn-toolchain-vendor: 'openjdk' # see ../../pom.xml | ||
server-id: 'sonatype-oss-repository-hosting' # see https://github.com/microbean/microbean-parent/blob/master/pom.xml#L38 | ||
server-password: 'SONATYPE_OSSRH_PASSWORD' | ||
server-username: 'SONATYPE_OSSRH_USERNAME' | ||
- id: 'setup-askpass' | ||
name: 'Step: Set Up GIT_ASKPASS' | ||
run: | | ||
install -m 700 /dev/null "${RUNNER_TEMP}/.askpass" # atomically create empty file with appropriate permissions | ||
cat >> "${RUNNER_TEMP}/.askpass" <<<'#!/bin/bash | ||
case "${1}" in | ||
Username*) exec echo x-access-token ;; | ||
Password*) exec echo "${PUSH_TOKEN}" ;; | ||
esac' | ||
- id: 'setup-gpg' | ||
name: 'Step: Set Up GPG' | ||
run: | | ||
echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf | ||
- id: 'mvn-release-prepare' | ||
name: 'Step: Maven Release: Prepare, Perform and Publish Site' | ||
env: | ||
DRY_RUN: '${{ inputs.dryRun }}' | ||
GIT_ASKPASS: '${{ runner.temp }}/.askpass' | ||
GPG_PASSPHRASE: '${{ secrets.GPG_PASSPHRASE }}' | ||
MVN_DEBUG: ${{ inputs.mvnDebug && '--debug' || '' }} | ||
MVN_TRANSFER_LOGGING: ${{ inputs.mvnTransferLogging && '' || '--no-transfer-progress' }} | ||
PUSH_TOKEN : '${{ secrets.PUSH_TOKEN }}' # critical; see ${GIT_ASKPASS} file | ||
SCM_GIT_HTTPS_URL: 'scm:git:${{ github.server_url }}/${{ github.repository }}.git' | ||
SONATYPE_OSSRH_PASSWORD: '${{ secrets.SONATYPE_OSSRH_PASSWORD }}' | ||
SONATYPE_OSSRH_STAGING_PROFILE_ID: '${{ vars.SONATYPE_OSSRH_STAGING_PROFILE_ID }}' | ||
SONATYPE_OSSRH_USERNAME: '${{ secrets.SONATYPE_OSSRH_USERNAME }}' | ||
shell: 'bash -e {0}' | ||
run: > | ||
git config --global user.email '[email protected]' | ||
git config --global user.name 'microbean' | ||
echo "::group::Running mvn prepare" | ||
mvn --batch-mode ${MVN_DEBUG} --errors ${MVN_TRANSFER_LOGGING} release:prepare | ||
-DdryRun="${DRY_RUN}" | ||
-Darguments="${MVN_TRANSFER_LOGGING}" | ||
-Dscm.url="${SCM_GIT_HTTPS_URL}" | ||
scm_tag="$(grep '^scm.tag=' release.properties | cut -f 2 -d =)" | ||
echo "Prepared ${scm_tag}" >> "${GITHUB_STEP_SUMMARY}" | ||
echo "scm_tag=${scm_tag}" >> "${GITHUB_OUTPUT}" | ||
echo "::endgroup::" | ||
echo "::group::Running mvn perform" | ||
set +e | ||
{ | ||
mvn --batch-mode ${MVN_DEBUG} --errors ${MVN_TRANSFER_LOGGING} release:perform | ||
-Darguments="${MVN_TRANSFER_LOGGING} -Dscmpublish.dryRun=${DRY_RUN} -Dscmpublish.pubScmUrl=${SCM_GIT_HTTPS_URL} -DskipTests -DstagingProfileId=${SONATYPE_OSSRH_STAGING_PROFILE_ID}" | ||
-DdryRun="${DRY_RUN}" | ||
-Dgoals="verify,post-site,scm-publish:publish-scm,deploy" | ||
-Dscm.url="${SCM_GIT_HTTPS_URL}" | ||
| | ||
tee /dev/fd/3 | ||
| | ||
grep --invert-match --silent 'Java class com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO' || cat > /dev/null | ||
; | ||
} | ||
3>&1 | ||
exit_codes=(${PIPESTATUS[@]}) | ||
echo "::endgroup::" | ||
set -e | ||
if [ "${exit_codes[2]}" -ne 0 ] ; then | ||
# grep "failed" (found com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO) and mvn failed | ||
echo "Released ${scm_tag} successfully, but verify that the staging repository was successfully released" >> "${GITHUB_STEP_SUMMARY}"; | ||
# Treat this as a successful run | ||
exit 0; | ||
elif [ "${exit_codes[0]}" -eq 0 ] ; then | ||
# mvn succeeded and grep "succeeded" (did not find com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO) | ||
echo "Released ${scm_tag} successfully" >> "${GITHUB_STEP_SUMMARY}"; | ||
fi | ||
exit "${exit_codes[0]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: 'Workflow: Maven Verify' | ||
run-name: 'Workflow Run: Maven Verify' | ||
on: | ||
- 'pull_request' | ||
- 'push' | ||
jobs: | ||
job-mvn-verify: | ||
name: 'Job: Maven Verify' | ||
permissions: | ||
contents: 'read' | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- id: 'checkout' | ||
name: 'Step: Checkout' | ||
uses: 'actions/checkout@v4' | ||
with: | ||
fetch-depth: 1 | ||
persist-credentials: false | ||
- id: 'setup-java' | ||
name: 'Step: Set Up Java and Maven' | ||
uses: 'actions/setup-java@v3' | ||
with: | ||
cache: 'maven' | ||
distribution: 'temurin' | ||
java-version: '17' | ||
mvn-toolchain-id: 'Temurin 17' | ||
mvn-toolchain-vendor: 'openjdk' # see ../../pom.xml | ||
- id: 'mvn-verify' | ||
name: 'Step: Maven Verify' | ||
run: 'mvn --batch-mode --color never --errors --no-transfer-progress -Dorg.slf4j.simpleLogger.defaultLogLevel=info verify' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,25 @@ | |
<url>https://microbean.github.io/microbean-scope</url> | ||
|
||
<scm> | ||
<connection>scm:git:[email protected]:microbean/microbean-scope.git</connection> | ||
<developerConnection>scm:git:[email protected]:microbean/microbean-scope.git</developerConnection> | ||
<connection>${scm.url}</connection> | ||
<developerConnection>${scm.url}</developerConnection> | ||
<url>https://github.com/microbean/microbean-scope/</url> | ||
<tag>HEAD</tag> | ||
</scm> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>sonatype-oss-repository-hosting</id> | ||
<!-- See https://central.sonatype.org/publish/publish-maven/#distribution-management-and-authentication --> | ||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> | ||
</repository> | ||
<site> | ||
<id>Github Pages</id> | ||
<name>microBean™ Function Site</name> | ||
<url>https://microbean.github.io/microbean-scope/</url> | ||
</site> | ||
</distributionManagement> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
|
||
|
@@ -35,7 +48,7 @@ | |
<dependency> | ||
<groupId>org.microbean</groupId> | ||
<artifactId>microbean-qualifier</artifactId> | ||
<version>0.2.3</version> | ||
<version>0.2.4</version> | ||
<type>jar</type> | ||
</dependency> | ||
|
||
|
@@ -81,6 +94,112 @@ | |
<pluginManagement> | ||
<plugins> | ||
|
||
<plugin> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<configuration> | ||
<checkstyleRules> | ||
<module name="Checker"> | ||
<module name="BeforeExecutionExclusionFileFilter"> | ||
<property name="fileNamePattern" value="module\-info\.java$" /> | ||
</module> | ||
<module name="FileTabCharacter"> | ||
<property name="eachLine" value="true" /> | ||
</module> | ||
<module name="JavadocPackage" /> | ||
<module name="LineLength"> | ||
<property name="max" value="160" /> | ||
</module> | ||
<module name="NewlineAtEndOfFile"> | ||
<property name="lineSeparator" value="lf" /> | ||
</module> | ||
<module name="TreeWalker"> | ||
<module name="AnnotationLocation"> | ||
<property name="allowSamelineSingleParameterlessAnnotation" value="false" /> | ||
</module> | ||
<module name="AnnotationUseStyle" /> | ||
<module name="ArrayTypeStyle" /> | ||
<module name="AvoidNestedBlocks" /> | ||
<module name="AvoidStarImport" /> | ||
<module name="ClassMemberImpliedModifier" /> | ||
<module name="CommentsIndentation" /> | ||
<module name="DeclarationOrder" /> | ||
<module name="DefaultComesLast" /> | ||
<module name="EmptyBlock" /> | ||
<module name="EmptyCatchBlock" /> | ||
<module name="EmptyStatement" /> | ||
<module name="EqualsHashCode" /> | ||
<module name="ExplicitInitialization" /> | ||
<module name="FinalClass" /> | ||
<module name="FinalLocalVariable"> | ||
<property name="tokens" value="VARIABLE_DEF,PARAMETER_DEF" /> | ||
</module> | ||
<module name="HideUtilityClassConstructor" /> | ||
<module name="InnerAssignment" /> | ||
<module name="InnerTypeLast" /> | ||
<module name="InterfaceIsType" /> | ||
<module name="InterfaceMemberImpliedModifier"> | ||
<property name="violateImpliedAbstractMethod" value="false" /> | ||
</module> | ||
<module name="InvalidJavadocPosition" /> | ||
<module name="JavadocContentLocationCheck" /> | ||
<module name="JavadocMissingWhitespaceAfterAsterisk" /> | ||
<module name="JavadocParagraph" /> | ||
<module name="JavadocStyle" /> | ||
<module name="JavadocVariable"> | ||
<property name="scope" value="protected" /> | ||
</module> | ||
<module name="LeftCurly" /> | ||
<module name="MethodTypeParameterName" /> | ||
<module name="MissingCtor" /> | ||
<module name="MissingDeprecated" /> | ||
<module name="MissingJavadocMethod" /> | ||
<module name="MissingJavadocPackage" /> | ||
<module name="MissingJavadocType"> | ||
<property name="scope" value="protected" /> | ||
</module> | ||
<module name="MissingOverride" /> | ||
<module name="MultipleVariableDeclarations" /> | ||
<module name="ModifierOrder" /> | ||
<module name="NeedBraces" /> | ||
<module name="NoArrayTrailingComma" /> | ||
<module name="NoFinalizer" /> | ||
<module name="NonEmptyAtclauseDescription" /> | ||
<module name="OneStatementPerLine" /> | ||
<module name="OneTopLevelClass" /> | ||
<module name="OuterTypeFilename" /> | ||
<module name="OverloadMethodsDeclarationOrder" /> | ||
<module name="PackageDeclaration" /> | ||
<module name="RedundantImport" /> | ||
<module name="RegexpSinglelineJava"> | ||
<property name="format" value="\s+$" /> | ||
<property name="message" value="File contains trailing whitespace." /> | ||
</module> | ||
<module name="RequireEmptyLineBeforeBlockTagGroup" /> | ||
<module name="RequireThis" /> | ||
<module name="RightCurly" /> | ||
<module name="SummaryJavadocCheck" /> | ||
<module name="SuppressWarningsHolder" /> | ||
<module name="UnnecessarySemicolonAfterOuterTypeDeclaration" /> | ||
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration" /> | ||
<module name="UnnecessarySemicolonInEnumeration" /> | ||
<module name="UnnecessarySemicolonInTryWithResources" /> | ||
<module name="UnusedImports" /> | ||
<module name="UnusedLocalVariable" /> | ||
<module name="UpperEll" /> | ||
<module name="VariableDeclarationUsageDistance" /> | ||
</module> | ||
<property name="charset" value="${project.build.sourceEncoding}" /> | ||
<property name="tabWidth" value="2" /> | ||
</module> | ||
</checkstyleRules> | ||
<propertyExpansion> | ||
project.basedir=${project.basedir} | ||
project.build.sourceEncoding=${project.build.sourceEncoding} | ||
</propertyExpansion> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<configuration> | ||
|
@@ -91,6 +210,7 @@ | |
<docfilessubdirs>true</docfilessubdirs> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
|
@@ -130,6 +250,8 @@ | |
<!-- maven-release-plugin properties; see http://maven.apache.org/maven-release/maven-release-plugin/ --> | ||
<goals>deploy,post-site,scm-publish:publish-scm</goals> | ||
|
||
<scm.url>scm:git:[email protected]:microbean/microbean-scope.git</scm.url> | ||
|
||
<!-- maven-scm-publish-plugin properties; | ||
see https://maven.apache.org/plugins/maven-scm-publish-plugin/publish-scm-mojo.html --> | ||
<scmpublish.content>${project.reporting.outputDirectory}</scmpublish.content> | ||
|
@@ -140,6 +262,16 @@ | |
|
||
<reporting> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
<reportSets> | ||
<reportSet> | ||
<reports> | ||
<report>checkstyle</report> | ||
</reports> | ||
</reportSet> | ||
</reportSets> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<reportSets> | ||
|