diff --git a/.circleci/config.yml b/.circleci/config.yml index f7810a5..daaf990 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,109 +1,37 @@ version: 2.1 - -# add your orb below, to be used in integration tests (note: a @dev:alpha -# release must exist.); +setup: true orbs: - gradle: circleci/gradle@dev:alpha - orb-tools: circleci/orb-tools@9.0 - -# Pipeline parameters -parameters: - # These pipeline parameters are required by the "trigger-integration-tests-workflow" - # job, by default. - run-integration-tests: - type: boolean - default: false - dev-orb-version: - type: string - default: "dev:alpha" + orb-tools: circleci/orb-tools@11.1 + shellcheck: circleci/shellcheck@3.1 -jobs: - # This job is an example of an integration testing job. - # This job should execute a command from your orb and verify - # the output is as expected, otherwise the job should fail. - # - # Rename this job and add more as needed. - # - integration-test-1: - executor: gradle/default - steps: - - checkout - - run: - name: Check if Gradle is installed - command: | - if [[ $(command -v gradle) == "" ]]; then - echo " Gradle is not installed! "; exit 1; - else - echo Gradle successfully installed. - fi +filters: &filters + tags: + only: /.*/ workflows: - # This `lint-pack_validate_publish-dev` workflow will run on any commit. - lint_pack-validate_publish-dev: - unless: << pipeline.parameters.run-integration-tests >> + lint-pack: jobs: - - orb-tools/lint - # pack your orb YAML files to a single orb.yml - # validate the orb.yml file to ensure it is well-formed + - orb-tools/lint: + filters: *filters - orb-tools/pack: - requires: - - orb-tools/lint - - # release dev version of orb, for testing & possible publishing. - # orb will be published as dev:alpha and dev:${CIRCLE_SHA1:0:7}. - # requires a CircleCI API token to be stored as CIRCLE_TOKEN (default) - # https://circleci.com/docs/2.0/managing-api-tokens - # store CIRCLE_TOKEN as a project env var or Contexts resource - # if using Contexts, add your context below - - orb-tools/publish-dev: + filters: *filters + - orb-tools/review: + filters: *filters + - shellcheck/check: + exclude: SC2148,SC2038,SC2086,SC2002,SC2016 + filters: *filters + - orb-tools/publish: orb-name: circleci/gradle - context: orb-publisher - requires: - - orb-tools/pack - - # trigger an integration workflow to test the - # dev:${CIRCLE_SHA1:0:7} version of your orb - - orb-tools/trigger-integration-tests-workflow: - name: trigger-integration-dev - context: orb-publisher + vcs-type: << pipeline.project.type >> requires: - - orb-tools/publish-dev - - # This `integration-tests_prod-release` workflow will only run - # when the run-integration-tests pipeline parameter is set to true. - # It is meant to be triggered by the "trigger-integration-tests-workflow" - # job, and run tests on @dev:${CIRCLE_SHA1:0:7}. - integration-tests_prod-release: - when: << pipeline.parameters.run-integration-tests >> - jobs: - # your integration test jobs go here: essentially, run all your orb's - # jobs and commands to ensure they behave as expected. or, run other - # integration tests of your choosing - - # an example job - - integration-test-1 - - gradle/test: - app_src_directory: sample_app - reports_path: sample_app/build/reports/ - test_results_path: sample_app/build/test-results/ - - # publish a semver version of the orb. relies on - # the commit subject containing the text "[semver:patch|minor|major|skip]" - # as that will determine whether a patch, minor or major - # version will be published or if publishing should - # be skipped. - # e.g. [semver:patch] will cause a patch version to be published. - - orb-tools/dev-promote-prod-from-commit-subject: - orb-name: circleci/gradle + [orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check] + # Use a context to hold your publishing token. context: orb-publisher - add-pr-comment: true - bot-token-variable: GHI_TOKEN - bot-user: orb-publisher - fail-if-semver-not-indicated: true - publish-version-tag: false - requires: - - integration-test-1 - - gradle/test - filters: - branches: - only: master + filters: *filters + github-token: GHI_TOKEN + # Triggers the next workflow in the Orb Development Kit. + - orb-tools/continue: + pipeline-number: << pipeline.number >> + vcs-type: << pipeline.project.type >> + requires: [orb-tools/publish] + filters: *filters diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml new file mode 100644 index 0000000..c61a933 --- /dev/null +++ b/.circleci/test-deploy.yml @@ -0,0 +1,53 @@ +version: 2.1 +orbs: + gradle: circleci/gradle@dev:<> + orb-tools: circleci/orb-tools@11.1 +filters: &filters + tags: + only: /.*/ +jobs: + # This job is an example of an integration testing job. + # This job should execute a command from your orb and verify + # the output is as expected, otherwise the job should fail. + # + # Rename this job and add more as needed. + # + integration-test-1: + executor: gradle/default + steps: + - checkout + - run: + name: Check if Gradle is installed + command: |- + if [[ $(command -v gradle) == "" ]]; then + echo " Gradle is not installed! "; exit 1; + else + echo Gradle successfully installed. + fi +workflows: + test-deploy: + jobs: + - integration-test-1: + filters: *filters + - gradle/test: + app_src_directory: sample_app + reports_path: sample_app/build/reports/ + test_results_path: sample_app/build/test-results/ + filters: *filters + - orb-tools/pack: + filters: *filters + - orb-tools/publish: + orb-name: circleci/gradle + vcs-type: << pipeline.project.type >> + pub-type: production + github-token: GHI_TOKEN + requires: + - orb-tools/pack + - integration-test-1 + - gradle/test + context: orb-publisher + filters: + branches: + ignore: /.*/ + tags: + only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..c9a8a2e --- /dev/null +++ b/.yamllint @@ -0,0 +1,7 @@ +extends: relaxed + +rules: + line-length: + max: 200 + allow-non-breakable-inline-mappings: true + diff --git a/src/commands/with_cache.yml b/src/commands/with_cache.yml index 61717a9..7745033 100755 --- a/src/commands/with_cache.yml +++ b/src/commands/with_cache.yml @@ -13,15 +13,17 @@ parameters: cache_key: description: Add a custom suffix to your cache key in the event you need to work with multiple maven caches. type: string - default: 'v1' + default: "v1" cache_checksum_file: description: File to use to generate the cache checksum, defaults to build.gradle. For example if using Gradle Kotlin DSL then set to build.gradle.kts instead. type: string - default: 'build.gradle' + default: "build.gradle" steps: - run: name: Generate Cache Checksum - command: find . -name '<< parameters.cache_checksum_file>>' | sort | xargs cat | shasum | awk '{print $1}' > /tmp/gradle_cache_seed + command: << include(scripts/checksum_files.sh) >> + environment: + PARAM_CHECKSUM_FILES: << parameters.cache_checksum_file>> - restore_cache: key: gradle-<< parameters.cache_key>>-{{ checksum "/tmp/gradle_cache_seed" }}-{{ checksum ".circleci/config.yml" }} - steps: << parameters.steps >> diff --git a/src/scripts/checksum_files.sh b/src/scripts/checksum_files.sh new file mode 100644 index 0000000..4ecbfa0 --- /dev/null +++ b/src/scripts/checksum_files.sh @@ -0,0 +1 @@ +find . -name "${PARAM_CHECKSUM_FILES}" | sort | xargs cat | shasum | awk '{print $1}' > /tmp/gradle_cache_seed \ No newline at end of file