From aa7a8ed48e65af15e20de377e904dc5952c0d7d1 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Thu, 28 Jan 2021 23:31:28 +0300 Subject: [PATCH 01/47] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/issue_reminder.yml | 22 +++++++++++++++ .github/workflows/linter.yml | 37 ++++++++++++++++++++++++ .github/workflows/shfmt.yml | 42 ++++++++++++++++++++++++++++ .github/workflows/version-update.yml | 31 ++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 .github/workflows/issue_reminder.yml create mode 100644 .github/workflows/linter.yml create mode 100644 .github/workflows/shfmt.yml create mode 100644 .github/workflows/version-update.yml diff --git a/.github/workflows/issue_reminder.yml b/.github/workflows/issue_reminder.yml new file mode 100644 index 0000000..709c89e --- /dev/null +++ b/.github/workflows/issue_reminder.yml @@ -0,0 +1,22 @@ +name: Issue Reminder +on: + issues: + types: [ opened ] + +jobs: + issue_comment: + runs-on: ubuntu-latest + steps: + - name: Comment on issue + uses: actions/github-script@0.9.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + var url = 'https://github.com/AlexRogalskiy/gradle-java-sample/blob/master/.github/ISSUE_TEMPLATE/bug_report.md' + var msg = `Thank you for opening an issue. If this issue is related to a bug, please follow the steps and provide the information outlined in the [Bug Report Guide](${url}). Failure to follow these instructions may result in automatic closing of this issue.` + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: msg + }) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..a2a5363 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,37 @@ +name: Lint Code Base + +# +# Documentation: +# https://help.github.com/en/articles/workflow-syntax-for-github-actions +# + +############################# +# Start the job on all push # +############################# +on: + push: + branches-ignore: [ master ] + # Remove the line above to run when pushing to master + pull_request: + branches: [ master ] + +############### +# Set the Job # +############### +jobs: + build: + # Name the Job + name: Lint Code Base + # Set the agent to run on + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Lint Code Base + uses: github/super-linter@v3 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/shfmt.yml b/.github/workflows/shfmt.yml new file mode 100644 index 0000000..92bf85c --- /dev/null +++ b/.github/workflows/shfmt.yml @@ -0,0 +1,42 @@ +name: Check Shell scripts + +on: + pull_request: + paths: + - "**/*.sh" + +jobs: + shfmt: + name: Shellformat + runs-on: ubuntu-latest + steps: + - name: Prepare git + run: git config --global core.autocrlf false + + - name: Checkout repository + uses: actions/checkout@v1 + + - run: docker run -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.6.3 shfmt -sr -i 2 -l -w -ci . + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - name: Prepare git + run: git config --global core.autocrlf false + + - name: Checkout repository + uses: actions/checkout@v1 + + - run: shellcheck *.sh + shellcheck2: + name: Shellcheck2 + runs-on: ubuntu-latest + steps: + - name: Prepare git + run: git config --global core.autocrlf false + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master diff --git a/.github/workflows/version-update.yml b/.github/workflows/version-update.yml new file mode 100644 index 0000000..ba037ec --- /dev/null +++ b/.github/workflows/version-update.yml @@ -0,0 +1,31 @@ +name: Version Update + +on: + push: + tags: + - '*.**' + +jobs: + update-version: + name: Update VERSION + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + ref: master + fetch-depth: 0 + + - name: Edit version.txt + run: echo "VERSION = \"$(git describe --tags `git rev-list --tags --max-count=1`)\"" > version.txt + + - name: Commit update + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + skip_dirty_check: true + commit_message: 'Update VERSION' + commit_options: '--no-verify --signoff' + commit_user_name: GitHub Bot + commit_user_email: github-actions@nullables.io + commit_author: GitHub Bot From b1fbb3cae810d3b64c962173a6e702e42784f147 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Fri, 29 Jan 2021 12:40:02 +0300 Subject: [PATCH 02/47] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/unlock-reopened-issues.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/unlock-reopened-issues.yml diff --git a/.github/workflows/unlock-reopened-issues.yml b/.github/workflows/unlock-reopened-issues.yml new file mode 100644 index 0000000..178ca5a --- /dev/null +++ b/.github/workflows/unlock-reopened-issues.yml @@ -0,0 +1,13 @@ +name: Unlock reopened issue + +on: + issues: + types: [ reopened ] + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: Dunning-Kruger/unlock-issues@v1 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" From b6aec63f497a8e1eca3e267136ad8553ac557cdd Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Fri, 29 Jan 2021 21:33:29 +0300 Subject: [PATCH 03/47] docs: updates on documentation Added informational and corporate documentation --- build.gradle | 1 + buildSrc/src/main/groovy/subproject.gradle | 38 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 4eea178..6984fe9 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ plugins { id("java") id("maven") id("checkstyle") + id("java-gradle-plugin") } repositories { diff --git a/buildSrc/src/main/groovy/subproject.gradle b/buildSrc/src/main/groovy/subproject.gradle index 6834699..ae1f890 100644 --- a/buildSrc/src/main/groovy/subproject.gradle +++ b/buildSrc/src/main/groovy/subproject.gradle @@ -67,12 +67,46 @@ clean.doFirst { sourceSets { main.java.srcDirs += "src/main/java" test.java.srcDirs += "src/test/java" + + functionalTest { + java { + srcDir file('src/functionalTest/java') + } + resources { + srcDir file('src/functionalTest/resources') + } + compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath + runtimeClasspath += output + compileClasspath + } +} + +task functionalTest(type: Test) { + testClassesDirs = sourceSets.functionalTest.output.classesDirs + classpath = sourceSets.functionalTest.runtimeClasspath } +check.dependsOn functionalTest + +//gradlePlugin { +// testSourceSets sourceSets.functionalTest +//} processResources { - doFirst { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + + with copySpec { from 'src/main/resources' - filter(ReplaceTokens, tokens: [project_version: project.version, project_name: project.name]) + include '**/application*.yml' + include '**/application*.yaml' + include '**/application*.properties' + + project.properties.findAll().each { + prop -> + if (prop.value != null) { + filter(ReplaceTokens, tokens: [(prop.key): String.valueOf(prop.value)]) + filter(ReplaceTokens, tokens: [('project.' + prop.key): String.valueOf(prop.value)]) + filter(ReplaceTokens, tokens: [project_version: project.version, project_name: project.name]) + } + } } } From a76727777d0674f0fe9cc5b8a11be9e12496ba8f Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Mon, 1 Feb 2021 21:04:25 +0300 Subject: [PATCH 04/47] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/changelog.yml | 41 +++++++++++++++++++++++++++++++++ .typo-ci.yml | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/changelog.yml create mode 100644 .typo-ci.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..89b58d0 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,41 @@ +# From: https://github.com/hopsoft/stimulus_reflex/blob/master/.github/workflows/changelog.yml +name: Changelog + +on: + workflow_dispatch: + release: + types: [ created ] + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 4 + if: "!contains(github.event.head_commit.message, '[nodoc]')" + steps: + - uses: actions/checkout@master + - name: Set up Ruby 3.0 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + - uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-changelog-gem + restore-keys: ${{ runner.os }}-changelog-gem + - name: Create local changes + run: | + gem install github_changelog_generator + github_changelog_generator -u ${{ github.repository_owner }} -p ${{ github.event.repository.name }} --token ${{ secrets.GITHUB_TOKEN }} --exclude-labels duplicate,question,invalid,wontfix,nodoc + - name: Commit files + run: | + git config --local user.email "github-actions@example.com" + git config --local user.name "GitHub Actions" + git commit -am "[nodoc] Update Changelog\n\nAdded CHANGELOG file" || echo "No changes to commit" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} \ No newline at end of file diff --git a/.typo-ci.yml b/.typo-ci.yml new file mode 100644 index 0000000..81bd581 --- /dev/null +++ b/.typo-ci.yml @@ -0,0 +1,41 @@ +# This is a sample .typo-ci.yml file, it's used to configure how Typo CI will behave. +# Add it to the root of your project and push it to github. +--- + +# What language dictionaries should it use? By default Typo CI will select 'en' & 'en_GB' +# Currently Typo CI supports: +# de +# en +# en_GB +# es +# fr +# it +# pt +# pt_BR +# tr +dictionaries: + - en + - en_GB + +# Any files/folders we should ignore? +excluded_files: + - "vendor/**/*" + - "node_modules/**/*" + - "*.key" + - "*.enc" + - "*.min.css" + - "*.css.map" + - "*.min.js" + - "*.js.map" + - "*.mk" + - "package-lock.json" + - "yarn.lock" + - "Gemfile.lock" + - ".typo-ci.yml" + +# Any typos we should ignore? +excluded_words: + - typoci + +# Would you like filenames to also be spellchecked? +spellcheck_filenames: true \ No newline at end of file From 696fa3fa5256eac399ca306d81a0297162a51e65 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Mon, 1 Feb 2021 23:05:49 +0300 Subject: [PATCH 05/47] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/remove-old-artifacts.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/remove-old-artifacts.yml diff --git a/.github/workflows/remove-old-artifacts.yml b/.github/workflows/remove-old-artifacts.yml new file mode 100644 index 0000000..6ad0067 --- /dev/null +++ b/.github/workflows/remove-old-artifacts.yml @@ -0,0 +1,18 @@ +name: Remove old artifacts + +on: + schedule: + # Every day at 1am + - cron: '0 1 * * *' + +jobs: + remove-old-artifacts: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Remove old artifacts + uses: c-hive/gha-remove-artifacts@v1 + with: + age: '7 days' + skip-tags: false \ No newline at end of file From de2cb17d7535e20a9fc7f7cc5c0919499e1cd5b5 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Tue, 2 Feb 2021 15:04:13 +0300 Subject: [PATCH 06/47] docs: updates on documentation Added informational and corporate documentation --- buildSrc/src/main/groovy/subproject.gradle | 3 +- codecheck/checkstyle/checkstyle-new-code.xml | 240 +++++++++++++++++++ 2 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 codecheck/checkstyle/checkstyle-new-code.xml diff --git a/buildSrc/src/main/groovy/subproject.gradle b/buildSrc/src/main/groovy/subproject.gradle index ae1f890..a0427aa 100644 --- a/buildSrc/src/main/groovy/subproject.gradle +++ b/buildSrc/src/main/groovy/subproject.gradle @@ -118,10 +118,11 @@ test { useJUnitPlatform() testLogging { + displayGranularity = 2 showExceptions = true showStandardStreams = true exceptionFormat = TestExceptionFormat.FULL - events "skipped", "failed", "standardOut", "standardError" + events "skipped", "passed", "failed", "standardOut", "standardError" } testlogger { diff --git a/codecheck/checkstyle/checkstyle-new-code.xml b/codecheck/checkstyle/checkstyle-new-code.xml new file mode 100644 index 0000000..7afa836 --- /dev/null +++ b/codecheck/checkstyle/checkstyle-new-code.xml @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 53af7b154afcbe9ad4632b47a27c34d78f34faf6 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Tue, 2 Feb 2021 20:11:41 +0300 Subject: [PATCH 07/47] docs: updates on documentation Added informational and corporate documentation --- buildSrc/src/main/groovy/dependencies.gradle | 6 +- db-schema/README.md | 87 +++++++++++++++++++ db-schema/build.gradle | 41 +++++++++ db-schema/src/main/resources/db/clean_db.sql | 1 + .../db/migration/V1.0__init_test_schema.sql | 3 + .../resources/flyway/conf/flyway-dev.conf | 12 +++ .../resources/flyway/conf/flyway-local.conf | 14 +++ settings.gradle | 1 + 8 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 db-schema/README.md create mode 100644 db-schema/build.gradle create mode 100644 db-schema/src/main/resources/db/clean_db.sql create mode 100644 db-schema/src/main/resources/db/migration/V1.0__init_test_schema.sql create mode 100644 db-schema/src/main/resources/flyway/conf/flyway-dev.conf create mode 100644 db-schema/src/main/resources/flyway/conf/flyway-local.conf diff --git a/buildSrc/src/main/groovy/dependencies.gradle b/buildSrc/src/main/groovy/dependencies.gradle index 8e26e52..9b87845 100644 --- a/buildSrc/src/main/groovy/dependencies.gradle +++ b/buildSrc/src/main/groovy/dependencies.gradle @@ -33,6 +33,8 @@ ext.versions = [ "ktlint" : "0.29.0", "lint" : "0.40.0", "mockito" : "3.7.7", + flyway : '7.5.2', + postgresql : '42.2.18' ] ext.libraries = [ @@ -56,7 +58,9 @@ ext.libraries = [ "logback_json_classic": "ch.qos.logback.contrib:logback-json-classic:${versions.logback_json}", "logback_jackson" : "ch.qos.logback.contrib:logback-jackson:${versions.logback_json}", "jackson_databind" : "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}", - "janino" : "org.codehaus.janino:janino:${versions.janino}" + "janino" : "org.codehaus.janino:janino:${versions.janino}", + "flyway" : "org.flywaydb:flyway-core:${versions.flyway}", + "postgresql" : "org.postgresql:postgresql:${versions.postgresql}" ], test: [ "assertj" : "org.assertj:assertj-core:${versions.assertj}", diff --git a/db-schema/README.md b/db-schema/README.md new file mode 100644 index 0000000..42f2f03 --- /dev/null +++ b/db-schema/README.md @@ -0,0 +1,87 @@ +# Project Title + +One Paragraph of project description goes here + +## Getting Started + +These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. + +### Prerequisites + +What things you need to install the software and how to install them + +``` +Give examples +``` + +### Installing + +A step by step series of examples that tell you how to get a development env running + +Say what the step will be + +``` +Give the example +``` + +And repeat + +``` +until finished +``` + +End with an example of getting some data out of the system or using it for a little demo + +## Running the tests + +Explain how to run the automated tests for this system + +### Break down into end to end tests + +Explain what these tests test and why + +``` +Give an example +``` + +### And coding style tests + +Explain what these tests test and why + +``` +Give an example +``` + +## Deployment + +Add additional notes about how to deploy this on a live system + +## Built With + +* [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used +* [Maven](https://maven.apache.org/) - Dependency Management +* [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds + +## Contributing + +Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us. + +## Versioning + +We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). + +## Authors + +* **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth) + +See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments + +* Hat tip to anyone whose code was used +* Inspiration +* etc diff --git a/db-schema/build.gradle b/db-schema/build.gradle new file mode 100644 index 0000000..65562f8 --- /dev/null +++ b/db-schema/build.gradle @@ -0,0 +1,41 @@ +import org.apache.tools.ant.filters.ReplaceTokens +import org.flywaydb.gradle.task.FlywayMigrateTask + +plugins { + id "org.flywaydb.flyway" version "7.5.2" +} + +dependencies { + implementation libraries.core.flyway + implementation libraries.core.postgresql +} + +def profiles = ['dev', 'local'] + +task flywayMigrateSchema( + type: FlywayMigrateTask, + dependsOn: ['classes'], + group: "flyway", + description: 'Migrate DataBase schema', +) { + def confDir = "$buildDir/resources/main/flyway/conf" + def activeProfile = project.hasProperty('db') ? project.getProperty('db') : 'local' + if (!profiles.contains(activeProfile)) { + throw new InvalidUserDataException(String.format("DB migration profile is not valid [%s], supported profiles %s", activeProfile, profiles)) + } + configFiles = ["$confDir/flyway-${activeProfile}.conf"] +} + +processResources { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + with copySpec { + from 'src/main/resources' + include '**/flyway*.conf' + project.properties.findAll().each { + prop -> + if (prop.value != null) { + filter(ReplaceTokens, tokens: [(prop.key): String.valueOf(prop.value)]) + } + } + } +} diff --git a/db-schema/src/main/resources/db/clean_db.sql b/db-schema/src/main/resources/db/clean_db.sql new file mode 100644 index 0000000..abec395 --- /dev/null +++ b/db-schema/src/main/resources/db/clean_db.sql @@ -0,0 +1 @@ +DROP SCHEMA test CASCADE; diff --git a/db-schema/src/main/resources/db/migration/V1.0__init_test_schema.sql b/db-schema/src/main/resources/db/migration/V1.0__init_test_schema.sql new file mode 100644 index 0000000..ca4ea20 --- /dev/null +++ b/db-schema/src/main/resources/db/migration/V1.0__init_test_schema.sql @@ -0,0 +1,3 @@ +-- test schema +CREATE SCHEMA IF NOT EXISTS test; +SET search_path = test; diff --git a/db-schema/src/main/resources/flyway/conf/flyway-dev.conf b/db-schema/src/main/resources/flyway/conf/flyway-dev.conf new file mode 100644 index 0000000..13bbddc --- /dev/null +++ b/db-schema/src/main/resources/flyway/conf/flyway-dev.conf @@ -0,0 +1,12 @@ +## https://flywaydb.org/documentation/configuration/configfile +flyway.url=jdbc:postgresql://localhost:5432/test?sslMode=disable +flyway.user=postgres +flyway.password=postgres +# List of supported schemas +flyway.schemas=test +flyway.createSchemas=false +# Maximum number of retries when attempting to connect to the database +flyway.connectRetries=10 +# List of available migration locations +flyway.locations=classpath:**/db/migration +#flyway.locations=filesystem:@buildDir@/resources/main/db/migration diff --git a/db-schema/src/main/resources/flyway/conf/flyway-local.conf b/db-schema/src/main/resources/flyway/conf/flyway-local.conf new file mode 100644 index 0000000..e7ab949 --- /dev/null +++ b/db-schema/src/main/resources/flyway/conf/flyway-local.conf @@ -0,0 +1,14 @@ +## https://flywaydb.org/documentation/configuration/configfile +flyway.url=jdbc:postgresql://localhost:5432/test?sslMode=disable +flyway.user=postgres +flyway.password=postgres +# List of supported schemas +flyway.schemas=test +flyway.createSchemas=true +# Migrations handling strategy +flyway.ignoreMissingMigrations=true +flyway.ignoreIgnoredMigrations=true +flyway.ignoreFutureMigrations=true +# List of available migration locations +flyway.locations=classpath:**/db/migration +#flyway.locations=filesystem:@buildDir@/resources/main/db/migration diff --git a/settings.gradle b/settings.gradle index 640f3d6..206b7b4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -43,3 +43,4 @@ include 'flatbuffers' include 'avro' include 'thrift' include 'codecheck' +include 'db-schema' From 69fac7cb47a02c76ee1cbd6770f526519cc0e0cc Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Wed, 3 Feb 2021 12:01:49 +0300 Subject: [PATCH 08/47] docs: updates on workflows Added information on documentation --- codecheck/quality.gradle | 48 +++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/codecheck/quality.gradle b/codecheck/quality.gradle index c4e2967..cc24fa4 100644 --- a/codecheck/quality.gradle +++ b/codecheck/quality.gradle @@ -2,6 +2,7 @@ * Set up Checkstyle, Findbugs and PMD to perform extensive code analysis. * * Gradle tasks added: + * - jacocoTestCoverageVerification * - checkstyle * - findbugs * - pmd @@ -17,9 +18,39 @@ apply plugin: 'pmd' def qualityConfigDir = "$project.rootDir/codecheck" as String; def reportsDir = "$project.buildDir/reports" as String -check.dependsOn 'checkstyle', 'findbugs', 'pmd' +check.dependsOn 'checkstyle', 'jacocoTestCoverageVerification', 'findbugs', 'pmd' -task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code style checks') { +task jacocoTestCoverageVerification( + type: JacocoCoverageVerification, + group: 'Verification', + description: 'Jacoco test coverage verification', + dependsOn: 'jacocoTestReport' +) { + def jacocoFilter = ['**/BuildConfig.*', '**/*Test*.*', '**/*Exception*.*'] + + sourceDirectories.setFrom(files(["$project.projectDir/src/main/java"])) + classDirectories.setFrom(files([fileTree(dir: "$project.buildDir/intermediates/javac/debug", excludes: jacocoFilter)])) + executionData.setFrom(files("${buildDir}/jacoco/testDebugUnitTest.exec")) + + violationRules { + failOnViolation = true + rule { + element = 'BUNDLE' + + limit { + value = 'COVEREDRATIO' + counter = 'INSTRUCTION' + minimum = 0.8 + } + } + } +} + +task checkstyle( + type: Checkstyle, + group: 'Verification', + description: 'Runs code style checks' +) { configFile file("$qualityConfigDir/checkstyle/checkstyle.xml") configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/codecheck/checkstyle/suppressions.xml").absolutePath @@ -28,6 +59,7 @@ task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code source 'src' include '**/*.java' + exclude '**/gen/**' reports { xml.enabled = true @@ -37,10 +69,12 @@ task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code classpath = files() } -task findbugs(type: FindBugs, +task findbugs( + type: FindBugs, group: 'Verification', description: 'Inspect java bytecode for bugs', - dependsOn: ['compileDebugSources', 'compileReleaseSources']) { + dependsOn: ['compileDebugSources', 'compileReleaseSources'] +) { ignoreFailures = true effort = "max" @@ -66,7 +100,11 @@ task findbugs(type: FindBugs, classpath = files() } -task pmd(type: Pmd, group: 'Verification', description: 'Inspect sourcecode for bugs') { +task pmd( + type: Pmd, + group: 'Verification', + description: 'Inspect sourcecode for bugs' +) { ruleSetFiles = files("$qualityConfigDir/pmd/pmd-ruleset.xml") ignoreFailures = true ruleSets = [] From 9669a18d9196fc2a354cd0a026dab25e5d45f3e9 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Thu, 4 Feb 2021 05:23:24 +0300 Subject: [PATCH 09/47] docs: updates on documentation Added informational and corporate documentation --- .../src/main/groovy/android-artifacts.gradle | 30 +++++++ .../src/main/groovy/central-publish.gradle | 85 +++++++++++++++++++ gradle.properties | 19 ++++- 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 buildSrc/src/main/groovy/android-artifacts.gradle create mode 100644 buildSrc/src/main/groovy/central-publish.gradle diff --git a/buildSrc/src/main/groovy/android-artifacts.gradle b/buildSrc/src/main/groovy/android-artifacts.gradle new file mode 100644 index 0000000..9d2842e --- /dev/null +++ b/buildSrc/src/main/groovy/android-artifacts.gradle @@ -0,0 +1,30 @@ +task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar" + classpath += files(ext.androidJar) +} + +/* + This fails for modules depending on other modules (published aar files), + therefore we just skip the androidJavaDocs part: + task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + */ +task androidJavadocsJar(type: Jar) { + archiveClassifier.set('javadoc') + from androidJavadocs.destinationDir +} + +task androidSourcesJar(type: Jar) { + archiveClassifier.set('sources') + from android.sourceSets.main.java.sourceFiles +} + +task androidJar(type: Jar) { + from 'build/intermediates/classes/release' +} + +artifacts { + archives androidSourcesJar + archives androidJavadocsJar + //archives androidJar +} diff --git a/buildSrc/src/main/groovy/central-publish.gradle b/buildSrc/src/main/groovy/central-publish.gradle new file mode 100644 index 0000000..40c4df9 --- /dev/null +++ b/buildSrc/src/main/groovy/central-publish.gradle @@ -0,0 +1,85 @@ +apply plugin: 'maven' +apply plugin: 'signing' + +def isReleaseBuild() { + return POM_VERSION_NAME.contains("SNAPSHOT") == false +} + +def getReleaseRepositoryUrl() { + return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL + : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" +} + +def getSnapshotRepositoryUrl() { + return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL + : "https://oss.sonatype.org/content/repositories/snapshots/" +} + +// credentials are stored in ~/.gradle/gradle.properties with ~ being the path of the home directory +def getRepositoryUsername() { + return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" +} + +// credentials are stored in ~/.gradle/gradle.properties with ~ being the path of the home directory +def getRepositoryPassword() { + return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" +} + +afterEvaluate { project -> + uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { deployment -> signing.signPom(deployment) } + + pom.groupId = POM_GROUP_ID + pom.artifactId = POM_ARTIFACT_ID + pom.version = POM_VERSION_NAME + + repository(url: getReleaseRepositoryUrl()) { + authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) + } + snapshotRepository(url: getSnapshotRepositoryUrl()) { + authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) + } + + pom.project { + name POM_NAME + packaging POM_PACKAGING + description POM_DESCRIPTION + url POM_URL + + scm { + url POM_SCM_URL + connection POM_SCM_CONNECTION + developerConnection POM_SCM_DEV_CONNECTION + } + + organization { + name POM_COMPANY_NAME + url POM_COMPANY_URL + } + + developers { + developer { + id POM_DEVELOPER_ID + name POM_DEVELOPER_NAME + } + } + + licenses { + license { + name POM_LICENCE_NAME + url POM_LICENCE_URL + distribution POM_LICENCE_DIST + } + } + } + } + } + } + + signing { + required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives + } +} diff --git a/gradle.properties b/gradle.properties index 1d7f7ca..3bf48e7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -30,4 +30,21 @@ systemProp.org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=756m -XX:+HeapDumpOnOu ### Project properties ### baseUrl="https://github.com/AlexRogalskiy/gradle-java-sample" - +### +### Release properties +### +POM_GROUP_ID=com.1gravity +POM_DESCRIPTION=Android RTEditor is a rich text editor component used as drop-in for EditText +POM_URL=https://github.com/1gravity/Android-RTEditor +POM_SCM_URL=https://github.com/1gravity/Android-RTEditor +POM_SCM_CONNECTION=scm:git@github.com:1gravity/Android-RTEditor.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:1gravity/Android-RTEditor.git +POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo +POM_COMPANY_NAME=1gravity LLC +POM_COMPANY_URL=www.1gravity.com +POM_DEVELOPER_ID=1gravity +POM_DEVELOPER_NAME=Emanuel Moecklin +POM_DEVELOPER_EMAIL=1gravityllc@gmail.com +POM_ISSUE_URL=https://github.com/1gravity/Android-RTEditor/issues From 775e3c2b5667f5e50a5558782f361e567fbfbd24 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Thu, 4 Feb 2021 18:09:50 +0300 Subject: [PATCH 10/47] docs: updates on documentation Added informational and corporate documentation --- .gitpod.Dockerfile | 2 +- .travis.yml | 1 + build.gradle | 20 ++++++++--- buildSrc/src/main/groovy/dependencies.gradle | 3 ++ buildSrc/src/main/groovy/subproject.gradle | 3 ++ codecheck/quality.gradle | 38 ++++++++++++++++++-- protobuf/build.gradle | 21 +++++++++++ 7 files changed, 81 insertions(+), 7 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index c0f82fe..010121d 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -19,7 +19,7 @@ LABEL io.nullables.api.playground.image.vendor="Nullables.io" LABEL io.nullables.api.playground.image.version=$VERSION ENV LC_ALL en_US.UTF-8 -ENV LANG ${LC_ALL} +ENV LANG $LC_ALL # Downloading and installing Gradle # Define a constant with the version of gradle you want to install diff --git a/.travis.yml b/.travis.yml index c23ca2a..cd30cd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,7 @@ notifications: before_cache: - rm -rf $HOME/.gradle/repository/ + - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ cache: directories: diff --git a/build.gradle b/build.gradle index 6984fe9..c91db27 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,8 @@ plugins { id("com.github.johnrengelman.shadow") id("com.adarshr.test-logger") version "2.1.1" id("com.diffplug.spotless") version "5.9.0" + id("com.gorylenko.gradle-git-properties") version "2.2.4" + id("io.franzbecker.gradle-lombok") version "4.0.0" id("org.sonarqube") id("java") @@ -59,6 +61,20 @@ allprojects { } } +// jacocoTestReport { +// reports { +// html.enabled = true +// xml.enabled = true +// csv.enabled = false +// } +// } + + gitProperties { + failOnNoGitDirectory = false + dateFormat = "yyyy-MM-dd'T'HH:mmZ" + dateFormatTimeZone = "PST" + } + def buildProperties = new Properties() file(rootDir.absolutePath + "/build.properties").withInputStream { buildProperties.load(it) } if (buildProperties.getProperty("build.debug").toBoolean()) { @@ -105,10 +121,6 @@ subprojects { sourceCompatibility = projectConfig.sourceCompatibility targetCompatibility = projectConfig.targetCompatibility - compileJava.options.encoding = 'UTF-8' - compileTestJava.options.encoding = 'UTF-8' - javadoc.options.encoding = 'UTF-8' - archivesBaseName = project.buildFile project.buildDir = projectConfig.projectBuildDir diff --git a/buildSrc/src/main/groovy/dependencies.gradle b/buildSrc/src/main/groovy/dependencies.gradle index 9b87845..e98f911 100644 --- a/buildSrc/src/main/groovy/dependencies.gradle +++ b/buildSrc/src/main/groovy/dependencies.gradle @@ -78,6 +78,9 @@ ext.libraries = [ ] ext { + generatedSourcesDir = file("${buildDir}/generated/sources") + generatedSourcesJavaDir = file("${project.generatedSourcesDir}/main/java") + excludeJunit = { exclude group: 'junit', module: 'junit' } excludeChecker = { exclude group: 'edu.washington.cs.types.checker', module: 'checker-framework' } } diff --git a/buildSrc/src/main/groovy/subproject.gradle b/buildSrc/src/main/groovy/subproject.gradle index a0427aa..69935f6 100644 --- a/buildSrc/src/main/groovy/subproject.gradle +++ b/buildSrc/src/main/groovy/subproject.gradle @@ -117,6 +117,9 @@ java { test { useJUnitPlatform() + minHeapSize = "256m" + maxHeapSize = "2g" + testLogging { displayGranularity = 2 showExceptions = true diff --git a/codecheck/quality.gradle b/codecheck/quality.gradle index cc24fa4..90c6bc2 100644 --- a/codecheck/quality.gradle +++ b/codecheck/quality.gradle @@ -23,8 +23,8 @@ check.dependsOn 'checkstyle', 'jacocoTestCoverageVerification', 'findbugs', 'pmd task jacocoTestCoverageVerification( type: JacocoCoverageVerification, group: 'Verification', - description: 'Jacoco test coverage verification', - dependsOn: 'jacocoTestReport' + description: 'Jacoco test coverage verification' + //dependsOn: 'jacocoTestReport' ) { def jacocoFilter = ['**/BuildConfig.*', '**/*Test*.*', '**/*Exception*.*'] @@ -46,6 +46,40 @@ task jacocoTestCoverageVerification( } } +task codeCoverageReport(type: JacocoReport, group: "Coverage reports") { + executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") + + dependsOn javaProjects*.test + + javaProjects.each { + sourceSets it.sourceSets.main + } + + reports { + xml.enabled = true + xml.destination new File("${buildDir}/reports/jacoco/report.xml") + html.enabled = true + html.destination new File("${buildDir}/reports/jacoco/html") + csv.enabled = false + } + afterEvaluate { + // Exclude generated files from top-level coverage report + classDirectories.setFrom( + files( + classDirectories.files.collect { + fileTree( + dir: it, + exclude: [ + "**/com/netflix/genie/proto/**", + "**/com/netflix/genie/web/data/entities/*_*", + ] + ) + } + ) + ) + } +} + task checkstyle( type: Checkstyle, group: 'Verification', diff --git a/protobuf/build.gradle b/protobuf/build.gradle index 7ee15ca..15e6e59 100644 --- a/protobuf/build.gradle +++ b/protobuf/build.gradle @@ -55,5 +55,26 @@ task sourcesJar(type: Jar, dependsOn: classes) { } compileJava { + options.encoding = 'UTF-8' options.compilerArgs += ["-proc:none"] + options.annotationProcessorGeneratedSourcesDirectory = project.generatedSourcesJavaDir + options.compilerArgs += [ + "-Xlint:unchecked", + "-Xlint:deprecation", + "-proc:none", + "-s", + project.generatedSourcesJavaDir + ] +} + +compileTestJava { + options.encoding = 'UTF-8' + options.compilerArgs += [ + "-Xlint:unchecked", + "-Xlint:deprecation" + ] +} + +javadoc { + options.encoding = 'UTF-8' } From d4bb8b770d56864b00f013583832f0e9c4dd2dbb Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Fri, 5 Feb 2021 02:41:56 +0300 Subject: [PATCH 11/47] docs: updates on documentation Added informational and corporate documentation --- build.gradle | 10 +++++++++- buildSrc/src/main/groovy/dependencies.gradle | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c91db27..197702f 100644 --- a/build.gradle +++ b/build.gradle @@ -39,6 +39,10 @@ repositories { name "Gradle plugins repository" url "https://plugins.gradle.org/m2/" } + maven { + name "IceRockDev gradle plugins repository" + url "https://dl.bintray.com/icerockdev/plugins" + } } allprojects { @@ -136,8 +140,12 @@ subprojects { // guava library dependencies implementation libraries.core.guava - // commons lang library dependencies + // commons library dependencies implementation libraries.core.commons_lang + implementation libraries.core.commons_text + + // javapoet library dependencies + implementation libraries.core.javapoet // lombok library dependencies implementation libraries.core.lombok diff --git a/buildSrc/src/main/groovy/dependencies.gradle b/buildSrc/src/main/groovy/dependencies.gradle index e98f911..8b41f21 100644 --- a/buildSrc/src/main/groovy/dependencies.gradle +++ b/buildSrc/src/main/groovy/dependencies.gradle @@ -11,6 +11,8 @@ ext.projectConfig = [ ext.versions = [ "guava" : "30.1-jre", "commons_lang" : "3.11", + "commons_text" : "1.9", + "javapoet" : "1.13.0", "lombok" : "1.18.16", "assertj" : "3.18.1", "hamcrest" : "2.2", @@ -41,6 +43,8 @@ ext.libraries = [ core: [ "guava" : "com.google.guava:guava:${versions.guava}", "commons_lang" : "org.apache.commons:commons-lang3:${versions.commons_lang}", + "commons_text" : "org.apache.commons:commons-text:${versions.commons_text}", + "javapoet" : "com.squareup:javapoet:${versions.javapoet}", "lombok" : "org.projectlombok:lombok:${versions.lombok}", "javax" : "javax.annotation:javax.annotation-api:${versions.javax}", "thrift" : "org.apache.thrift:libthrift:${versions.thrift}", From 596bf06140699d8f51dca749bfc39f5f8f3284ea Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sat, 6 Feb 2021 15:13:22 +0300 Subject: [PATCH 12/47] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/remove-labels.yml | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/remove-labels.yml diff --git a/.github/workflows/remove-labels.yml b/.github/workflows/remove-labels.yml new file mode 100644 index 0000000..ba74dcc --- /dev/null +++ b/.github/workflows/remove-labels.yml @@ -0,0 +1,53 @@ +name: Remove outdated labels + +on: + pull_request_target: + types: + - closed + issues: + types: + - closed + +jobs: + remove-merged-pr-labels: + name: Remove merged pull request labels + if: github.event.pull_request.merged + runs-on: ubuntu-latest + steps: + - uses: mondeja/remove-labels-gh-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + awaiting reply + changes requested + duplicate + in discussion + invalid + out of scope + pending + won't add + + remove-closed-pr-labels: + name: Remove closed pull request labels + if: github.event_name == 'pull_request_target' && (! github.event.pull_request.merged) + runs-on: ubuntu-latest + steps: + - uses: mondeja/remove-labels-gh-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + in discussion + pending + + remove-closed-issue-labels: + name: Remove closed issue labels + if: github.event.issue.state == 'closed' + runs-on: ubuntu-latest + steps: + - uses: mondeja/remove-labels-gh-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + in discussion + pending + tracking From fd83c8ff90dc49690cfb6c90b164deec192a875e Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sat, 6 Feb 2021 15:17:50 +0300 Subject: [PATCH 13/47] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/add-labels.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/add-labels.yml diff --git a/.github/workflows/add-labels.yml b/.github/workflows/add-labels.yml new file mode 100644 index 0000000..da4328f --- /dev/null +++ b/.github/workflows/add-labels.yml @@ -0,0 +1,13 @@ +name: Pull Request Labeler + +on: + pull_request_target: + types: [ opened ] + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: ericcornelissen/labeler@label-based-on-status + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} From 5f5730ff72208c73d1057b5f3c8181a655c18519 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sat, 6 Feb 2021 15:49:21 +0300 Subject: [PATCH 14/47] docs: updates on documentation Added informational and corporate documentation --- build.gradle | 1 + buildSrc/src/main/groovy/commons.gradle | 8 +++++ buildSrc/src/main/groovy/subproject.gradle | 16 +++++++++ .../findbugs/findbugs-exclude-filter.xml | 27 ++++++++++----- codecheck/pmd/pmd-ruleset.xml | 33 +++++++++++++++++-- codecheck/quality.gradle | 12 +++++-- 6 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 buildSrc/src/main/groovy/commons.gradle diff --git a/build.gradle b/build.gradle index 197702f..02af37e 100644 --- a/build.gradle +++ b/build.gradle @@ -50,6 +50,7 @@ allprojects { apply plugin: 'com.adarshr.test-logger' apply plugin: 'com.diffplug.spotless' apply plugin: 'java' + apply plugin: 'jacoco' repositories { jcenter() diff --git a/buildSrc/src/main/groovy/commons.gradle b/buildSrc/src/main/groovy/commons.gradle new file mode 100644 index 0000000..c1cb23f --- /dev/null +++ b/buildSrc/src/main/groovy/commons.gradle @@ -0,0 +1,8 @@ +task generateReadme { + doFirst { + def readmeFile = new File("${project.rootDir}/README.md") + def content = readmeFile.text + content = content.replaceAll("'co\\.infinum:retromock:.+?'", "'co.infinum:retromock:${versions.retromock}'") + readmeFile.setText(content) + } +} diff --git a/buildSrc/src/main/groovy/subproject.gradle b/buildSrc/src/main/groovy/subproject.gradle index 69935f6..ea25cac 100644 --- a/buildSrc/src/main/groovy/subproject.gradle +++ b/buildSrc/src/main/groovy/subproject.gradle @@ -34,6 +34,10 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat // } //} +jacoco { + toolVersion = "0.8.2" +} + configurations.all { config -> config.resolutionStrategy { cacheChangingModulesFor 0, 'seconds' @@ -141,4 +145,16 @@ test { showSkippedStandardStreams false showFailedStandardStreams true } + + afterSuite { desc, result -> + if (!desc.parent) { + println "\nTest result: ${result.resultType}" + println "Test summary: ${result.testCount} tests, " + + "${result.successfulTestCount} succeeded, " + + "${result.failedTestCount} failed, " + + "${result.skippedTestCount} skipped" + } + } + + finalizedBy jacocoTestReport } diff --git a/codecheck/findbugs/findbugs-exclude-filter.xml b/codecheck/findbugs/findbugs-exclude-filter.xml index 3907bd5..1d2dd22 100644 --- a/codecheck/findbugs/findbugs-exclude-filter.xml +++ b/codecheck/findbugs/findbugs-exclude-filter.xml @@ -1,10 +1,10 @@ + Excluded because of the following issue: + #1403 NP_NONNULL_PARAM_VIOLATION for completedFuture(null) + https://sourceforge.net/p/findbugs/bugs/1403 + --> @@ -27,12 +27,12 @@ + - - - - - + + + + @@ -42,4 +42,13 @@ + + + + + + + + + diff --git a/codecheck/pmd/pmd-ruleset.xml b/codecheck/pmd/pmd-ruleset.xml index 0993f93..cd0652c 100644 --- a/codecheck/pmd/pmd-ruleset.xml +++ b/codecheck/pmd/pmd-ruleset.xml @@ -3,32 +3,38 @@ xmlns="http://pmd.sf.net/ruleset/1.0.0" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"> - Custom ruleset for ribot Android application .*/R.java .*/gen/.* - + + + + + + + + @@ -36,5 +42,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/codecheck/quality.gradle b/codecheck/quality.gradle index 90c6bc2..8ce4fb1 100644 --- a/codecheck/quality.gradle +++ b/codecheck/quality.gradle @@ -86,7 +86,11 @@ task checkstyle( description: 'Runs code style checks' ) { configFile file("$qualityConfigDir/checkstyle/checkstyle.xml") - configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/codecheck/checkstyle/suppressions.xml").absolutePath + //configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/codecheck/checkstyle/suppressions.xml").absolutePath + configProperties = [ + 'checkstyle.cache.file' : rootProject.file('build/checkstyle.cache'), + 'checkstyle.suppression.file': file("${project.rootDir}/codecheck/checkstyle/suppressions.xml") + ] maxWarnings = 0 ignoreFailures = true @@ -109,10 +113,10 @@ task findbugs( description: 'Inspect java bytecode for bugs', dependsOn: ['compileDebugSources', 'compileReleaseSources'] ) { - ignoreFailures = true effort = "max" reportLevel = "high" + maxHeapSize = "512m" excludeFilter = new File("$qualityConfigDir/findbugs/findbugs-exclude-filter.xml") classes = files("$project.rootDir/app/build/intermediates/classes") as DefaultTask @@ -154,3 +158,7 @@ task pmd( html.destination = "$reportsDir/pmd/pmd.html" } } + +findbugsTest { + enabled = false +} From 7adfab5e734de1af7e50c8fee5b8c3775b00e765 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sat, 6 Feb 2021 15:52:38 +0300 Subject: [PATCH 15/47] docs: updates on documentation Added informational and corporate documentation --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 02af37e..d067a99 100644 --- a/build.gradle +++ b/build.gradle @@ -195,6 +195,7 @@ subprojects { manifest { attributes("Automatic-Module-Name": projectConfig.module) + attributes("Build-Date": Instant.now().toString()) attributes("Class-Path": configurations.compile.collect { it.getPath() }.join(' ')) } } From 3ac430e83f49dfbed338938a683410f922ef21d6 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sun, 7 Feb 2021 04:25:57 +0300 Subject: [PATCH 16/47] docs: updates on documentation Added informational and corporate documentation --- buildSrc/src/main/groovy/subproject.gradle | 12 ++++++++++++ protobuf/build.gradle | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/subproject.gradle b/buildSrc/src/main/groovy/subproject.gradle index ea25cac..6ee9504 100644 --- a/buildSrc/src/main/groovy/subproject.gradle +++ b/buildSrc/src/main/groovy/subproject.gradle @@ -1,6 +1,11 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import java.nio.charset.StandardCharsets +import java.time.ZoneOffset +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter + //compileJava { // doFirst { // options.compilerArgs = [ @@ -97,6 +102,13 @@ check.dependsOn functionalTest processResources { duplicatesStrategy = DuplicatesStrategy.INCLUDE + doFirst { + final File file = new File("$buildDir/resources/main/build-date.txt") + if (file.createNewFile()) { + file.text = ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT) + } + } + with copySpec { from 'src/main/resources' include '**/application*.yml' diff --git a/protobuf/build.gradle b/protobuf/build.gradle index 15e6e59..c2f0aed 100644 --- a/protobuf/build.gradle +++ b/protobuf/build.gradle @@ -55,8 +55,9 @@ task sourcesJar(type: Jar, dependsOn: classes) { } compileJava { + options.debug = true options.encoding = 'UTF-8' - options.compilerArgs += ["-proc:none"] + options.debugOptions.debugLevel = 'source,vars,lines' options.annotationProcessorGeneratedSourcesDirectory = project.generatedSourcesJavaDir options.compilerArgs += [ "-Xlint:unchecked", From 9291a04287fdb11446d32fc7ac3cb29a325e9de9 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Tue, 9 Feb 2021 20:47:20 +0300 Subject: [PATCH 17/47] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/pre-merge.yml | 112 ++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/pre-merge.yml diff --git a/.github/workflows/pre-merge.yml b/.github/workflows/pre-merge.yml new file mode 100644 index 0000000..f3efe8d --- /dev/null +++ b/.github/workflows/pre-merge.yml @@ -0,0 +1,112 @@ +name: Pre Merge Checks + +on: + push: + branches: + - master + pull_request: + branches: + - '**' + +jobs: + gradle: + if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + jdk: [ 8, 11, 15 ] + runs-on: ${{ matrix.os }} + env: + JDK_VERSION: ${{ matrix.jdk }} + GRADLE_OPTS: -Dorg.gradle.daemon=false + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + + # Let's cleanup the gradle cache folders to make sure + # we don't accidentally cache stale files. + - name: Cleanup Gradle Folders + shell: bash + run: | + rm -rf ~/.gradle/caches/ && \ + rm -rf ~/.gradle/wrapper/ + + - name: Cache Gradle Folders + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches/ + ~/.gradle/wrapper/ + key: cache-gradle-${{ matrix.os }}-${{ matrix.jdk }}-${{ hashFiles('./build.gradle.kts') }} + restore-keys: | + cache-gradle-${{ matrix.os }}-${{ matrix.jdk }}- + cache-gradle-${{ matrix.os }}- + cache-gradle- + + - name: Setup Java + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.jdk }} + + - name: Build project + run: ./gradlew build --parallel + + verify-generated-config-file: + if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} + runs-on: ubuntu-latest + env: + GRADLE_OPTS: -Dorg.gradle.daemon=false + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + + - name: Cache Gradle Folders + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches/ + ~/.gradle/wrapper/ + key: cache-gradle-ubuntu-latest-14-verifygenerator-${{ hashFiles('./build.gradle.kts') }} + restore-keys: | + cache-gradle-ubuntu-latest-14-verifygenerator- + cache-gradle-ubuntu-latest-14- + cache-gradle-ubuntu-latest- + cache-gradle- + + - name: Setup Java + uses: actions/setup-java@v1 + with: + java-version: 14 + + - name: Verify Generated Config File + run: ./gradlew verify + + compile-test-snippets: + if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} + runs-on: ubuntu-latest + env: + GRADLE_OPTS: -Dorg.gradle.daemon=false + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + + - name: Cache Gradle Folders + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches/ + ~/.gradle/wrapper/ + key: cache-gradle-ubuntu-latest-14-compiletestsnippets-${{ hashFiles('./build.gradle.kts') }} + restore-keys: | + cache-gradle-ubuntu-latest-14-compiletestsnippets- + cache-gradle-ubuntu-latest-14- + cache-gradle-ubuntu-latest- + cache-gradle- + + - name: Setup Java + uses: actions/setup-java@v1 + with: + java-version: 15 + - name: Build and compile test snippets + run: ./gradlew test --build-cache --parallel From e7173961079ecfce818b36353834553413203f06 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Tue, 9 Feb 2021 20:52:25 +0300 Subject: [PATCH 18/47] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/codecoverage.yml | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/codecoverage.yml diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml new file mode 100644 index 0000000..5ffeb64 --- /dev/null +++ b/.github/workflows/codecoverage.yml @@ -0,0 +1,33 @@ +name: Code Coverage + +on: + push: + branches: + - master + pull_request: + branches: + - '**' + +jobs: + publish-code-coverage: + if: ${{ !contains(github.event.head_commit.message, 'coverage skip') }} + runs-on: ubuntu-latest + env: + JDK_VERSION: ${{ matrix.jdk }} + GRADLE_OPTS: -Dorg.gradle.daemon=false + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + + - name: Setup Java + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Generate Coverage Report + run: ./gradlew jacocoTestReport -Dorg.gradle.caching=false + + - name: Publish Coverage + if: success() + run: bash <(curl -s https://codecov.io/bash) + shell: bash From 82fd898c7d2937f0bd2feff9ea42afb67dc022a0 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Wed, 10 Feb 2021 14:05:35 +0300 Subject: [PATCH 19/47] docs: updates on documentation Added informational and corporate documentation --- build.gradle | 3 + .../src/main/groovy/maven-metadata.gradle | 21 +++++ docker/docker-compose.yml | 78 +++++++++++++++++++ docker/flyway/Dockerfile | 9 +++ docker/flyway/scripts/wait-for-db.sh | 22 ++++++ docker/pgadmin/passfile.txt | 2 + docker/pgadmin/servers.json | 14 ++++ docker/postgres/Dockerfile | 36 +++++++++ .../postgres/scripts/postgres_init_config.sh | 14 ++++ docker/postgres/scripts/postgres_init_user.sh | 15 ++++ 10 files changed, 214 insertions(+) create mode 100644 buildSrc/src/main/groovy/maven-metadata.gradle create mode 100644 docker/docker-compose.yml create mode 100644 docker/flyway/Dockerfile create mode 100644 docker/flyway/scripts/wait-for-db.sh create mode 100644 docker/pgadmin/passfile.txt create mode 100644 docker/pgadmin/servers.json create mode 100644 docker/postgres/Dockerfile create mode 100644 docker/postgres/scripts/postgres_init_config.sh create mode 100644 docker/postgres/scripts/postgres_init_user.sh diff --git a/build.gradle b/build.gradle index d067a99..13f6bad 100644 --- a/build.gradle +++ b/build.gradle @@ -106,6 +106,8 @@ allprojects { kotlin { target '**/*.kt' ktlint() + trimTrailingWhitespace() + endWithNewline() } } } @@ -192,6 +194,7 @@ subprojects { jar { from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + //from { configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) } } manifest { attributes("Automatic-Module-Name": projectConfig.module) diff --git a/buildSrc/src/main/groovy/maven-metadata.gradle b/buildSrc/src/main/groovy/maven-metadata.gradle new file mode 100644 index 0000000..fb5359d --- /dev/null +++ b/buildSrc/src/main/groovy/maven-metadata.gradle @@ -0,0 +1,21 @@ +ext.pomConfig = { + licenses { + license { + name "The Apache Software License, Version 2.0" + url "http://www.apache.org/licenses/LICENSE-2.0.txt" + distribution "repo" + } + } + developers { + developer { + id "AlexRogalskiy" + name "Alexander Rogalskiy" + organization "nullables.io" + organizationUrl "https://www.nullables.io" + } + } + + scm { + url "https://github.com/AlexRogalskiy/gradle-java-sample" + } +} diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..e9792ab --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,78 @@ +version: '3.9' + +services: + postgresql: + build: + context: postgres + dockerfile: Dockerfile + container_name: test-postgres + shm_size: 256mb + healthcheck: + test: [ "CMD-SHELL", "pg_isready", "-q", "-U", "$POSTGRES_USER", "d", "$POSTGRES_DB" ] + start_period: 10s + interval: 10s + timeout: 10s + retries: 5 + volumes: + - "./postgres/scripts:/docker-entrypoint-initdb.d/" + expose: + - 5432 + ports: + - "${POSTGRES_SERVER_PORT:-15432}:5432" + environment: + TZ: Europe/Moscow + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + POSTGRES_INITDB_ARGS: "--no-sync" + restart: unless-stopped + networks: + backend-network: + ipv4_address: 172.20.128.2 + + pgadmin: + image: dpage/pgadmin4:latest + container_name: test-pgadmin + environment: + PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL:-admin@admin.com} + PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD:-admin} + PGADMIN_SERVER_JSON_FILE: /pgadmin4/config/servers.json + PGADMIN_LISTEN_PORT: ${PGADMIN_PORT:-8081} + ports: + - "${PGADMIN_SERVER_PORT:-8081}:8081" + volumes: + - "./pgadmin:/pgadmin4/config" + depends_on: + - postgresql + restart: unless-stopped + networks: + backend-network: + ipv4_address: 172.20.128.3 + + flyway: + build: + context: flyway + dockerfile: Dockerfile + container_name: test-flyway + command: migrate + entrypoint: [ "bash", "/flyway/bin/wait-for-db.sh", "172.20.128.2", "5432", "test", "5", "--", "flyway" ] + environment: + FLYWAY_URL: jdbc:postgresql://172.20.128.2:5432/postgres?sslMode=disable + FLYWAY_USER: test + FLYWAY_PASSWORD: test + FLYWAY_LOCATIONS: filesystem:/flyway/sql + volumes: + - "../db-schema/src/main/resources/flyway/conf/flyway-local.conf:/flyway/conf/flyway.conf" + - "../db-schema/src/main/resources/db/migration:/flyway/sql" + depends_on: + - postgresql + networks: + backend-network: + ipv4_address: 172.20.128.4 + +networks: + backend-network: + ipam: + config: + - subnet: 172.20.0.0/16 + gateway: 172.20.128.1 diff --git a/docker/flyway/Dockerfile b/docker/flyway/Dockerfile new file mode 100644 index 0000000..664937d --- /dev/null +++ b/docker/flyway/Dockerfile @@ -0,0 +1,9 @@ +FROM boxfuse/flyway:latest + +RUN apt-get update && \ + apt-get install -y postgresql-client && \ + mkdir /flyway/bin + +ADD scripts/wait-for-db.sh /flyway/bin/wait-for-db.sh + +RUN chmod 755 /flyway/bin/wait-for-db.sh \ No newline at end of file diff --git a/docker/flyway/scripts/wait-for-db.sh b/docker/flyway/scripts/wait-for-db.sh new file mode 100644 index 0000000..eb68305 --- /dev/null +++ b/docker/flyway/scripts/wait-for-db.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o nounset + +db_host="$1" +shift +db_port="$1" +shift +db_name="$1" +shift +db_retry="$1" +shift +cmd="$@" + +until PGPASSWORD=$FLYWAY_PASSWORD /usr/bin/psql --quiet --host "$db_host" --port "$db_port" --dbname "$db_name" --username "$FLYWAY_USER" --command "SELECT 1;" >/dev/null 2>&1 || [ $db_retry -eq 0 ]; do + echo "==> $(date): Retry #$((db_retry -= 1)) while connecting to database <$db_name> on host <$db_host> with port <$db_port>..." + sleep 1 +done + +echo "Database <"$db_name"> on host <$db_host> with port <$db_port> is up and running" +exec $cmd diff --git a/docker/pgadmin/passfile.txt b/docker/pgadmin/passfile.txt new file mode 100644 index 0000000..0a81edd --- /dev/null +++ b/docker/pgadmin/passfile.txt @@ -0,0 +1,2 @@ +# hostname:port:database:username:password +172.20.128.2:5432:test:test:test diff --git a/docker/pgadmin/servers.json b/docker/pgadmin/servers.json new file mode 100644 index 0000000..c94fcf9 --- /dev/null +++ b/docker/pgadmin/servers.json @@ -0,0 +1,14 @@ +{ + "Servers": { + "1": { + "Name": "test-db", + "Group": "Servers", + "Port": 5432, + "Username": "test", + "Host": "172.20.128.2", + "SSLMode": "disable", + "MaintenanceDB": "postgres", + "PassFile": "/pgadmin4/config/passfile.txt" + } + } +} diff --git a/docker/postgres/Dockerfile b/docker/postgres/Dockerfile new file mode 100644 index 0000000..2884df4 --- /dev/null +++ b/docker/postgres/Dockerfile @@ -0,0 +1,36 @@ +## example Dockerfile for https://docs.docker.com/engine/examples/postgresql_service/ +FROM postgres:12.0 + +## Updating dependencies list +RUN apt-get update + +## Installing build dependencies +RUN apt-get install unzip && apt-get --assume-yes install build-essential wget + +## Installing certificate dependencies +RUN apt-get install ca-certificates + +## Installing postgresql dependencies +RUN apt-get --assume-yes install postgresql-server-dev-12 + +## Installing ip4r extension +RUN apt-get install postgresql-12-ip4r + +## Installing jobmon extension +RUN wget --no-check-certificate https://github.com/omniti-labs/pg_jobmon/archive/v1.3.3.zip -O pg_jobmon-1.3.3.zip \ + && unzip pg_jobmon-1.3.3.zip \ + && cd /pg_jobmon-1.3.3 && make && make install + +## Installing partman extension +RUN wget --no-check-certificate https://github.com/pgpartman/pg_partman/archive/v4.4.1.zip -O pg_partman-4.4.1.zip \ + && unzip pg_partman-4.4.1.zip \ + && cd /pg_partman-4.4.1 && pwd && make install && make NO_BGW=1 install + +## Running the rest of the commands as the ``postgres`` user created by the "postgres-12" package +USER postgres + +## Exposing the PostgreSQL port +EXPOSE 5432 + +## Adding VOLUMEs to allow backup of config, logs and databases +VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"] \ No newline at end of file diff --git a/docker/postgres/scripts/postgres_init_config.sh b/docker/postgres/scripts/postgres_init_config.sh new file mode 100644 index 0000000..b06a1f6 --- /dev/null +++ b/docker/postgres/scripts/postgres_init_config.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# setting non-durable options +# https://www.postgresql.org/docs/current/static/non-durability.html +echo "Configuring postgres non-durable options." +# no need to flush data to disk. +echo "fsync = off" >>/var/lib/postgresql/data/postgresql.conf +# no need to force WAL writes to disk on every commit. +echo "synchronous_commit = off" >>/var/lib/postgresql/data/postgresql.conf +# no need to guard against partial page writes. +echo "full_page_writes = off" >>/var/lib/postgresql/data/postgresql.conf +# increase checkpoint interval +echo "checkpoint_timeout = 3600" >>/var/lib/postgresql/data/postgresql.conf +echo "max_wal_size = 128" >>/var/lib/postgresql/data/postgresql.conf diff --git a/docker/postgres/scripts/postgres_init_user.sh b/docker/postgres/scripts/postgres_init_user.sh new file mode 100644 index 0000000..853982f --- /dev/null +++ b/docker/postgres/scripts/postgres_init_user.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o nounset + +function initialize_db() { + echo "Initializing default database with user " + PGPASSWORD=$POSTGRES_PASSWORD /usr/bin/psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE USER test WITH SUPERUSER PASSWORD 'test'; + CREATE DATABASE test; + GRANT ALL PRIVILEGES ON DATABASE test TO test; +EOSQL +} + +initialize_db From 213d07652e39574cd6f23903eb13ad47987006d2 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Fri, 26 Feb 2021 15:51:58 +0300 Subject: [PATCH 20/47] docs: updates on documentation Added informational and corporate documentation --- build.gradle | 89 +++++++++++++++++++++++-------------------- buildSrc/build.gradle | 3 ++ 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index 13f6bad..9425605 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,16 @@ plugins { - id("com.github.ben-manes.versions") - id("com.github.johnrengelman.shadow") - id("com.adarshr.test-logger") version "2.1.1" - id("com.diffplug.spotless") version "5.9.0" - id("com.gorylenko.gradle-git-properties") version "2.2.4" - id("io.franzbecker.gradle-lombok") version "4.0.0" - - id("org.sonarqube") - id("java") - id("maven") - id("checkstyle") - id("java-gradle-plugin") + id('com.github.ben-manes.versions') + id('com.github.johnrengelman.shadow') + id('com.adarshr.test-logger') version '2.1.1' + id('com.diffplug.spotless') version '5.9.0' + id('com.gorylenko.gradle-git-properties') version '2.2.4' + id('io.franzbecker.gradle-lombok') version '4.0.0' + + id('org.sonarqube') + id('java') + id('maven') + id('checkstyle') + id('java-gradle-plugin') } repositories { @@ -20,32 +20,33 @@ repositories { jcenter() maven { - name "Artifactory repository" - url "https://oss.jfrog.org/artifactory/oss-snapshot-local/" + name 'Artifactory repository' + url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' } maven { - name "Jitpack repository" + name 'Jitpack repository' url 'https://jitpack.io' } maven { - name "JCenter gradle plugins repository" - url "https://dl.bintray.com/gradle/gradle-plugins" + name 'JCenter gradle plugins repository' + url 'https://dl.bintray.com/gradle/gradle-plugins' } maven { - name "Sonatype snapshots repository" - url "https://oss.sonatype.org/content/repositories/snapshots/" + name 'Sonatype snapshots repository' + url 'https://oss.sonatype.org/content/repositories/snapshots/' } maven { - name "Gradle plugins repository" - url "https://plugins.gradle.org/m2/" + name 'Gradle plugins repository' + url 'https://plugins.gradle.org/m2/' } maven { - name "IceRockDev gradle plugins repository" - url "https://dl.bintray.com/icerockdev/plugins" + name 'IceRockDev gradle plugins repository' + url 'https://dl.bintray.com/icerockdev/plugins' } } allprojects { + apply plugin: 'io.github.robwin.jgitflow' apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.adarshr.test-logger' apply plugin: 'com.diffplug.spotless' @@ -57,12 +58,12 @@ allprojects { mavenCentral() maven { - name "KotlinX repository" - url "https://kotlin.bintray.com/kotlinx" + name 'KotlinX repository' + url 'https://kotlin.bintray.com/kotlinx' } maven { - name "Artifactory repository" - url "https://oss.jfrog.org/artifactory/oss-snapshot-local/" + name 'Artifactory repository' + url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' } } @@ -77,12 +78,18 @@ allprojects { gitProperties { failOnNoGitDirectory = false dateFormat = "yyyy-MM-dd'T'HH:mmZ" - dateFormatTimeZone = "PST" + dateFormatTimeZone = 'PST' } def buildProperties = new Properties() - file(rootDir.absolutePath + "/build.properties").withInputStream { buildProperties.load(it) } - if (buildProperties.getProperty("build.debug").toBoolean()) { + file(rootDir.absolutePath + '/build.properties').withInputStream { buildProperties.load(it) } + if (buildProperties.getProperty('build.debug').toBoolean()) { + + initJGitflow { + feature = "features/" + release = "releases/" + versiontag = 'v' + } testlogger { theme 'mocha' @@ -181,12 +188,12 @@ subprojects { dependencyUpdates.resolutionStrategy { componentSelection { rules -> rules.all { ComponentSelection selection -> - boolean rejected = ["alpha", "beta", "rc", "cr", "m", "preview", "b", "ea", "snapshot"].any { + boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview', 'b', 'ea', 'snapshot'].any { qualifier -> selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-+]*/ } if (rejected) { - selection.reject("Release candidate") + selection.reject('Release candidate') } } } @@ -194,12 +201,12 @@ subprojects { jar { from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } - //from { configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) } } + //from { configurations.runtimeClasspath.get().filter { it.name.endsWith('jar') }.map { zipTree(it) } } manifest { - attributes("Automatic-Module-Name": projectConfig.module) - attributes("Build-Date": Instant.now().toString()) - attributes("Class-Path": configurations.compile.collect { it.getPath() }.join(' ')) + attributes('Automatic-Module-Name': projectConfig.module) + attributes('Build-Date': Instant.now().toString()) + attributes('Class-Path': configurations.compile.collect { it.getPath() }.join(' ')) } } } @@ -207,18 +214,18 @@ subprojects { task stage(dependsOn: ['clean']) task copyToLib(type: Copy) { - from "$buildDir/libs" - into "$rootProject.buildDir/libs" + from '$buildDir/libs' + into '$rootProject.buildDir/libs' } copyToLib.dependsOn(stage) stage.dependsOn(copyToLib) task copyLicense { - outputs.file new File("$buildDir/LICENSE") + outputs.file new File('$buildDir/LICENSE') doLast { copy { - from "LICENSE" - into "$buildDir" + from 'LICENSE' + into '$buildDir' } } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index fbafdcf..4601b1e 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -8,6 +8,7 @@ repositories { ext.versions = [ "github_release" : "2.2.12", + "jgitflow" : "0.6.0", "gradle_shadow" : "5.2.0", "gradle_versions" : "0.28.0", "gradle_sonarqube": "2.8", @@ -17,6 +18,7 @@ ext.versions = [ ] ext.deps = [ "github_release" : "com.github.breadmoirai:github-release:${versions.github_release}", + "jgitflow" : "io.github.robwin:jgitflow-gradle-plugin:${versions.jgitflow}", "gradle_shadow" : "com.github.jengelman.gradle.plugins:shadow:${versions.gradle_shadow}", "gradle_versions" : "com.github.ben-manes:gradle-versions-plugin:${versions.gradle_versions}", "gradle_sonarqube": "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${versions.gradle_sonarqube}", @@ -26,6 +28,7 @@ ext.deps = [ ] dependencies { + implementation deps.jgitflow implementation deps.github_release implementation deps.gradle_shadow implementation deps.gradle_versions From 08231d181bec9368a4e266b3387ed3d36bc25838 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Fri, 26 Feb 2021 16:30:46 +0300 Subject: [PATCH 21/47] docs: updates on documentation Added informational and corporate documentation --- .travis.yml | 3 ++ build.gradle | 40 ++++++++++++++++++---- buildSrc/build.gradle | 23 ++++++++----- buildSrc/src/main/groovy/subproject.gradle | 3 +- 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd30cd0..b7b51b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,9 @@ script: after_success: - if [ -n "$CODECOV_ENABLED" ]; then bash <(curl -s --retry 5 --retry-delay 2 --connect-timeout 2 https://codecov.io/bash) -t $CODECOV_TOKEN; fi +# - ./gradlew cobertura coveralls + - ./gradlew jacocoTestReport coveralls +# - ./gradlew pitest coveralls after_failure: - cat hs_err* diff --git a/build.gradle b/build.gradle index 9425605..f7c7bb3 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,9 @@ plugins { id('com.diffplug.spotless') version '5.9.0' id('com.gorylenko.gradle-git-properties') version '2.2.4' id('io.franzbecker.gradle-lombok') version '4.0.0' + id('info.solidsoft.pitest') version '1.5.2' + id('jacoco') id('org.sonarqube') id('java') id('maven') @@ -46,7 +48,9 @@ repositories { } allprojects { + apply plugin: 'info.solidsoft.pitest' apply plugin: 'io.github.robwin.jgitflow' + apply plugin: 'com.github.kt3k.coveralls' apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.adarshr.test-logger' apply plugin: 'com.diffplug.spotless' @@ -67,13 +71,31 @@ allprojects { } } -// jacocoTestReport { -// reports { -// html.enabled = true -// xml.enabled = true -// csv.enabled = false -// } -// } + pitest { + threads.set(4) + outputFormats.set(['XML', 'HTML']) + timestampedReports.set(false) + + junit5PluginVersion.set('0.12') + + testSourceSets.set([sourceSets.test]) //sourceSets.integrationTest + mainSourceSets.set([sourceSets.main]) //sourceSets.additionalMain + jvmArgs.set(['-Xmx1024m', '-Dspring.test.constructor.autowire.mode=all']) + useClasspathFile.set(true) //useful with bigger projects on Windows + fileExtensionsToFilter.addAll('xml', 'orbit') + + if (project.name in ['appflow', 'avro', 'codecheck', 'db-schema', 'flatbuffers', 'protobuf', 'thrift', 'testflow']) { + failWhenNoMutations.set(false) + } + } + + jacocoTestReport { + reports { + html.enabled = true + xml.enabled = true + csv.enabled = false + } + } gitProperties { failOnNoGitDirectory = false @@ -85,6 +107,10 @@ allprojects { file(rootDir.absolutePath + '/build.properties').withInputStream { buildProperties.load(it) } if (buildProperties.getProperty('build.debug').toBoolean()) { + coveralls { + jacocoReportPath 'build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml' + } + initJGitflow { feature = "features/" release = "releases/" diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 4601b1e..70f706a 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -7,18 +7,22 @@ repositories { } ext.versions = [ - "github_release" : "2.2.12", - "jgitflow" : "0.6.0", - "gradle_shadow" : "5.2.0", - "gradle_versions" : "0.28.0", - "gradle_sonarqube": "2.8", - "gradle_dokka" : "1.4.10", - "semver4j" : "3.1.0", - "gradle_nexus" : "0.22.0" + 'github_release' : '2.2.12', + 'pitest' : '1.5.2', + 'coveralls' : '2.8.3', + 'jgitflow' : '0.6.0', + 'gradle_shadow' : '5.2.0', + 'gradle_versions' : '0.28.0', + 'gradle_sonarqube': '2.8', + 'gradle_dokka' : '1.4.10', + 'semver4j' : '3.1.0', + 'gradle_nexus' : '0.22.0' ] ext.deps = [ "github_release" : "com.github.breadmoirai:github-release:${versions.github_release}", - "jgitflow" : "io.github.robwin:jgitflow-gradle-plugin:${versions.jgitflow}", + "pitest" : "info.solidsoft.gradle.pitest:gradle-pitest-plugin:${versions.pitest}", + "coveralls" : "org.kt3k.gradle.plugin:coveralls-gradle-plugin:${versions.coveralls}", + "jgitflow" : "io.github.robwin:jgitflow-gradle-plugin:${versions.jgitflow}", "gradle_shadow" : "com.github.jengelman.gradle.plugins:shadow:${versions.gradle_shadow}", "gradle_versions" : "com.github.ben-manes:gradle-versions-plugin:${versions.gradle_versions}", "gradle_sonarqube": "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${versions.gradle_sonarqube}", @@ -28,6 +32,7 @@ ext.deps = [ ] dependencies { + implementation deps.coveralls implementation deps.jgitflow implementation deps.github_release implementation deps.gradle_shadow diff --git a/buildSrc/src/main/groovy/subproject.gradle b/buildSrc/src/main/groovy/subproject.gradle index 6ee9504..198d706 100644 --- a/buildSrc/src/main/groovy/subproject.gradle +++ b/buildSrc/src/main/groovy/subproject.gradle @@ -1,7 +1,6 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import java.nio.charset.StandardCharsets import java.time.ZoneOffset import java.time.ZonedDateTime import java.time.format.DateTimeFormatter @@ -136,6 +135,8 @@ test { minHeapSize = "256m" maxHeapSize = "2g" + systemProperty 'spring.test.constructor.autowire.mode', 'all' + testLogging { displayGranularity = 2 showExceptions = true From 891ce010ab3c94dc8d1b6ba52d01f70e62678bec Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Fri, 26 Feb 2021 18:57:23 +0300 Subject: [PATCH 22/47] docs: updates on documentation Added informational and corporate documentation --- build.gradle | 171 +++---- buildSrc/build.gradle | 32 +- buildSrc/src/main/groovy/dependencies.gradle | 11 +- buildSrc/src/main/groovy/detekt.gradle | 2 +- codecheck/build.gradle | 188 ++++++++ codecheck/checkstyle/checkstyle-custom.xsl | 83 ++++ codecheck/findbugs/findbugs-custom.xsl | 465 +++++++++++++++++++ codecheck/quality.gradle | 164 ------- codequality/detekt.yml | 21 + gradle.properties | 30 +- settings.gradle | 20 +- 11 files changed, 908 insertions(+), 279 deletions(-) create mode 100644 codecheck/build.gradle create mode 100644 codecheck/checkstyle/checkstyle-custom.xsl create mode 100644 codecheck/findbugs/findbugs-custom.xsl delete mode 100644 codecheck/quality.gradle create mode 100644 codequality/detekt.yml diff --git a/build.gradle b/build.gradle index f7c7bb3..9683b2b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,20 @@ +import com.vanniktech.dependency.graph.generator.DependencyGraphGeneratorExtension + plugins { - id('com.github.ben-manes.versions') - id('com.github.johnrengelman.shadow') - id('com.adarshr.test-logger') version '2.1.1' - id('com.diffplug.spotless') version '5.9.0' - id('com.gorylenko.gradle-git-properties') version '2.2.4' - id('io.franzbecker.gradle-lombok') version '4.0.0' - id('info.solidsoft.pitest') version '1.5.2' - - id('jacoco') - id('org.sonarqube') - id('java') - id('maven') - id('checkstyle') - id('java-gradle-plugin') + id("com.github.ben-manes.versions") + id("com.github.johnrengelman.shadow") + id("com.adarshr.test-logger") version "2.1.1" + id("com.diffplug.spotless") version "5.9.0" +// id("com.gorylenko.gradle-git-properties") version "2.2.4" + id("io.franzbecker.gradle-lombok") version "4.0.0" + id("info.solidsoft.pitest") version "1.5.2" + + id("jacoco") + id("org.sonarqube") + id("java") + id("maven") + id("checkstyle") + id("java-gradle-plugin") } repositories { @@ -22,69 +24,70 @@ repositories { jcenter() maven { - name 'Artifactory repository' - url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' + name "Artifactory repository" + url "https://oss.jfrog.org/artifactory/oss-snapshot-local/" } maven { - name 'Jitpack repository' - url 'https://jitpack.io' + name "Jitpack repository" + url "https://jitpack.io" } maven { - name 'JCenter gradle plugins repository' - url 'https://dl.bintray.com/gradle/gradle-plugins' + name "JCenter gradle plugins repository" + url "https://dl.bintray.com/gradle/gradle-plugins" } maven { - name 'Sonatype snapshots repository' - url 'https://oss.sonatype.org/content/repositories/snapshots/' + name "Sonatype snapshots repository" + url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { - name 'Gradle plugins repository' - url 'https://plugins.gradle.org/m2/' + name "Gradle plugins repository" + url "https://plugins.gradle.org/m2/" } maven { - name 'IceRockDev gradle plugins repository' - url 'https://dl.bintray.com/icerockdev/plugins' + name "IceRockDev gradle plugins repository" + url "https://dl.bintray.com/icerockdev/plugins" } } allprojects { - apply plugin: 'info.solidsoft.pitest' - apply plugin: 'io.github.robwin.jgitflow' - apply plugin: 'com.github.kt3k.coveralls' - apply plugin: 'com.github.johnrengelman.shadow' - apply plugin: 'com.adarshr.test-logger' - apply plugin: 'com.diffplug.spotless' - apply plugin: 'java' - apply plugin: 'jacoco' + apply plugin: "com.vanniktech.dependency.graph.generator" + apply plugin: "info.solidsoft.pitest" + apply plugin: "io.github.robwin.jgitflow" +// apply plugin: "com.github.kt3k.coveralls" + apply plugin: "com.github.johnrengelman.shadow" + apply plugin: "com.adarshr.test-logger" + apply plugin: "com.diffplug.spotless" + apply plugin: "java" + apply plugin: "jacoco" repositories { jcenter() mavenCentral() maven { - name 'KotlinX repository' - url 'https://kotlin.bintray.com/kotlinx' + name "KotlinX repository" + url "https://kotlin.bintray.com/kotlinx" } maven { - name 'Artifactory repository' - url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' + name "Artifactory repository" + url "https://oss.jfrog.org/artifactory/oss-snapshot-local/" } } pitest { threads.set(4) - outputFormats.set(['XML', 'HTML']) + outputFormats.set(["XML", "HTML"]) timestampedReports.set(false) - junit5PluginVersion.set('0.12') + junit5PluginVersion.set("0.12") testSourceSets.set([sourceSets.test]) //sourceSets.integrationTest mainSourceSets.set([sourceSets.main]) //sourceSets.additionalMain - jvmArgs.set(['-Xmx1024m', '-Dspring.test.constructor.autowire.mode=all']) + jvmArgs.set(["-Xmx1024m", "-Dspring.test.constructor.autowire.mode=all"]) useClasspathFile.set(true) //useful with bigger projects on Windows - fileExtensionsToFilter.addAll('xml', 'orbit') + fileExtensionsToFilter.addAll("xml", "orbit") - if (project.name in ['appflow', 'avro', 'codecheck', 'db-schema', 'flatbuffers', 'protobuf', 'thrift', 'testflow']) { + if (project.name in ["appflow", "avro", "codecheck", "db-schema", "flatbuffers", "protobuf", "thrift", "testflow"]) { failWhenNoMutations.set(false) } } @@ -97,47 +100,51 @@ allprojects { } } - gitProperties { - failOnNoGitDirectory = false - dateFormat = "yyyy-MM-dd'T'HH:mmZ" - dateFormatTimeZone = 'PST' - } +// gitProperties { +// failOnNoGitDirectory = false +// dateFormat = "yyyy-MM-dd'T'HH:mmZ" +// dateFormatTimeZone = "PST" +// } def buildProperties = new Properties() - file(rootDir.absolutePath + '/build.properties').withInputStream { buildProperties.load(it) } - if (buildProperties.getProperty('build.debug').toBoolean()) { + file(rootDir.absolutePath + "/build.properties").withInputStream { buildProperties.load(it) } + if (buildProperties.getProperty("build.debug").toBoolean()) { - coveralls { - jacocoReportPath 'build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml' + dependencyGraphGenerator { + generators = [DependencyGraphGeneratorExtension.Generator.ALL] } +// coveralls { +// jacocoReportPath "build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" +// } + initJGitflow { feature = "features/" release = "releases/" - versiontag = 'v' + versiontag = "v" } testlogger { - theme 'mocha' + theme "mocha" slowThreshold 5000 } spotless { - format 'misc', { - target '**/*.gradle', '**/*.md', '**/.gitignore' - targetExclude 'docs/**' + format "misc", { + target "**/*.gradle", "**/*.md", "**/.gitignore" + targetExclude "docs/**" trimTrailingWhitespace() indentWithSpaces() endWithNewline() } java { - target 'build/**/*.java' - targetExclude '**/avro/*.java', 'flatbuffers/**/*.java', 'thrift/**/*.java', '**/protobuf/*.java' + target "build/**/*.java" + targetExclude "**/avro/*.java", "flatbuffers/**/*.java", "thrift/**/*.java", "**/protobuf/*.java" googleJavaFormat().aosp() } kotlin { - target '**/*.kt' + target "**/*.kt" ktlint() trimTrailingWhitespace() endWithNewline() @@ -147,12 +154,12 @@ allprojects { } subprojects { - apply from: rootProject.file('buildSrc/src/main/groovy/setup.gradle') - apply from: rootProject.file('buildSrc/src/main/groovy/dependencies.gradle') - apply from: rootProject.file('buildSrc/src/main/groovy/subproject.gradle') + apply from: rootProject.file("buildSrc/src/main/groovy/setup.gradle") + apply from: rootProject.file("buildSrc/src/main/groovy/dependencies.gradle") + apply from: rootProject.file("buildSrc/src/main/groovy/subproject.gradle") - apply plugin: 'java' - apply plugin: 'groovy' + apply plugin: "java" + apply plugin: "groovy" group projectConfig.group version projectConfig.version @@ -171,7 +178,7 @@ subprojects { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(dir: "libs", include: ["*.jar"]) // guava library dependencies implementation libraries.core.guava @@ -214,12 +221,12 @@ subprojects { dependencyUpdates.resolutionStrategy { componentSelection { rules -> rules.all { ComponentSelection selection -> - boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview', 'b', 'ea', 'snapshot'].any { + boolean rejected = ["alpha", "beta", "rc", "cr", "m", "preview", "b", "ea", "snapshot"].any { qualifier -> selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-+]*/ } if (rejected) { - selection.reject('Release candidate') + selection.reject("Release candidate") } } } @@ -227,31 +234,39 @@ subprojects { jar { from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } - //from { configurations.runtimeClasspath.get().filter { it.name.endsWith('jar') }.map { zipTree(it) } } + //from { configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) } } manifest { - attributes('Automatic-Module-Name': projectConfig.module) - attributes('Build-Date': Instant.now().toString()) - attributes('Class-Path': configurations.compile.collect { it.getPath() }.join(' ')) + attributes("Automatic-Module-Name": projectConfig.module) + attributes("Built-By": "Robert Winkler") + attributes("Build-Date": Instant.now().toString()) + attributes("Build-Date": project.buildDate) + attributes("Build-Time": project.buildTime) + attributes("Specification-Title": projectConfig.module) + attributes("Specification-Version": project.version) + attributes("Implementation-Title": projectConfig.module) + attributes("Implementation-Version": project.version) + attributes("Created-By": projectConfig.vendor) + attributes("Class-Path": configurations.compile.collect { it.getPath() }.join(" ")) } } } -task stage(dependsOn: ['clean']) +task stage(dependsOn: ["clean"]) task copyToLib(type: Copy) { - from '$buildDir/libs' - into '$rootProject.buildDir/libs' + from "$buildDir/libs" + into "$rootProject.buildDir/libs" } copyToLib.dependsOn(stage) stage.dependsOn(copyToLib) task copyLicense { - outputs.file new File('$buildDir/LICENSE') + outputs.file new File("$buildDir/LICENSE") doLast { copy { - from 'LICENSE' - into '$buildDir' + from "LICENSE" + into "$buildDir" } } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 70f706a..c041722 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'java' +apply plugin: "java" repositories { mavenLocal() // used to publish and test local gradle plugin changes @@ -7,18 +7,24 @@ repositories { } ext.versions = [ - 'github_release' : '2.2.12', - 'pitest' : '1.5.2', - 'coveralls' : '2.8.3', - 'jgitflow' : '0.6.0', - 'gradle_shadow' : '5.2.0', - 'gradle_versions' : '0.28.0', - 'gradle_sonarqube': '2.8', - 'gradle_dokka' : '1.4.10', - 'semver4j' : '3.1.0', - 'gradle_nexus' : '0.22.0' + "findbugs" : "3.0.1", + "spotbugs" : "4.6.2", + "github_release" : "2.2.12", + "gradle_graph" : "0.5.0", + "pitest" : "1.5.2", + "coveralls" : "2.8.3", + "jgitflow" : "0.6.0", + "gradle_shadow" : "5.2.0", + "gradle_versions" : "0.28.0", + "gradle_sonarqube": "2.8", + "gradle_dokka" : "1.4.10", + "semver4j" : "3.1.0", + "gradle_nexus" : "0.22.0" ] ext.deps = [ + "findbugs" : "com.google.code.findbugs:findbugs:${versions.findbugs}", + "spotbugs" : "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:${versions.spotbugs}", + "gradle_graph" : "com.vanniktech:gradle-dependency-graph-generator-plugin:${versions.gradle_graph}", "github_release" : "com.github.breadmoirai:github-release:${versions.github_release}", "pitest" : "info.solidsoft.gradle.pitest:gradle-pitest-plugin:${versions.pitest}", "coveralls" : "org.kt3k.gradle.plugin:coveralls-gradle-plugin:${versions.coveralls}", @@ -32,7 +38,9 @@ ext.deps = [ ] dependencies { - implementation deps.coveralls + implementation deps.spotbugs + implementation deps.gradle_graph +// implementation deps.coveralls implementation deps.jgitflow implementation deps.github_release implementation deps.gradle_shadow diff --git a/buildSrc/src/main/groovy/dependencies.gradle b/buildSrc/src/main/groovy/dependencies.gradle index 8b41f21..b855e7c 100644 --- a/buildSrc/src/main/groovy/dependencies.gradle +++ b/buildSrc/src/main/groovy/dependencies.gradle @@ -1,11 +1,16 @@ +import java.text.SimpleDateFormat + ext.projectConfig = [ "group" : 'io.nullables.api.sample', "version" : '1.0.0-SNAPSHOT', "module" : "gradle-java-sample", "description" : "Gradle java sample project", + "url" : "https://github.com/AlexRogalskiy/gradle-java-sample", + "license" : "GPL-3.0", "sourceCompatibility": JavaVersion.VERSION_1_8, "targetCompatibility": JavaVersion.VERSION_1_8, - "projectBuildDir" : "${rootProject.buildDir}/${project.name}" + "projectBuildDir" : "${rootProject.buildDir}/${project.name}", + "vendor" : System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")" ] ext.versions = [ @@ -82,6 +87,10 @@ ext.libraries = [ ] ext { + final Date buildTimeAndDate = new Date() + buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate) + buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate) + generatedSourcesDir = file("${buildDir}/generated/sources") generatedSourcesJavaDir = file("${project.generatedSourcesDir}/main/java") diff --git a/buildSrc/src/main/groovy/detekt.gradle b/buildSrc/src/main/groovy/detekt.gradle index e76aca8..ed7e11c 100644 --- a/buildSrc/src/main/groovy/detekt.gradle +++ b/buildSrc/src/main/groovy/detekt.gradle @@ -16,7 +16,7 @@ task detekt(type: JavaExec) { main = "io.gitlab.arturbosch.detekt.cli.Main" classpath = configurations.detekt def input = "$project.projectDir.absolutePath" - def config = "$project.projectDir/detekt.yml" + def config = "$project.rootDir/codequality/detekt.yml" def reports = "txt:$reportFile" def baseline = "$project.projectDir.absolutePath/reports/baseline.xml" def filters = ".*test.*" diff --git a/codecheck/build.gradle b/codecheck/build.gradle new file mode 100644 index 0000000..bfda42f --- /dev/null +++ b/codecheck/build.gradle @@ -0,0 +1,188 @@ +import com.github.spotbugs.snom.SpotBugsTask + +/** + * Set up Checkstyle, Findbugs and PMD to perform extensive code analysis. + * + * Gradle tasks added: + * - jacocoTestCoverageVerification + * - checkstyle + * - spotbugs + * - pmd + * + * The three tasks above are added as dependencies of the check task so running check will + * run all of them. + */ + +apply plugin: "checkstyle" +apply plugin: "com.github.spotbugs" +//apply plugin: "findbugs" +apply plugin: "pmd" + +def qualityConfigDir = "$project.rootDir/codecheck" as String +def reportsDir = "$project.buildDir/reports" as String + +check.dependsOn "styleCheck", "jacocoTestCoverageCheck", "spotbugsCheck", "pmdCheck" + +task jacocoTestCoverageCheck( + type: JacocoCoverageVerification, + group: "Verification", + description: "Jacoco test coverage verification" + //dependsOn: "jacocoTestReport" +) { + def jacocoFilter = ["**/BuildConfig.*", "**/*Test*.*", "**/*Exception*.*"] + + sourceDirectories.setFrom(files(["$project.projectDir/src/main/java"])) + classDirectories.setFrom(files([fileTree(dir: "$project.buildDir/intermediates/javac/debug", excludes: jacocoFilter)])) + executionData.setFrom(files("${buildDir}/jacoco/testDebugUnitTest.exec")) + + violationRules { + failOnViolation = true + rule { + element = "BUNDLE" + + limit { + value = "COVEREDRATIO" + counter = "INSTRUCTION" + minimum = 0.8 + } + } + } +} + +task codeCoverageReport(type: JacocoReport, group: "Coverage reports") { + executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") + +// dependsOn javaProjects*.test + +// javaProjects.each { +// sourceSets it.sourceSets.main +// } + + reports { + xml.enabled = true + xml.destination new File("${buildDir}/reports/jacoco/report.xml") + html.enabled = true + html.destination new File("${buildDir}/reports/jacoco/html") + csv.enabled = false + } + afterEvaluate { + // Exclude generated files from top-level coverage report + classDirectories.setFrom( + files( + classDirectories.files.collect { + fileTree( + dir: it, + exclude: [ + "**/com/netflix/genie/proto/**", + "**/com/netflix/genie/web/data/entities/*_*", + ] + ) + } + ) + ) + } +} + +task styleCheck( + type: Checkstyle, + group: "Verification", + description: "Runs code style checks" +) { + configFile file("$qualityConfigDir/checkstyle/checkstyle.xml") + //configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/codecheck/checkstyle/suppressions.xml").absolutePath + configProperties = [ + "checkstyle.cache.file" : rootProject.file("build/checkstyle.cache"), + "checkstyle.suppression.file": file("${project.rootDir}/codecheck/checkstyle/suppressions.xml") + ] + + maxWarnings = 0 + ignoreFailures = true + + source "src" + include "**/*.java" + exclude "**/gen/**" + + reports { + xml.enabled = true + xml.setDestination(file("$reportsDir/checkstyle/checkstyle.xml")) + html.stylesheet resources.text.fromFile("$reportsDir/checkstyle/checkstyle-custom.xsl") + } + + classpath = files() +} + +task spotbugsCheck( + type: SpotBugsTask, + group: "Verification", + description: "Inspect java bytecode for bugs", + dependsOn: ["classes"] +) { + classDirs = sourceSets.main.output + sourceDirs = sourceSets.main.allSource.sourceDirectories + auxClassPaths = sourceSets.main.compileClasspath + + spotbugsMain.enabled = true + spotbugsTest.enabled = true + + reports { + xml.enabled = false + html.enabled = true + } +} + +//task findbugs( +// type: FindBugs, +// group: "Verification", +// description: "Inspect java bytecode for bugs", +// dependsOn: ["compileDebugSources", "compileReleaseSources"] +//) { +// ignoreFailures = true +// effort = "max" +// reportLevel = "high" +// maxHeapSize = "512m" +// excludeFilter = new File("$qualityConfigDir/findbugs/findbugs-exclude-filter.xml") +// classes = files("$project.rootDir/app/build/intermediates/classes") as DefaultTask +// +// source "src" +// include "**/*.java" +// exclude "**/gen/**" +// +// reports { +// xml.enabled = true +// html.enabled = false +// html.stylesheet resources.text.fromFile("$qualityConfigDir/findbugs/findbugs-custom.xsl") +// xml { +// destination "$reportsDir/findbugs/findbugs.xml" +// } +// html { +// destination "$reportsDir/findbugs/findbugs.html" +// } +// } +// +// classpath = files() +//} + +task pmdCheck( + type: Pmd, + group: "Verification", + description: "Inspect sourcecode for bugs" +) { + ruleSetFiles = files("$qualityConfigDir/pmd/pmd-ruleset.xml") + ignoreFailures = true + ruleSets = [] + + source "src" + include "**/*.java" + exclude "**/gen/**" + + reports { + xml.enabled = true + html.enabled = true + xml.setDestination(file("$reportsDir/pmd/pmd.xml")) + html.setDestination(file("$reportsDir/pmd/pmd.html")) + } +} + +//findbugsTest { +// enabled = false +//} diff --git a/codecheck/checkstyle/checkstyle-custom.xsl b/codecheck/checkstyle/checkstyle-custom.xsl new file mode 100644 index 0000000..5e181b5 --- /dev/null +++ b/codecheck/checkstyle/checkstyle-custom.xsl @@ -0,0 +1,83 @@ + + + + + + + + Sun Coding Style Violations + + +

+ Coding Style Check Results +

+ + + + + + + + + + + + + + + + + + + + +
+ Summary +
Total files checked + +
Files with errors + +
Total errors + +
Errors per file + +
+
+

The following are violations of the Sun Coding-Style Standards:

+

+ + + + + + + + + + + +
File: + +
+ + + + + + +
Line NumberError Message
+

+ + + + + + + + + + + + + + diff --git a/codecheck/findbugs/findbugs-custom.xsl b/codecheck/findbugs/findbugs-custom.xsl new file mode 100644 index 0000000..0dfa764 --- /dev/null +++ b/codecheck/findbugs/findbugs-custom.xsl @@ -0,0 +1,465 @@ + + + + + + + + + Warning + Priority + Details + + + + + + + FindBugs Report + + + + + + + + +

FindBugs Report

+

Produced using FindBugs + . +

+

Project: + + + + + + + + +

+ + + + + + +
+

Metrics

+ +
+

Summary

+ + + + + + + + + + + + + tablerow0 + tablerow1 + + + + + + + + + + + + tablerow0 + tablerow1 + + + + + + +
Warning TypeNumber
+ + Warnings + + + +
+ Total + + + + +
+
+ +

+
+
+

+ +

Warnings

+ +

Click on each warning link to see a full description of the issue, and + details of how to resolve it. +

+ + + + + + + + + + Warnings + + Warnings_ + + + + +

+
+
+

+

+ Warning Types +

+ + + + + + + + +
+ + + + + + + + + + + high + + + medium + + + low + + + #fdfdfd + + + + + + + + + + + High + + Medium + Low + Unknown + + + +
+
+ +
+
+ + + In file + + + + + + , + + + line + + + + lines + + to + + + + + + +
+ +
+
+
+ + +
+ + +

+ + + +

+ +

+
+
+

+
+ + + + + + +

+ + + +

+ + + + + + + + + + + + + + + + +
+

+ None +

+
+

+
+
+

+
+ + + + + +

+ lines of code analysed, + in + classes, + in + packages. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MetricTotalDensity*
High Priority Warnings + + + +
Medium Priority Warnings + + + +
Low Priority Warnings + + + +
+ Total Warnings + + + + + + + + +
+

+ (* Defects per thousand lines of non-commenting source statements) +

+

+
+
+

+ +
+ +
diff --git a/codecheck/quality.gradle b/codecheck/quality.gradle deleted file mode 100644 index 8ce4fb1..0000000 --- a/codecheck/quality.gradle +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Set up Checkstyle, Findbugs and PMD to perform extensive code analysis. - * - * Gradle tasks added: - * - jacocoTestCoverageVerification - * - checkstyle - * - findbugs - * - pmd - * - * The three tasks above are added as dependencies of the check task so running check will - * run all of them. - */ - -apply plugin: 'checkstyle' -apply plugin: 'findbugs' -apply plugin: 'pmd' - -def qualityConfigDir = "$project.rootDir/codecheck" as String; -def reportsDir = "$project.buildDir/reports" as String - -check.dependsOn 'checkstyle', 'jacocoTestCoverageVerification', 'findbugs', 'pmd' - -task jacocoTestCoverageVerification( - type: JacocoCoverageVerification, - group: 'Verification', - description: 'Jacoco test coverage verification' - //dependsOn: 'jacocoTestReport' -) { - def jacocoFilter = ['**/BuildConfig.*', '**/*Test*.*', '**/*Exception*.*'] - - sourceDirectories.setFrom(files(["$project.projectDir/src/main/java"])) - classDirectories.setFrom(files([fileTree(dir: "$project.buildDir/intermediates/javac/debug", excludes: jacocoFilter)])) - executionData.setFrom(files("${buildDir}/jacoco/testDebugUnitTest.exec")) - - violationRules { - failOnViolation = true - rule { - element = 'BUNDLE' - - limit { - value = 'COVEREDRATIO' - counter = 'INSTRUCTION' - minimum = 0.8 - } - } - } -} - -task codeCoverageReport(type: JacocoReport, group: "Coverage reports") { - executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") - - dependsOn javaProjects*.test - - javaProjects.each { - sourceSets it.sourceSets.main - } - - reports { - xml.enabled = true - xml.destination new File("${buildDir}/reports/jacoco/report.xml") - html.enabled = true - html.destination new File("${buildDir}/reports/jacoco/html") - csv.enabled = false - } - afterEvaluate { - // Exclude generated files from top-level coverage report - classDirectories.setFrom( - files( - classDirectories.files.collect { - fileTree( - dir: it, - exclude: [ - "**/com/netflix/genie/proto/**", - "**/com/netflix/genie/web/data/entities/*_*", - ] - ) - } - ) - ) - } -} - -task checkstyle( - type: Checkstyle, - group: 'Verification', - description: 'Runs code style checks' -) { - configFile file("$qualityConfigDir/checkstyle/checkstyle.xml") - //configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/codecheck/checkstyle/suppressions.xml").absolutePath - configProperties = [ - 'checkstyle.cache.file' : rootProject.file('build/checkstyle.cache'), - 'checkstyle.suppression.file': file("${project.rootDir}/codecheck/checkstyle/suppressions.xml") - ] - - maxWarnings = 0 - ignoreFailures = true - - source 'src' - include '**/*.java' - exclude '**/gen/**' - - reports { - xml.enabled = true - xml.destination = "$reportsDir/checkstyle/checkstyle.xml" - } - - classpath = files() -} - -task findbugs( - type: FindBugs, - group: 'Verification', - description: 'Inspect java bytecode for bugs', - dependsOn: ['compileDebugSources', 'compileReleaseSources'] -) { - ignoreFailures = true - effort = "max" - reportLevel = "high" - maxHeapSize = "512m" - excludeFilter = new File("$qualityConfigDir/findbugs/findbugs-exclude-filter.xml") - classes = files("$project.rootDir/app/build/intermediates/classes") as DefaultTask - - source 'src' - include '**/*.java' - exclude '**/gen/**' - - reports { - xml.enabled = true - html.enabled = false - xml { - destination "$reportsDir/findbugs/findbugs.xml" - } - html { - destination "$reportsDir/findbugs/findbugs.html" - } - } - - classpath = files() -} - -task pmd( - type: Pmd, - group: 'Verification', - description: 'Inspect sourcecode for bugs' -) { - ruleSetFiles = files("$qualityConfigDir/pmd/pmd-ruleset.xml") - ignoreFailures = true - ruleSets = [] - - source 'src' - include '**/*.java' - exclude '**/gen/**' - - reports { - xml.enabled = true - html.enabled = true - xml.destination = "$reportsDir/pmd/pmd.xml" - html.destination = "$reportsDir/pmd/pmd.html" - } -} - -findbugsTest { - enabled = false -} diff --git a/codequality/detekt.yml b/codequality/detekt.yml new file mode 100644 index 0000000..3e3ff80 --- /dev/null +++ b/codequality/detekt.yml @@ -0,0 +1,21 @@ +failFast: true + +potential-bugs: + UnsafeCast: + active: false # We know what we're doing. + LateinitUsage: + active: false # We know what we're doing. + +style: + TopLevelPropertyNaming: + active: false + MaxLineLength: + active: false + UnnecessaryApply: + active: false + +comments: + UndocumentedPublicClass: + active: false + UndocumentedPublicFunction: + active: false diff --git a/gradle.properties b/gradle.properties index 3bf48e7..ade2fce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,18 +33,22 @@ baseUrl="https://github.com/AlexRogalskiy/gradle-java-sample" ### ### Release properties ### -POM_GROUP_ID=com.1gravity -POM_DESCRIPTION=Android RTEditor is a rich text editor component used as drop-in for EditText -POM_URL=https://github.com/1gravity/Android-RTEditor -POM_SCM_URL=https://github.com/1gravity/Android-RTEditor -POM_SCM_CONNECTION=scm:git@github.com:1gravity/Android-RTEditor.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:1gravity/Android-RTEditor.git -POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_GROUP_ID=io.nullable.api.sample +POM_ARTIFACT_ID=gradle-java-sample +POM_NAME=Gradle Java Sample +POM_PACKAGING=jar +POM_INCEPTION_YEAR=2021 +POM_DESCRIPTION=Gradle java sample project +POM_URL=https://github.com/AlexRogalskiy/gradle-java-sample +POM_SCM_URL=https://github.com/AlexRogalskiy/gradle-java-sample +POM_SCM_CONNECTION=scm:git@github.com:AlexRogalskiy/gradle-java-sample.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:AlexRogalskiy/gradle-java-sample.git +POM_LICENCE_NAME=GPL-3.0 POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo -POM_COMPANY_NAME=1gravity LLC -POM_COMPANY_URL=www.1gravity.com -POM_DEVELOPER_ID=1gravity -POM_DEVELOPER_NAME=Emanuel Moecklin -POM_DEVELOPER_EMAIL=1gravityllc@gmail.com -POM_ISSUE_URL=https://github.com/1gravity/Android-RTEditor/issues +POM_COMPANY_NAME=Nullables.io, Inc. +POM_COMPANY_URL=https://www.nullables.io +POM_DEVELOPER_ID=AlexRogalskiy +POM_DEVELOPER_NAME=Alexander Rogalskiy +POM_DEVELOPER_EMAIL=hi@nullables.io +POM_ISSUE_URL=https://github.com/AlexRogalskiy/gradle-java-sample/issues diff --git a/settings.gradle b/settings.gradle index 206b7b4..96db787 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,33 +8,33 @@ pluginManagement { gradlePluginPortal() maven { - name "JCenter Gradle Plugins repository" - url "https://dl.bintray.com/gradle/gradle-plugins" + name 'JCenter Gradle Plugins repository' + url 'https://dl.bintray.com/gradle/gradle-plugins' } maven { - name "Sonatype Snapshots repository" - url "https://oss.sonatype.org/content/repositories/snapshots/" + name 'Sonatype Snapshots repository' + url 'https://oss.sonatype.org/content/repositories/snapshots/' } maven { - name "Gradle repository" - url "https://plugins.gradle.org/m2/" + name 'Gradle repository' + url 'https://plugins.gradle.org/m2/' } } } // build scan plugin can only be applied in settings file plugins { - id("com.gradle.enterprise") version "3.5.1" + id('com.gradle.enterprise') version '3.5.1' } gradleEnterprise { buildScan { - termsOfServiceUrl = "https://gradle.com/terms-of-service" - termsOfServiceAgree = "yes" + termsOfServiceUrl = 'https://gradle.com/terms-of-service' + termsOfServiceAgree = 'yes' } } -rootProject.name = "gradle-java-sample" +rootProject.name = 'gradle-java-sample' include 'appflow' include 'testflow' From e24a30e6488a3a2aa9a37617bb5c06a139ad34f7 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Mon, 5 Apr 2021 19:49:00 +0300 Subject: [PATCH 23/47] docs: updates on documentation Added informational and corporate documentation --- .bettercodehub.yml | 5 +++++ .deepsource.toml | 8 ++++++++ buildSrc/src/main/groovy/dependencies.gradle | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .bettercodehub.yml create mode 100644 .deepsource.toml diff --git a/.bettercodehub.yml b/.bettercodehub.yml new file mode 100644 index 0000000..46be470 --- /dev/null +++ b/.bettercodehub.yml @@ -0,0 +1,5 @@ +component_depth: 6 +default_excludes: true +languages: + - java + - kotlin diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..f2b9af9 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,8 @@ +version = 1 + +[[analyzers]] +name = "java" +enabled = true + + [analyzers.meta] + runtime_version = "11" diff --git a/buildSrc/src/main/groovy/dependencies.gradle b/buildSrc/src/main/groovy/dependencies.gradle index b855e7c..a737c2d 100644 --- a/buildSrc/src/main/groovy/dependencies.gradle +++ b/buildSrc/src/main/groovy/dependencies.gradle @@ -40,8 +40,8 @@ ext.versions = [ "ktlint" : "0.29.0", "lint" : "0.40.0", "mockito" : "3.7.7", - flyway : '7.5.2', - postgresql : '42.2.18' + "flyway" : "7.5.2", + "postgresql" : "42.2.18" ] ext.libraries = [ From 0131c3c860f92fa99f863b85aedbd0b2d6ea6866 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Mon, 5 Apr 2021 20:01:07 +0300 Subject: [PATCH 24/47] docs: updates on documentation Added informational and corporate documentation --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0e31061..c84913d 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ _**Gradle Java Sample**_ has experimental support for **Gitpod**, a pre-configur The project uses [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/AlexRogalskiy/gradle-java-sample/tags). +## 🐛 _Issues_ + +[![DeepSource](https://deepsource.io/gh/AlexRogalskiy/gradle-java-sample.svg/?label=active+issues&show_trend=true)](https://deepsource.io/gh/AlexRogalskiy/gradle-java-sample/?ref=repository-badge) + ## 🌹 _Authors_ _**Gradle Java Sample**_ is maintained by the following GitHub team-members: From 386102b7de048d5c5ba3d25f066fab16c562f04a Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Tue, 6 Apr 2021 03:27:54 +0300 Subject: [PATCH 25/47] docs: updates on documentation Added informational and corporate documentation --- .github/scripts/close-pending.sh | 27 +++++++++ .github/scripts/comment-commands/close.sh | 21 +++++++ .github/scripts/comment-commands/debug.sh | 7 +++ .github/scripts/comment-commands/help.sh | 13 +++++ .github/scripts/comment-commands/label.sh | 11 ++++ .github/scripts/comment-commands/pending.sh | 22 ++++++++ .github/scripts/comment-commands/ready.sh | 20 +++++++ .github/scripts/comment-commands/retest.sh | 61 +++++++++++++++++++++ .github/scripts/process-comment.sh | 41 ++++++++++++++ .github/workflows/close-pending.yml | 21 +++++++ README.md | 3 + 11 files changed, 247 insertions(+) create mode 100644 .github/scripts/close-pending.sh create mode 100644 .github/scripts/comment-commands/close.sh create mode 100644 .github/scripts/comment-commands/debug.sh create mode 100644 .github/scripts/comment-commands/help.sh create mode 100644 .github/scripts/comment-commands/label.sh create mode 100644 .github/scripts/comment-commands/pending.sh create mode 100644 .github/scripts/comment-commands/ready.sh create mode 100644 .github/scripts/comment-commands/retest.sh create mode 100644 .github/scripts/process-comment.sh create mode 100644 .github/workflows/close-pending.yml diff --git a/.github/scripts/close-pending.sh b/.github/scripts/close-pending.sh new file mode 100644 index 0000000..b7ed417 --- /dev/null +++ b/.github/scripts/close-pending.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +MESSAGE=$(cat $SCRIPT_DIR/closing-message.txt) + +while IFS= read -r number && + IFS= read -r title; do + echo "Closing PR ($number): $title" + curl -s -o /dev/null \ + -X POST \ + --data "$(jq --arg body "$MESSAGE" -n '{body: $body}')" \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + --header 'content-type: application/json' \ + "https://api.github.com/repos/AlexRogalskiy/object-mappers-playground/issues/$number/comments" + + curl -s -o /dev/null \ + -X PATCH \ + --data '{"state": "close"}' \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + --header 'content-type: application/json' \ + "https://api.github.com/repos/AlexRogalskiy/object-mappers-playground/pulls/$number" +done < <(curl -H "Content-Type: application/json" \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + "https://api.github.com/search/issues?q=repo:AlexRogalskiy/object-mappers-playground+type:pr+updated:<$(date -d "-21 days" +%Y-%m-%d)+label:pending+is:open" | + jq -r '.items[] | (.number,.title)') diff --git a/.github/scripts/comment-commands/close.sh b/.github/scripts/comment-commands/close.sh new file mode 100644 index 0000000..6c04626 --- /dev/null +++ b/.github/scripts/comment-commands/close.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +#doc: Close pending pull request temporary +# shellcheck disable=SC2124 +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +MESSAGE=$(cat $SCRIPT_DIR/../closing-message.txt) + +set +x #GITHUB_TOKEN +curl -s -o /dev/null \ + -X POST \ + --data "$(jq --arg body "$MESSAGE" -n '{body: $body}')" \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + --header 'content-type: application/json' \ + "$(jq -r '.issue.comments_url' "$GITHUB_EVENT_PATH")" + +curl -s -o /dev/null \ + -X PATCH \ + --data '{"state": "close"}' \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + --header 'content-type: application/json' \ + "$(jq -r '.issue.pull_request.url' "$GITHUB_EVENT_PATH")" diff --git a/.github/scripts/comment-commands/debug.sh b/.github/scripts/comment-commands/debug.sh new file mode 100644 index 0000000..fbc68ce --- /dev/null +++ b/.github/scripts/comment-commands/debug.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +#doc: Show current event json to debug problems + +echo "\`\`\`" +cat "$GITHUB_EVENT_PATH" +echo "\`\`\`" diff --git a/.github/scripts/comment-commands/help.sh b/.github/scripts/comment-commands/help.sh new file mode 100644 index 0000000..babec9b --- /dev/null +++ b/.github/scripts/comment-commands/help.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +#doc: Show all the available comment commands +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +echo "Available commands:" +DOCTAG="#" +DOCTAG="${DOCTAG}doc" +for command in "$DIR"/*.sh; do + COMMAND_NAME="$(basename "$command" | sed 's/\.sh$//')" + if [ "$COMMAND_NAME" != "debug" ]; then + printf " * /**%s** %s\n" "$COMMAND_NAME" "$(grep $DOCTAG "$command" | sed "s/$DOCTAG//g")" + fi +done diff --git a/.github/scripts/comment-commands/label.sh b/.github/scripts/comment-commands/label.sh new file mode 100644 index 0000000..d7612b4 --- /dev/null +++ b/.github/scripts/comment-commands/label.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +#doc: add new label to the issue: `/label