Skip to content

Commit

Permalink
Merge pull request #4 from itsallcode/upgrade-dependencies
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
kaklakariada authored Jan 27, 2024
2 parents d208e9e + aa089c6 commit 939cfea
Show file tree
Hide file tree
Showing 31 changed files with 344 additions and 599 deletions.
57 changes: 34 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,44 @@ name: Build

on:
push:
branches: [ master, develop ]
branches: [ main ]
pull_request:
branches: [ master, develop ]
branches: [ main ]

jobs:
build:
matrix-build:

runs-on: ubuntu-latest
strategy:
matrix:
java: [11, 17, 21]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-java-${{ matrix.java }}
cancel-in-progress: true
name: "Build with Java ${{ matrix.java }}"
env:
DEFAULT_JAVA: 11

steps:
- uses: actions/checkout@v2
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- uses: actions/setup-java@v1
- uses: actions/checkout@v4
with:
java-version: 11
- uses: gradle/wrapper-validation-action@v1
- name: Cache Gradle packages and wrapper
uses: actions/cache@v2
fetch-depth: 0
- uses: actions/setup-java@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Build with Gradle
run: |
./gradlew build --warning-mode=summary
cache: gradle
distribution: temurin
java-version: |
11
17
21
- uses: gradle/wrapper-validation-action@v1
- name: Build with Java ${{ matrix.java }}
run: ./gradlew build --info --warning-mode=summary -PjavaVersion=${{ matrix.java }}
- name: Sonar analysis
if: ${{ env.DEFAULT_JAVA == matrix.java && env.SONAR_TOKEN != null }}
run: |
./gradlew sonarqube -Dsonar.host.url=https://sonarcloud.io \
-Dsonar.organization=itsallcode \
-Dsonar.login=$SONAR_TOKEN \
--warning-mode=summary
./gradlew sonarqube -Dsonar.token=$SONAR_TOKEN -PjavaVersion=${{ matrix.java }} \
--info --warning-mode=summary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -45,3 +49,10 @@ jobs:
with:
report_paths: '**/build/test-results/*/TEST-*.xml'
github_token: ${{ secrets.GITHUB_TOKEN }}

build:
needs: matrix-build
runs-on: ubuntu-latest
steps:
- run: echo "Build successful"

34 changes: 12 additions & 22 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: "CodeQL"

on:
push:
branches: [master, develop]
branches: [main]
pull_request:
branches: [master, develop]
schedule:
- cron: '0 7 * * 6'
branches: [main]

jobs:
analyze:
Expand All @@ -20,35 +18,27 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 2

- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: 11
cache: gradle
distribution: temurin
java-version: |
11
17
- uses: gradle/wrapper-validation-action@v1

- name: Cache Gradle packages and wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ${{ runner.os }}-gradle-

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.generate.finalModifiers": "explicit",
"source.fixAll": "explicit"
},
"java.saveActions.organizeImports": true,
"java.sources.organizeImports.starThreshold": 3,
"java.sources.organizeImports.staticStarThreshold": 3,
"java.configuration.updateBuildConfiguration": "automatic",
"sonarlint.connectedMode.project": {
"connectionId": "itsallcode",
"projectKey": "org.itsallcode:hamcrest-auto-matcher"
}
}
47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repositories {
}
dependencies {
testCompile 'org.itsallcode:hamcrest-auto-matcher:0.5.0'
testCompile 'org.itsallcode:hamcrest-auto-matcher:0.5.1'
}
```

Expand All @@ -39,7 +39,7 @@ dependencies {
<dependency>
<groupId>org.itsallcode</groupId>
<artifactId>hamcrest-auto-matcher</artifactId>
<version>0.5.0</version>
<version>0.5.1</version>
<scope>test</scope>
</dependency>
```
Expand Down Expand Up @@ -153,19 +153,36 @@ Also see [`DemoModelMatcher`](src/test/java/com/github/hamstercommunity/matcher/
## Development

```bash
$ git clone https://github.com/itsallcode/hamcrest-auto-matcher.git
$ ./gradlew check
git clone https://github.com/itsallcode/hamcrest-auto-matcher.git
cd hamcrest-auto-matcher
./gradlew check
# Test report: build/reports/tests/index.html
```

### Using eclipse

Import into eclipse using [buildship](https://projects.eclipse.org/projects/tools.buildship).

### Generate license header for added files
### Run sonar analysis

```bash
$ ./gradlew licenseFormat
./gradlew clean sonar --info -Dsonar.token=[token]
```

### Check for dependency updates

```bash
./gradlew dependencyUpdates
```


### Test Coverage

To calculate and view test coverage:

```sh
./gradlew check jacocoTestReport
open build/reports/jacoco/test/html/index.html
```

### Publish to Maven Central
Expand All @@ -181,12 +198,18 @@ $ ./gradlew licenseFormat
signing.secretKeyRingFile=<path to secret keyring file>
```

2. Increment version number in `build.gradle`, update version in README.md, commit and push.
3. Run the following command:
2. Increment version number in `build.gradle` and `README.md`, commit and push.
3. Optional: run the following command to do a dry-run:

```sh
./gradlew clean check build publishToSonatype closeSonatypeStagingRepository --info
```

4. Run the following command to publish to Maven Central:

```bash
$ ./gradlew clean check build publish closeAndReleaseRepository --info
```sh
./gradlew clean check build publishToSonatype closeAndReleaseSonatypeStagingRepository --info
```

4. Create a new [release](https://github.com/itsallcode/hamcrest-auto-matcher/releases) on GitHub.
5. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-auto-matcher/).
5. Create a new [release](https://github.com/itsallcode/hamcrest-auto-matcher/releases) on GitHub.
6. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-auto-matcher/).
64 changes: 50 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ plugins {
id "signing"
id "maven-publish"
id "jacoco"
id "com.github.hierynomus.license" version "0.15.0"
id "org.sonarqube" version "3.1.1"
id "io.codearte.nexus-staging" version "0.22.0"
id "org.sonarqube" version "4.4.1.3373"
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
id "com.github.ben-manes.versions" version "0.51.0"
}

repositories {
Expand All @@ -14,42 +14,59 @@ repositories {

dependencies {
implementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.j8unit:core:4.12.1'
}

group 'org.itsallcode'
version = '0.5.0'
version = '0.5.1'

java {
toolchain {
def javaVersion = project.hasProperty('javaVersion') ? project.getProperty('javaVersion') : 11
languageVersion = JavaLanguageVersion.of(11)
}
withJavadocJar()
withSourcesJar()
}

testing {
suites {
test {
var junitVersion = '5.10.1'
useJUnitJupiter(junitVersion)
dependencies {
implementation 'org.j8unit:core:4.12.1'
implementation "org.junit.vintage:junit-vintage-engine:${junitVersion}"
}
}
}
}

javadoc {
failOnError = true
options.addBooleanOption('html5', true)
options.addStringOption('Xwerror', '-quiet')
}

tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:all'
options.encoding = 'UTF-8'
}

license {
header = file('gradle/license-header.txt')
}

jacocoTestReport {
reports {
xml.enabled true
xml.required = true
}
}

rootProject.tasks["sonarqube"].dependsOn(tasks["jacocoTestReport"])

sonarqube {
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.organization", "itsallcode"
}
}

def getOptionalProperty(String name) {
if(project.hasProperty(name)) {
return project.property(name)
Expand Down Expand Up @@ -107,8 +124,27 @@ signing {
sign publishing.publications.mavenJava
}

nexusStaging {

nexusPublishing {
packageGroup = project.group
username = getOptionalProperty("ossrhUsername")
password = getOptionalProperty("ossrhPassword")
repositories {
sonatype {
stagingProfileId = "546ea6ce74787e"
username = getOptionalProperty("ossrhUsername")
password = getOptionalProperty("ossrhPassword")
}
}
}

def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}

tasks.named("dependencyUpdates").configure {
gradleReleaseChannel = "current"
rejectVersionIf {
isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)
}
}
15 changes: 0 additions & 15 deletions gradle/license-header.txt

This file was deleted.

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 939cfea

Please sign in to comment.