From 0e3dcf535b2dfaee0bdc4bae2f4427d07f226425 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 11 Mar 2024 12:42:45 +0100 Subject: [PATCH 1/5] feat: support ratchet comments in github-actions manager --- .../github-actions/__fixtures__/workflow_4.yml | 2 ++ lib/modules/manager/github-actions/extract.spec.ts | 12 ++++++++++++ lib/modules/manager/github-actions/extract.ts | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/modules/manager/github-actions/__fixtures__/workflow_4.yml b/lib/modules/manager/github-actions/__fixtures__/workflow_4.yml index ae34907103bdcf..1c3cbecb6bf4f9 100644 --- a/lib/modules/manager/github-actions/__fixtures__/workflow_4.yml +++ b/lib/modules/manager/github-actions/__fixtures__/workflow_4.yml @@ -17,3 +17,5 @@ jobs: - uses: actions/checkout@01aecc#v2.1.0 - uses: actions/checkout@689fcce700ae7ffc576f2b029b51b2ffb66d3abd # comment containing 2.1.0 - uses: actions/checkout@689fcce700ae7ffc576f2b029b51b2ffb66d3abd # v2.1.0 additional comment + - uses: actions/checkout@689fcce700ae7ffc576f2b029b51b2ffb66d3abd # ratchet:actions/checkout@v2.1.0 + - uses: actions/checkout@689fcce700ae7ffc576f2b029b51b2ffb66d3abd # ratchet:exclude diff --git a/lib/modules/manager/github-actions/extract.spec.ts b/lib/modules/manager/github-actions/extract.spec.ts index 6cb38d7ac02909..a660f80d9da413 100644 --- a/lib/modules/manager/github-actions/extract.spec.ts +++ b/lib/modules/manager/github-actions/extract.spec.ts @@ -385,6 +385,18 @@ describe('modules/manager/github-actions/extract', () => { replaceString: 'actions/checkout@689fcce700ae7ffc576f2b029b51b2ffb66d3abd # v2.1.0', }, + { + currentDigest: '689fcce700ae7ffc576f2b029b51b2ffb66d3abd', + currentValue: 'v2.1.0', + replaceString: + 'actions/checkout@689fcce700ae7ffc576f2b029b51b2ffb66d3abd # ratchet:actions/checkout@v2.1.0', + }, + { + currentDigest: '689fcce700ae7ffc576f2b029b51b2ffb66d3abd', + currentValue: undefined, + replaceString: + 'actions/checkout@689fcce700ae7ffc576f2b029b51b2ffb66d3abd # ratchet:exclude', + }, ]); }); diff --git a/lib/modules/manager/github-actions/extract.ts b/lib/modules/manager/github-actions/extract.ts index 14ba5c4b99b5e1..edf09dbfed2d9f 100644 --- a/lib/modules/manager/github-actions/extract.ts +++ b/lib/modules/manager/github-actions/extract.ts @@ -15,7 +15,7 @@ import type { Workflow } from './types'; const dockerActionRe = regEx(/^\s+uses\s*: ['"]?docker:\/\/([^'"]+)\s*$/); const actionRe = regEx( - /^\s+-?\s+?uses\s*: (?['"]?(?https:\/\/[.\w-]+\/)?(?[\w-]+\/[.\w-]+)(?\/.*)?@(?[^\s'"]+)['"]?(?:\s+#\s*(?:renovate\s*:\s*)?(?:pin\s+|tag\s*=\s*)?@?(?v?\d+(?:\.\d+(?:\.\d+)?)?))?)/, + /^\s+-?\s+?uses\s*: (?['"]?(?https:\/\/[.\w-]+\/)?(?[\w-]+\/[.\w-]+)(?\/.*)?@(?[^\s'"]+)['"]?(?:\s+#\s*(((?:renovate\s*:\s*)?(?:pin\s+|tag\s*=\s*)?|(?:ratchet:[\w-]+\/[.\w-]+)?)@?(?v?\d+(?:\.\d+(?:\.\d+)?)?)|(?:ratchet:exclude)))?)/, ); // SHA1 or SHA256, see https://github.blog/2020-10-19-git-2-29-released/ From a03399dccac5c90e6d89778f9f1a4cf2706d2ecb Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 11 Mar 2024 12:57:51 +0100 Subject: [PATCH 2/5] docs: update README for github-actions manager --- lib/modules/manager/github-actions/readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/modules/manager/github-actions/readme.md b/lib/modules/manager/github-actions/readme.md index be99cb2597fb22..b6084de6c5d958 100644 --- a/lib/modules/manager/github-actions/readme.md +++ b/lib/modules/manager/github-actions/readme.md @@ -40,3 +40,5 @@ jobs: build: runs-on: ${{ env.RUNNER }} ``` + +The `github-action` manager also supports `ratchet` comments, like `# ratchet:actions/checkout@v2.1.0`. Please refer to the [ratchet documentation](https://github.com/sethvargo/ratchet/blob/main/README.md) for more information. From 5330075021bf06546fd14710c22df4ea239e93b1 Mon Sep 17 00:00:00 2001 From: Artem Kamenev Date: Mon, 11 Mar 2024 14:32:29 +0100 Subject: [PATCH 3/5] docs: format readme Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- lib/modules/manager/github-actions/readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/modules/manager/github-actions/readme.md b/lib/modules/manager/github-actions/readme.md index b6084de6c5d958..e4251450dbdafb 100644 --- a/lib/modules/manager/github-actions/readme.md +++ b/lib/modules/manager/github-actions/readme.md @@ -41,4 +41,5 @@ jobs: runs-on: ${{ env.RUNNER }} ``` -The `github-action` manager also supports `ratchet` comments, like `# ratchet:actions/checkout@v2.1.0`. Please refer to the [ratchet documentation](https://github.com/sethvargo/ratchet/blob/main/README.md) for more information. +The `github-action` manager also supports `ratchet` comments, like `# ratchet:actions/checkout@v2.1.0`. +Please read the [ratchet documentation](https://github.com/sethvargo/ratchet/blob/main/README.md) for more information. From f12a0d705e7bccd185428dd6856bc6263c632ab9 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 11 Mar 2024 17:41:56 +0100 Subject: [PATCH 4/5] docs: clarify github-actions manager behavior --- lib/modules/manager/github-actions/readme.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/modules/manager/github-actions/readme.md b/lib/modules/manager/github-actions/readme.md index e4251450dbdafb..2bddad69598a87 100644 --- a/lib/modules/manager/github-actions/readme.md +++ b/lib/modules/manager/github-actions/readme.md @@ -41,5 +41,14 @@ jobs: runs-on: ${{ env.RUNNER }} ``` +<<<<<<< HEAD The `github-action` manager also supports `ratchet` comments, like `# ratchet:actions/checkout@v2.1.0`. Please read the [ratchet documentation](https://github.com/sethvargo/ratchet/blob/main/README.md) for more information. +======= +The `github-action` manager understands `ratchet` comments, like `# ratchet:actions/checkout@v2.1.0`. +This means that Renovate will: + +- update the version of a _pinned_ Ratchet version if needed +- not delete Ratchet comments after parsing them +- keep `# ratchet:exclude` comments +>>>>>>> 8bc27d16a (docs: clarify github-actions manager behavior) From 15822b6f7e8e52c3fc6f874f9e127f1ce164091d Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 11 Mar 2024 17:50:18 +0100 Subject: [PATCH 5/5] docs: update wording --- lib/modules/manager/github-actions/readme.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/modules/manager/github-actions/readme.md b/lib/modules/manager/github-actions/readme.md index 2bddad69598a87..2a8d381391445e 100644 --- a/lib/modules/manager/github-actions/readme.md +++ b/lib/modules/manager/github-actions/readme.md @@ -41,14 +41,9 @@ jobs: runs-on: ${{ env.RUNNER }} ``` -<<<<<<< HEAD -The `github-action` manager also supports `ratchet` comments, like `# ratchet:actions/checkout@v2.1.0`. -Please read the [ratchet documentation](https://github.com/sethvargo/ratchet/blob/main/README.md) for more information. -======= The `github-action` manager understands `ratchet` comments, like `# ratchet:actions/checkout@v2.1.0`. This means that Renovate will: - update the version of a _pinned_ Ratchet version if needed - not delete Ratchet comments after parsing them - keep `# ratchet:exclude` comments ->>>>>>> 8bc27d16a (docs: clarify github-actions manager behavior)