Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Jun 20, 2023
2 parents 3e95c92 + a68c0c1 commit d03ab51
Show file tree
Hide file tree
Showing 69 changed files with 1,667 additions and 987 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/java-ea-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ jobs:
cache: 'maven'

- name: Build and (headless) test with Maven
uses: GabrielBB/xvfb-action@v1
uses: smithki/xvfb-action@v1.1.2
with:
run: mvn -U -B -ntp package
28 changes: 23 additions & 5 deletions .github/workflows/java8-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
cache: 'maven'

- name: Build and (headless) test with Maven
uses: GabrielBB/xvfb-action@v1
uses: smithki/xvfb-action@v1.1.2
with:
run: mvn -U -B -ntp package

Expand Down Expand Up @@ -59,21 +59,30 @@ jobs:
cache: 'maven'

- name: Deploy snapshot with Maven if settings defined
run: test ! -f ci.settings.xml || mvn -B -ntp deploy -DskipTests=true -s ci.settings.xml -P base-deploy,snapshot-deploy,!non-deployable-modules
run: test ! -f ci.settings.xml || mvn -B -ntp deploy -DskipTests -s ci.settings.xml -P base-deploy,snapshot-deploy,!non-deployable-modules
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
SIGN_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
SIGN_KEY_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Dryrun release assets with Maven
run: mvn -B -ntp install -DskipTests=true -P full-release -Djreleaser.dry.run=true
run: mvn -B -ntp install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser -Djreleaser.dry.run
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Upload JReleaser output
if: always()
uses: actions/upload-artifact@v3
with:
name: assets-snapshot-log
path: |
out/jreleaser/trace.log
out/jreleaser/output.properties
release-job:
needs: build-and-test-job
if: startsWith(github.repository, 'nbbrd/') && startsWith(github.ref, 'refs/tags/v')
Expand All @@ -100,7 +109,7 @@ jobs:
cache: 'maven'

- name: Deploy with Maven if settings defined
run: test ! -f ci.settings.xml || mvn -B -ntp deploy -DskipTests=true -s ci.settings.xml -P base-deploy,release-deploy,!non-deployable-modules
run: test ! -f ci.settings.xml || mvn -B -ntp deploy -DskipTests -s ci.settings.xml -P base-deploy,release-deploy,!non-deployable-modules
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
Expand All @@ -110,9 +119,18 @@ jobs:
MAVEN_OPTS: "--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"

- name: Release assets with Maven
run: mvn -B -ntp install -DskipTests=true -P full-release
run: mvn -B -ntp install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Upload JReleaser output
if: always()
uses: actions/upload-artifact@v3
with:
name: assets-release-log
path: |
out/jreleaser/trace.log
out/jreleaser/output.properties
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.6.0] - 2023-06-20

This release improves extension points and also aligns features of Maven plugin and CLI.

### Added

- Add extension point for scan formatting [#119](https://github.com/nbbrd/heylogs/issues/119)
- Add scan mojo [#120](https://github.com/nbbrd/heylogs/issues/120)
- Add list command and mojo [#120](https://github.com/nbbrd/heylogs/issues/120)

### Changed

- Refactor extension points [#119](https://github.com/nbbrd/heylogs/issues/119)
- Merge old list command into extract command [#120](https://github.com/nbbrd/heylogs/issues/120)
- Improve output of errors in check mojo [#119](https://github.com/nbbrd/heylogs/issues/119)

## [0.5.0] - 2022-11-29

### Added
Expand Down Expand Up @@ -67,7 +83,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Initial release

[Unreleased]: https://github.com/nbbrd/heylogs/compare/v0.5.0...HEAD
[Unreleased]: https://github.com/nbbrd/heylogs/compare/v0.6.0...HEAD
[0.6.0]: https://github.com/nbbrd/heylogs/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/nbbrd/heylogs/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/nbbrd/heylogs/compare/v0.3.2...v0.4.0
[0.3.2]: https://github.com/nbbrd/heylogs/compare/v0.3.1...v0.3.2
Expand Down
9 changes: 7 additions & 2 deletions heylogs-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.nbbrd.heylogs</groupId>
<artifactId>heylogs-parent</artifactId>
<version>0.5.0</version>
<version>0.6.0</version>
</parent>

<artifactId>heylogs-api</artifactId>
Expand Down Expand Up @@ -50,7 +50,12 @@
<dependency>
<groupId>org.semver4j</groupId>
<artifactId>semver4j</artifactId>
<version>3.0.0</version>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>com.github.nbbrd.java-io-util</groupId>
<artifactId>java-io-base</artifactId>
<version>0.0.23</version>
</dependency>

<!-- test only -->
Expand Down
82 changes: 48 additions & 34 deletions heylogs-api/src/main/java/internal/heylogs/ExtendedRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import com.vladsch.flexmark.ast.Link;
import com.vladsch.flexmark.ast.LinkNodeBase;
import com.vladsch.flexmark.util.ast.Node;
import nbbrd.design.MightBeGenerated;
import nbbrd.design.VisibleForTesting;
import nbbrd.heylogs.Failure;
import nbbrd.heylogs.Rule;
import nbbrd.heylogs.RuleBatch;
import nbbrd.heylogs.spi.Rule;
import nbbrd.heylogs.spi.RuleBatch;
import nbbrd.io.text.Parser;
import nbbrd.service.ServiceProvider;
import org.jetbrains.annotations.NotNull;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
import java.util.stream.Stream;
Expand All @@ -18,19 +20,19 @@ public enum ExtendedRules implements Rule {

HTTPS {
@Override
public Failure validate(Node node) {
return node instanceof LinkNodeBase ? validateHttps((LinkNodeBase) node) : null;
public Failure validate(@NotNull Node node) {
return node instanceof LinkNodeBase ? validateHttps((LinkNodeBase) node) : NO_PROBLEM;
}
},
GITHUB_ISSUE_REF {
@Override
public Failure validate(Node node) {
return node instanceof Link ? validateGitHubIssueRef((Link) node) : null;
public Failure validate(@NotNull Node node) {
return node instanceof Link ? validateGitHubIssueRef((Link) node) : NO_PROBLEM;
}
};

@Override
public String getName() {
public @NotNull String getId() {
return name().toLowerCase(Locale.ROOT).replace('_', '-');
}

Expand All @@ -41,49 +43,61 @@ public boolean isAvailable() {

@VisibleForTesting
static Failure validateHttps(LinkNodeBase link) {
try {
if (new URL(link.getUrl().toString()).getProtocol().equals("http")) {
return Failure.of(HTTPS, "Expecting HTTPS protocol", link);
}
} catch (MalformedURLException e) {
}
return null;
return Parser
.onURL()
.parseValue(link.getUrl())
.filter(url -> !url.getProtocol().equals("https"))
.map(ignore -> Failure
.builder()
.rule(HTTPS)
.message("Expecting HTTPS protocol")
.location(link)
.build())
.orElse(NO_PROBLEM);
}

@VisibleForTesting
static Failure validateGitHubIssueRef(Link link) {
int expected = getGitHubIssueRefFromURL(link);
int found = getGitHubIssueRefFromText(link);
return expected != -1 && found != -1 && expected != found
? Failure.of(GITHUB_ISSUE_REF, "Expecting GitHub issue ref " + expected + ", found " + found, link)
: null;
return expected != NO_ISSUE_REF && found != NO_ISSUE_REF && expected != found
? Failure
.builder()
.rule(GITHUB_ISSUE_REF)
.message("Expecting GitHub issue ref " + expected + ", found " + found)
.location(link)
.build()
: NO_PROBLEM;
}

private static int getGitHubIssueRefFromURL(Link link) {
try {
URL url = new URL(link.getUrl().toString());
if (url.getHost().equals("github.com")) {
int index = url.getPath().indexOf("/issues/");
if (index != -1) {
return Integer.parseInt(url.getPath().substring(index + 8));
}
URL url = Parser.onURL().parse(link.getUrl());
if (url != null && url.getHost().equals("github.com")) {
int index = url.getPath().indexOf("/issues/");
if (index != -1) {
return Parser
.onInteger()
.parseValue(url.getPath().substring(index + 8))
.orElse(NO_ISSUE_REF);
}
} catch (MalformedURLException | NumberFormatException ex) {
}
return -1;
return NO_ISSUE_REF;
}

private static int getGitHubIssueRefFromText(Link link) {
try {
String text = link.getText().toString();
if (text.startsWith("#")) {
return Integer.parseInt(text.substring(1));
}
} catch (NumberFormatException ex) {
String text = link.getText().toString();
if (text.startsWith("#")) {
return Parser
.onInteger()
.parseValue(text.substring(1))
.orElse(NO_ISSUE_REF);
}
return -1;
return NO_ISSUE_REF;
}

private static final int NO_ISSUE_REF = -1;

@MightBeGenerated
@ServiceProvider
public static final class Batch implements RuleBatch {

Expand Down
Loading

0 comments on commit d03ab51

Please sign in to comment.