From aff1fb623459668c9e0b75e1acbc1f94cd4ea109 Mon Sep 17 00:00:00 2001 From: Peter Darton Date: Fri, 15 Sep 2023 09:29:06 +0100 Subject: [PATCH 1/4] Describe remaining migration work --- MIGRATION.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/MIGRATION.md b/MIGRATION.md index 458f9724..daf41704 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -10,7 +10,8 @@ _Note: If you are upgrading from 11.x to 12.x proceed here. If you are upgrading - **Removed the need for a dev publishing token** - Previously, after the orb was built, it would be published to a development tag and referenced in the test pipeline. This required a publishing token to be present in the dev pipeline. - - The dynamic configuration system allows us to inject the orb directly into the pipeline as an "in-line" orb, allowing for orb testing without the need for access to a publishing token. + - The dynamic configuration system allows us to inject the orb directly into the pipeline as an "in-line" orb, allowing for orb testing without the need for access to a publishing token, + thus allowing forked-PR builds to "build and test" securely. - **Snake_Case Renamed Components** - To keep consistency with CircleCI's _native_ configuration schema, all components and parameters have been renamed to use snake_case. (Example: `parameter-name` -> `parameter_name`) @@ -21,16 +22,46 @@ _Note: If you are upgrading from 11.x to 12.x proceed here. If you are upgrading 1. Clone your orb project locally. 1. Create a new branch for upgrading your pipeline + ```sh git checkout -b orb-tools-12-migration ```` + 1. Copy the `migrate.sh` script from this repository into your project's root directory. 1. Run the script + ```sh chmod +x migrate.sh && ./migrate.sh ``` After executing the script, your orb's component names and parameters will be converted to snake_case, and references to them within your config files will be updated. The reference to your orb in the `test-deploy` config will be removed, as the orb will now be dynamically injected into the pipeline. + +1. Edit your project's `.circleci/config.yml` file. + + Compare the current +[v12 "step1 " lint-pack example](https://circleci.com/developer/orbs/orb/circleci/orb-tools?version=12#usage-step1_lint-pack) +vs the +[v11 version](https://circleci.com/developer/orbs/orb/circleci/orb-tools?version=11#usage-step1_lint-pack) +to see the required changes. + - Remove the old "dev publish" job (`orb-tools/publish`) from the workflow. + - Fix the `requires:` specification so that the "continue" job requires everything else. + +1. Edit your project's `.circleci/test-deploy.yml` file. + + Compare the current +[v12 "step2 " test-deploy example](https://circleci.com/developer/orbs/orb/circleci/orb-tools?version=12#usage-step2_test-deploy) +vs the +[v11 version](https://circleci.com/developer/orbs/orb/circleci/orb-tools?version=11#usage-step2_test-deploy) +to see the required changes. + + - Add an extra call to the "pack" job (`orb-tools/pack`) and ensure that the publish job(s) `require:` it. + - Consider adding an extra call to the "publish" job to reinstate the "dev publish" removed from the `config.yml` build file. + - Not all users will require this; this is only necessary if dev publishes of unreleased orbs are needed for use by other projects. + - Consider setting a filter to ensure that the dev publish doesn't happen for release builds (i.e. no tags) or for external (forked) PR builds (i.e. no branches matching `/^pull/[0-9]+$/`). + - Make the "pack" job `require:` all your test jobs and then have the publish job(s) `require:` the pack job. + +--- + ## v11.0.0 Version 11.0.0 of orb-tools is composed of a major re-write that greatly changes and improves the way orbs are deployed, makes use of CircleCI's [dynamic configuration](https://circleci.com/docs/2.0/dynamic-config/), and can even automatically test for best practices. From bfaa8a8b3a6d1af5a22b4bbc948c1607e8fd0a79 Mon Sep 17 00:00:00 2001 From: Peter Darton Date: Fri, 15 Sep 2023 09:30:39 +0100 Subject: [PATCH 2/4] Don't dev-publish for forked-PRs. Only pack if tests worked --- .circleci/test-deploy.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) mode change 100755 => 100644 .circleci/test-deploy.yml diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml old mode 100755 new mode 100644 index 3f49757a..16bdc961 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -11,25 +11,29 @@ workflows: jobs: - orb-tools-alpha/lint: filters: *filters - - orb-tools-alpha/pack: - filters: *filters - orb-tools-alpha/review: filters: *filters + - orb-tools-alpha/pack: + filters: *filters + requires: + - orb-tools-alpha/lint + - orb-tools-alpha/review - orb-tools-alpha/publish: name: publish_dev_test orb_name: circleci/orb-tools vcs_type: <> pub_type: dev github_token: GHI_TOKEN - requires: - [orb-tools-alpha/lint, orb-tools-alpha/review, orb-tools-alpha/pack] + requires: [orb-tools-alpha/pack] context: orb-publisher + filters: + branches: + ignore: /pull/[0-9]+/ - orb-tools-alpha/publish: orb_name: circleci/orb-tools vcs_type: <> pub_type: production - requires: - [orb-tools-alpha/lint, orb-tools-alpha/review, orb-tools-alpha/pack, publish_dev_test] + requires: [orb-tools-alpha/pack] context: orb-publisher github_token: GHI_TOKEN filters: From 09be88123ccaad00839210bdc5c2708b0538f08b Mon Sep 17 00:00:00 2001 From: Peter Darton Date: Fri, 15 Sep 2023 09:31:48 +0100 Subject: [PATCH 3/4] Example should only dev-publish for forked-PRs and only pack if tests worked --- src/examples/step2_test-deploy.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/examples/step2_test-deploy.yml b/src/examples/step2_test-deploy.yml index 4e7876b1..550754e4 100644 --- a/src/examples/step2_test-deploy.yml +++ b/src/examples/step2_test-deploy.yml @@ -34,13 +34,30 @@ usage: tags: only: /.*/ # Because our publishing job has a tag filter, we must also apply a filter to each job it depends on. + - orb-tools/pack: + requires: + - command-tests + - /my_job + filters: + tags: + only: /.*/ + - orb-tools/publish: + name: publish_dev_test + orb_name: / + pub_type: dev + vcs_type: <> + requires: [orb-tools/pack] + context: [orb-publishing-context] + filters: + tags: + ignore: /^v[0-9]+\.[0-9]+\.[0-9]+$/ + branches: + ignore: /^pull/[0-9]+/ - orb-tools/publish: orb_name: / pub_type: production vcs_type: <> - requires: - - command-tests - - /my_job + requires: [orb-tools/pack] context: [orb-publishing-context] filters: tags: From 549aa4c45ee5951086b9a04512fb01fba6494b8b Mon Sep 17 00:00:00 2001 From: Peter Darton Date: Fri, 12 Jan 2024 14:31:15 +0000 Subject: [PATCH 4/4] Moved changes to test-deploy.yml and example to new PRs --- .circleci/test-deploy.yml | 16 ++++++---------- src/examples/step2_test-deploy.yml | 23 +++-------------------- 2 files changed, 9 insertions(+), 30 deletions(-) mode change 100644 => 100755 .circleci/test-deploy.yml diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml old mode 100644 new mode 100755 index 16bdc961..3f49757a --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -11,29 +11,25 @@ workflows: jobs: - orb-tools-alpha/lint: filters: *filters - - orb-tools-alpha/review: - filters: *filters - orb-tools-alpha/pack: filters: *filters - requires: - - orb-tools-alpha/lint - - orb-tools-alpha/review + - orb-tools-alpha/review: + filters: *filters - orb-tools-alpha/publish: name: publish_dev_test orb_name: circleci/orb-tools vcs_type: <> pub_type: dev github_token: GHI_TOKEN - requires: [orb-tools-alpha/pack] + requires: + [orb-tools-alpha/lint, orb-tools-alpha/review, orb-tools-alpha/pack] context: orb-publisher - filters: - branches: - ignore: /pull/[0-9]+/ - orb-tools-alpha/publish: orb_name: circleci/orb-tools vcs_type: <> pub_type: production - requires: [orb-tools-alpha/pack] + requires: + [orb-tools-alpha/lint, orb-tools-alpha/review, orb-tools-alpha/pack, publish_dev_test] context: orb-publisher github_token: GHI_TOKEN filters: diff --git a/src/examples/step2_test-deploy.yml b/src/examples/step2_test-deploy.yml index 550754e4..4e7876b1 100644 --- a/src/examples/step2_test-deploy.yml +++ b/src/examples/step2_test-deploy.yml @@ -34,30 +34,13 @@ usage: tags: only: /.*/ # Because our publishing job has a tag filter, we must also apply a filter to each job it depends on. - - orb-tools/pack: - requires: - - command-tests - - /my_job - filters: - tags: - only: /.*/ - - orb-tools/publish: - name: publish_dev_test - orb_name: / - pub_type: dev - vcs_type: <> - requires: [orb-tools/pack] - context: [orb-publishing-context] - filters: - tags: - ignore: /^v[0-9]+\.[0-9]+\.[0-9]+$/ - branches: - ignore: /^pull/[0-9]+/ - orb-tools/publish: orb_name: / pub_type: production vcs_type: <> - requires: [orb-tools/pack] + requires: + - command-tests + - /my_job context: [orb-publishing-context] filters: tags: