Skip to content

Commit

Permalink
ci: Orb tools 11 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaryt authored Apr 21, 2022
2 parents 2e5aa0f + 66043c9 commit 614c0e5
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 102 deletions.
126 changes: 27 additions & 99 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

# 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/[email protected]
shellcheck: circleci/[email protected]

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 <your orb>@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
53 changes: 53 additions & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: 2.1
orbs:
gradle: circleci/gradle@dev:<<pipeline.git.revision>>
orb-tools: circleci/[email protected]
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]+$/
7 changes: 7 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends: relaxed

rules:
line-length:
max: 200
allow-non-breakable-inline-mappings: true

8 changes: 5 additions & 3 deletions src/commands/with_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 >>
Expand Down
1 change: 1 addition & 0 deletions src/scripts/checksum_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find . -name "${PARAM_CHECKSUM_FILES}" | sort | xargs cat | shasum | awk '{print $1}' > /tmp/gradle_cache_seed

0 comments on commit 614c0e5

Please sign in to comment.