Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Github Action #72

Merged
merged 6 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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
82 changes: 82 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 18 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
}
Expand All @@ -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'
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RuleViolation> 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 = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'() {
Expand Down
6 changes: 6 additions & 0 deletions version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version.buildmeta=
version.major=1
version.minor=0
version.patch=0
version.prerelease=SNAPSHOT
version.semver=1.0.0-SNAPSHOT