diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..166b765f --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,20 @@ +exclude-labels: + - 'skip-changelog' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +template: | + ## Changes + + $CHANGES \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..75bd8c2d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,82 @@ +name: Java CI + +on: + push: + branches: + - 'master' + - 'feature/**' + pull_request: + branches: + - 'master' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Set Version + id: set-version + run: "./gradlew properties -q | grep version: | awk '{print \"::set-output name=version::\" $2}'" + + - name: Print Version + run: echo "Version ${{ steps.set-version.outputs.version }}" + + - name: Compile + run: ./gradlew assemble + + - name: Verify + run: ./gradlew check + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: ./build/test-results/test/*.xml + + - name: Publish Artifact + if: github.event_name != 'pull_request' + env: + MVN_USER: ${{ secrets.GIT_USER }} + MVN_PASSWORD: ${{ secrets.GIT_TOKEN }} + run: | + echo "$MVN_USER" + echo "$MVN_PASSWORD" + ./gradlew publish + + - name: Perform Release + if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' }} + run: echo "Releasing version ${{ steps.set-version.outputs.version }}" + + - name: Perform Release + if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' }} + env: + GIT_USER: ${{ secrets.GIT_USER }} + GIT_PASSWORD: ${{ secrets.GIT_TOKEN }} + run: | + git config --local credential.helper "!f() { echo username=\\GIT_USER; echo password=\\$GIT_PASSWORD; }; f" + git config --global user.email "${{ secrets.GIT_EMAIL }}" + git config --global user.name "${{ secrets.GIT_USER }}" + git tag -a v${{ steps.set-version.outputs.version }} -m "Version ${{ steps.set-version.outputs.version }}" + ./gradlew incrementPatch -Dversion.prerelease=SNAPSHOT + git add version.properties + git commit -m "Incrementing to next SNAPSHOT patch version" + git push --follow-tags + + - name: Add Release Note and Create Github Release + if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' }} + uses: release-drafter/release-drafter@v5 + with: + version: ${{ steps.set-version.outputs.version }} + tag: v${{ steps.set-version.outputs.version }} + publish: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4574f8ba..3bbf2f5c 100644 --- a/build.gradle +++ b/build.gradle @@ -3,11 +3,12 @@ plugins { id 'java' id 'application' id 'codenarc' + id 'maven-publish' id 'com.github.johnrengelman.shadow' version '6.0.0' + id 'net.thauvin.erik.gradle.semver' version '1.0.4' } group 'com.avioconsulting.mule' -version '1.0-SNAPSHOT' mainClassName = 'com.avioconsulting.mule.MuleLinterCli' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -19,7 +20,6 @@ repositories { dependencies { implementation 'org.codehaus.groovy:groovy-all:3.0.0' implementation 'info.picocli:picocli-groovy:4.3.2' - testImplementation platform('org.spockframework:spock-bom:2.0-M3-groovy-3.0') testImplementation 'org.spockframework:spock-core' } @@ -34,3 +34,19 @@ codenarc { ignoreFailures = true } +publishing { + publications { + maven(MavenPublication) { + from components.java + } + } + repositories { + maven { + credentials { + username = System.getenv("MVN_USER") != null ? System.getenv("MVN_USER") : '' + password = System.getenv("MVN_PASSWORD") != null ? System.getenv("MVN_PASSWORD") : '' + } + url = 'https://maven.pkg.github.com/avioconsulting/public-packages' + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..62d4c053 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/src/test/groovy/com/avioconsulting/mule/linter/rule/property/EncryptedPasswordRuleTest.groovy b/src/test/groovy/com/avioconsulting/mule/linter/rule/property/EncryptedPasswordRuleTest.groovy index 47b33a8a..acefbb39 100644 --- a/src/test/groovy/com/avioconsulting/mule/linter/rule/property/EncryptedPasswordRuleTest.groovy +++ b/src/test/groovy/com/avioconsulting/mule/linter/rule/property/EncryptedPasswordRuleTest.groovy @@ -48,11 +48,19 @@ class EncryptedPasswordRuleTest extends Specification { then: app.propertyFiles.size() == 2 violations.size() == 3 - violations[0].fileName.contains('sample-mule-app.test.properties') - violations[0].message.endsWith('db.secret') - violations[1].fileName.contains('sample-mule-app.dev.properties') - violations[1].message.endsWith('db.secret') - violations[2].message.endsWith('password') + RuleViolation testPropertiesViolation = violations.find { + it.fileName.contains('sample-mule-app.test.properties') + } + testPropertiesViolation.message.endsWith('db.secret') + List devPropertiesViolation = violations.findAll { + it.fileName.contains('sample-mule-app.dev.properties') + } + devPropertiesViolation.find { + it.message.contains('db.secret') + } + devPropertiesViolation.find { + it.message.contains('password') + } } private static final String GOOD_PROPERTY_1 = ''' diff --git a/src/test/groovy/com/avioconsulting/mule/linter/rule/property/HostnamePropertyRuleTest.groovy b/src/test/groovy/com/avioconsulting/mule/linter/rule/property/HostnamePropertyRuleTest.groovy index 3f5bf80e..392b217e 100644 --- a/src/test/groovy/com/avioconsulting/mule/linter/rule/property/HostnamePropertyRuleTest.groovy +++ b/src/test/groovy/com/avioconsulting/mule/linter/rule/property/HostnamePropertyRuleTest.groovy @@ -46,10 +46,14 @@ class HostnamePropertyRuleTest extends Specification { then: app.propertyFiles.size() == 2 violations.size() == 2 - violations[0].fileName.contains('sample-mule-app.test.properties') - violations[0].message == HostnamePropertyRule.RULE_VIOLATION_MESSAGE + 'db.host' - violations[1].fileName.contains('sample-mule-app.dev.properties') - violations[1].message == HostnamePropertyRule.RULE_VIOLATION_MESSAGE + 'db.hostname' + RuleViolation testPropertiesViolation = violations.find { + it.fileName.contains('sample-mule-app.test.properties') + } + testPropertiesViolation.message == HostnamePropertyRule.RULE_VIOLATION_MESSAGE + 'db.host' + RuleViolation devPropertiesViolation = violations.find { + it.fileName.contains('sample-mule-app.dev.properties') + } + devPropertiesViolation.message == HostnamePropertyRule.RULE_VIOLATION_MESSAGE + 'db.hostname' } def 'Exempt properties pass rule'() { diff --git a/version.properties b/version.properties new file mode 100644 index 00000000..28885410 --- /dev/null +++ b/version.properties @@ -0,0 +1,6 @@ +version.buildmeta= +version.major=1 +version.minor=0 +version.patch=0 +version.prerelease=SNAPSHOT +version.semver=1.0.0-SNAPSHOT \ No newline at end of file