threads / patch / 58915

patch, 4 partsAvoid using deprecated features in Git's GitHub workflows

Subject: [PATCH 0/4] Avoid using deprecated features in Git's GitHub workflows

## tl;dr

11 messages between Dec 7, 2022 and Dec 8, 2022. Diffs are folded; open one to read it.

replies: 10people: 4as markdown or json

Johannes Schindelin via GitGitGadget· Dec 7, 2022, 14:34 UTC · lore

We are using a couple of GitHub Actions features that have been deprecated since we started using them. One of these features is addressed in Oscar's contribution over at https://lore.kernel.org/git/pull.1354.v2.git.git.1670234474721.gitgitgadget@gmail.com/, on which this here patch series is based.

I waited for quite a while with submitting this because I did not want to interfere with patch series that are in flight, but it seems that this was unwise, as there is now a patch floating about (ab/ci-retire-set-output) that partially fulfills this here patch series' purpose. However, these patches are more complete, so I proposed to supersede that patch with this more comprehensive solution.

This patch series is based on od/ci-use-checkout-v3-when-applicable.
Johannes Schindelin (4):
  ci: use a newer `github-script` version
  ci: avoid deprecated `set-output` workflow command
  ci: avoid using deprecated {up,down}load-artifacts Action
  ci(l10n): avoid using the deprecated `set-output` workflow command
 .github/workflows/l10n.yml |  4 ++--
 .github/workflows/main.yml | 30 ++++++++++++++++++------------
 2 files changed, 20 insertions(+), 14 deletions(-)
base-commit: 6cf4d908a92296654f891d440fe09d9fd34b2272
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1440%2Fdscho%2Fci-set-output-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1440/dscho/ci-set-output-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1440
-- 
gitgitgadget
Johannes Schindelin via GitGitGadget· Dec 7, 2022, 14:34 UTC · re: Johannes Schindelin via GitGitGadget · lore

[PATCH 1/4] ci: use a newer `github-script` version

From: Johannes Schindelin <johannes.schindelin@gmx.de>

The old version we currently use runs in node.js v12.x, which is being deprecated in GitHub Actions. The new version uses node.js v16.x.

Incidentally, this also avoids the warning about the deprecated `::set-output::` workflow command because the newer version of the `github-script` Action uses the recommended new way to specify outputs.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 .github/workflows/main.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Show changes to .github/workflows/main.yml +3 −3
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 5262823eb1c..43d47824dd3 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -37,14 +37,14 @@ jobs:
           echo "::set-output name=enabled::$enabled"
       - name: skip if the commit or tree was already tested
         id: skip-if-redundant
-        uses: actions/github-script@v3
+        uses: actions/github-script@v6
         if: steps.check-ref.outputs.enabled == 'yes'
         with:
           github-token: ${{secrets.GITHUB_TOKEN}}
           script: |
             try {
               // Figure out workflow ID, commit and tree
-              const { data: run } = await github.actions.getWorkflowRun({
+              const { data: run } = await github.rest.actions.getWorkflowRun({
                 owner: context.repo.owner,
                 repo: context.repo.repo,
                 run_id: context.runId,
@@ -54,7 +54,7 @@ jobs:
               const tree_id = run.head_commit.tree_id;
 
               // See whether there is a successful run for that commit or tree
-              const { data: runs } = await github.actions.listWorkflowRuns({
+              const { data: runs } = await github.rest.actions.listWorkflowRuns({
                 owner: context.repo.owner,
                 repo: context.repo.repo,
                 per_page: 500,
-- 
gitgitgadget
Taylor Blau· Dec 7, 2022, 22:22 UTC · re: Johannes Schindelin via GitGitGadget · lore

Re: [PATCH 1/4] ci: use a newer `github-script` version

On Wed, Dec 07, 2022 at 02:34:37PM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 11 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> The old version we currently use runs in node.js v12.x, which is being
> deprecated in GitHub Actions. The new version uses node.js v16.x.
>
> Incidentally, this also avoids the warning about the deprecated
> `::set-output::` workflow command because the newer version of the
> `github-script` Action uses the recommended new way to specify outputs.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>

It took me a second to remember why my S-o-b was here, but it looks like this is from when I queued this patch in [1], which is on 'master' as of 63357b79c9 (ci: use a newer `github-script` version, 2022-11-08).

So having my S-o-b here is definitely OK (since I was the one who put it there in the first place!), but I don't think we need to re-queue this patch, unless it was reverted out in the meantime (which it doesn't appear to be).

Thanks, Taylor

[1]: https://lore.kernel.org/git/Y2q9723uEtfkJrah@nand.local/
Johannes Schindelin via GitGitGadget· Dec 7, 2022, 14:34 UTC · re: Johannes Schindelin via GitGitGadget · lore

[PATCH 2/4] ci: avoid deprecated `set-output` workflow command

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Due to security concerns, this command was deprecated and we need to write into `$GITHUB_OUTPUT` instead. For more details, see https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .github/workflows/main.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to .github/workflows/main.yml +1 −1
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 43d47824dd3..1e95aa86b6c 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -34,7 +34,7 @@ jobs:
           then
             enabled=no
           fi
-          echo "::set-output name=enabled::$enabled"
+          echo "enabled=$enabled" >>$GITHUB_OUTPUT
       - name: skip if the commit or tree was already tested
         id: skip-if-redundant
         uses: actions/github-script@v6
-- 
gitgitgadget
Taylor Blau· Dec 7, 2022, 22:24 UTC · re: Johannes Schindelin via GitGitGadget · lore

Re: [PATCH 2/4] ci: avoid deprecated `set-output` workflow command

On Wed, Dec 07, 2022 at 02:34:38PM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 5 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> Due to security concerns, this command was deprecated and we need to
> write into `$GITHUB_OUTPUT` instead. For more details, see
> https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

OK, this one and [1] are pretty similar. I don't have a strong preference between one or the other, though I suspect it will be easier for the maintainer to pick them all up from the same series.

So in that sense I guess I have a slight preference for this one, though I admit to not feeling very strongly about it ;-).

Thanks, Taylor

[1]: https://lore.kernel.org/git/patch-1.1-deb65805345-20221206T195811Z-avarab@gmail.com/
Johannes Schindelin via GitGitGadget· Dec 7, 2022, 14:34 UTC · re: Johannes Schindelin via GitGitGadget · lore

[PATCH 3/4] ci: avoid using deprecated {up,down}load-artifacts Action

From: Johannes Schindelin <johannes.schindelin@gmx.de>

The deprecated versions of these Actions still use node.js 12 whereas workflows will need to use node.js 16 to avoid problems going forward.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .github/workflows/main.yml | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
Show changes to .github/workflows/main.yml +14 −8
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 1e95aa86b6c..5e82d8d2b1b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -94,7 +94,7 @@ jobs:
     - name: zip up tracked files
       run: git archive -o artifacts/tracked.tar.gz HEAD
     - name: upload tracked files and build artifacts
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: windows-artifacts
         path: artifacts
@@ -108,7 +108,7 @@ jobs:
         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     steps:
     - name: download tracked files and build artifacts
-      uses: actions/download-artifact@v2
+      uses: actions/download-artifact@v3
       with:
         name: windows-artifacts
         path: ${{github.workspace}}
@@ -125,7 +125,7 @@ jobs:
       run: ci/print-test-failures.sh
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: failed-tests-windows
         path: ${{env.FAILED_TEST_ARTIFACTS}}
@@ -177,7 +177,7 @@ jobs:
     - name: zip up tracked files
       run: git archive -o artifacts/tracked.tar.gz HEAD
     - name: upload tracked files and build artifacts
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: vs-artifacts
         path: artifacts
@@ -192,7 +192,7 @@ jobs:
     steps:
     - uses: git-for-windows/setup-git-for-windows-sdk@v1
     - name: download tracked files and build artifacts
-      uses: actions/download-artifact@v2
+      uses: actions/download-artifact@v3
       with:
         name: vs-artifacts
         path: ${{github.workspace}}
@@ -210,7 +210,7 @@ jobs:
       run: ci/print-test-failures.sh
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: failed-tests-windows
         path: ${{env.FAILED_TEST_ARTIFACTS}}
@@ -267,7 +267,7 @@ jobs:
       run: ci/print-test-failures.sh
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: failed-tests-${{matrix.vector.jobname}}
         path: ${{env.FAILED_TEST_ARTIFACTS}}
@@ -302,7 +302,13 @@ jobs:
       shell: bash
       run: ci/print-test-failures.sh
     - name: Upload failed tests' directories
-      if: failure() && env.FAILED_TEST_ARTIFACTS != ''
+      if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname != 'linux32'
+      uses: actions/upload-artifact@v3
+      with:
+        name: failed-tests-${{matrix.vector.jobname}}
+        path: ${{env.FAILED_TEST_ARTIFACTS}}
+    - name: Upload failed tests' directories
+      if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname == 'linux32'
       uses: actions/upload-artifact@v1
       with:
         name: failed-tests-${{matrix.vector.jobname}}
-- 
gitgitgadget
Johannes Schindelin via GitGitGadget· Dec 7, 2022, 14:34 UTC · re: Johannes Schindelin via GitGitGadget · lore

[PATCH 4/4] ci(l10n): avoid using the deprecated `set-output` workflow command

From: Johannes Schindelin <johannes.schindelin@gmx.de>

We need to use an environment file now. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .github/workflows/l10n.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to .github/workflows/l10n.yml +2 −2
diff --git a/.github/workflows/l10n.yml b/.github/workflows/l10n.yml
index 27f72f0ff34..2915c595b4f 100644
--- a/.github/workflows/l10n.yml
+++ b/.github/workflows/l10n.yml
@@ -23,8 +23,8 @@ jobs:
             base=${{ github.event.before }}
             head=${{ github.event.after }}
           fi
-          echo "::set-output name=base::$base"
-          echo "::set-output name=head::$head"
+          echo "base=$base" >>$GITHUB_OUTPUT
+          echo "head=$head" >>$GITHUB_OUTPUT
       - name: Run partial clone
         run: |
           git -c init.defaultBranch=master init --bare .
-- 
gitgitgadget
Taylor Blau· Dec 7, 2022, 22:40 UTC · re: Johannes Schindelin via GitGitGadget · lore

Re: [PATCH 0/4] Avoid using deprecated features in Git's GitHub workflows

On Wed, Dec 07, 2022 at 02:34:36PM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 5 quoted lines
> Johannes Schindelin (4):
>   ci: use a newer `github-script` version
>   ci: avoid deprecated `set-output` workflow command
>   ci: avoid using deprecated {up,down}load-artifacts Action
>   ci(l10n): avoid using the deprecated `set-output` workflow command

These all look reasonable to me, minus the first one which is already on 'master' as-is (unless I am missing something, but see my reply to that email).

Thanks, Taylor

Junio C Hamano· Dec 7, 2022, 23:58 UTC · re: Taylor Blau · lore

Re: [PATCH 0/4] Avoid using deprecated features in Git's GitHub workflows

Taylor Blau <me@ttaylorr.com> writes:
Show 10 quoted lines
> On Wed, Dec 07, 2022 at 02:34:36PM +0000, Johannes Schindelin via GitGitGadget wrote:
>> Johannes Schindelin (4):
>>   ci: use a newer `github-script` version
>>   ci: avoid deprecated `set-output` workflow command
>>   ci: avoid using deprecated {up,down}load-artifacts Action
>>   ci(l10n): avoid using the deprecated `set-output` workflow command
>
> These all look reasonable to me, minus the first one which is already
> on 'master' as-is (unless I am missing something, but see my reply to
> that email).

I think we already have set-output ones figured out and queued in 'seen', and the third one alone cleanly applies without any others (and replaces my botched attempt ;-), so we are in good shape, I think.

Thanks.
Junio C Hamano· Dec 8, 2022, 05:50 UTC · re: Junio C Hamano · lore

Re: [PATCH 0/4] Avoid using deprecated features in Git's GitHub workflows

Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> Taylor Blau <me@ttaylorr.com> writes:
>
>> On Wed, Dec 07, 2022 at 02:34:36PM +0000, Johannes Schindelin via GitGitGadget wrote:
>>> Johannes Schindelin (4):
>>>   ci: use a newer `github-script` version
>>>   ci: avoid deprecated `set-output` workflow command
>>>   ci: avoid using deprecated {up,down}load-artifacts Action
>>>   ci(l10n): avoid using the deprecated `set-output` workflow command
>>
>> These all look reasonable to me, minus the first one which is already
>> on 'master' as-is (unless I am missing something, but see my reply to
>> that email).
>
> I think we already have set-output ones figured out and queued in
> 'seen', and the third one alone cleanly applies without any others
> (and replaces my botched attempt ;-), so we are in good shape, I
> think.

So, with "checkout@v3" by Oscar a few days ago, "set-output to $GITHUB_OUTPUT" by Ævar yesterday, and the "upload/download artifact@v3" in this series, all queued near the tip of 'next', all the deprecation warnings we have been seeing are now gone, cf.

  https://github.com/git/git/actions/runs/3644168470

Unfortunately, a new one says that ubuntu-22.04 will soon be used when ubuntu-latest is called for X-<.

In any case, thank you, everybody, for cleaning up the CI workers.
Ævar Arnfjörð Bjarmason· Dec 7, 2022, 22:42 UTC · re: Johannes Schindelin via GitGitGadget · lore

Re: [PATCH 0/4] Avoid using deprecated features in Git's GitHub workflows

On Wed, Dec 07 2022, Johannes Schindelin via GitGitGadget wrote:
Show 6 quoted lines
> I waited for quite a while with submitting this because I did not want to
> interfere with patch series that are in flight, but it seems that this was
> unwise, as there is now a patch floating about (ab/ci-retire-set-output)
> that partially fulfills this here patch series' purpose. However, these
> patches are more complete, so I proposed to supersede that patch with this
> more comprehensive solution.

What does "more complete" here mean? Just that this series is doing more things than stand-alone patches?

> This patch series is based on od/ci-use-checkout-v3-when-applicable.
>
> Johannes Schindelin (4):
>   ci: use a newer `github-script` version

Is this the patch that needs or interacts with od/ci-use-checkout-v3-when-applicable?

I don't see it in "What's Cooking", but "seen" currently has "gitster/js/ci-set-output", which looks to be from [1]

>   ci: avoid deprecated `set-output` workflow command
This is byte-for-byte the same as the second hunk in my [2].
>   ci: avoid using deprecated {up,down}load-artifacts Action

Most of this looks good & doesn't duplicate any existing patch, but why is there a change in there that disables the uploading of failed test directories for the "linux32" job?

>   ci(l10n): avoid using the deprecated `set-output` workflow command

This does the same as the first hunk in my [2], you're just using two "echo", I used a here-doc.

I think what would make it valuable to bundle these up is if doing so would resolve some tricky interference between these patches.

But I don't see that that's the case, and we can e.g. start writing to "$GITHUB_OUTPUT" independent of other changes.

1. https://lore.kernel.org/git/pull.1387.git.1667902408921.gitgitgadget@gmail.com/
2. https://lore.kernel.org/git/patch-v2-1.1-4e7db0db3be-20221207T014848Z-avarab@gmail.com/

← back to recent threads