Skip to contentSkip to conversation

ci: avoid using the deprecated `set-env` construct

PATCH In review Johannes Schindelin via GitGitGadget 4 participants 6 messages Nov 7, 2020 – Nov 18, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ci: avoid using the deprecated `set-env` construct

From: Johannes Schindelin <[email protected]>

The set-env construct was deprecated as of the announcement in
https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

Let's use the recommended alternative instead.

---
ci: avoid using the deprecated set-env construct

This avoids an ugly warning (see e.g. this run
[https://github.com/gitgitgadget/git/actions/runs/350443139]).

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-781%2Fdscho%2Fno-set-env-in-github-workflows-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-781/dscho/no-set-env-in-github-workflows-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/781

 .github/workflows/check-whitespace.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.github/workflows/check-whitespace.yml +1 -1
index 9d070b9cdf..c74b47de9e 100644
@@ -14,7 +14,7 @@ jobs:
     steps:
     - name: Set commit count
       shell: bash
-      run: echo "::set-env name=COMMIT_DEPTH::$((1+$COMMITS))"
+      run: echo "COMMIT_DEPTH=$((1+$COMMITS))" >>$GITHUB_ENV
       env:
         COMMITS: ${{ github.event.pull_request.commits }}
 

base-commit: 7f7ebe054af6d831b999d6c2241b9227c4e4e08d

Signature · 1 line
gitgitgadget
#1 lore raw

Looks good. Doing a similar change in a related repo.

...chris.

...chris.
[email protected]
webstech.com

Quoted 39 lines · Johannes Schindelin via GitGitGadget

From: Johannes Schindelin <[email protected]>

The set-env construct was deprecated as of the announcement in
https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

Let's use the recommended alternative instead.

---
ci: avoid using the deprecated set-env construct

This avoids an ugly warning (see e.g. this run
[https://github.com/gitgitgadget/git/actions/runs/350443139]).

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-781%2Fdscho%2Fno-set-env-in-github-workflows-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-781/dscho/no-set-env-in-github-workflows-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/781

 .github/workflows/check-whitespace.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.github/workflows/check-whitespace.yml +1 -1
index 9d070b9cdf..c74b47de9e 100644
@@ -14,7 +14,7 @@ jobs:
     steps:
     - name: Set commit count
       shell: bash
-      run: echo "::set-env name=COMMIT_DEPTH::$((1+$COMMITS))"
+      run: echo "COMMIT_DEPTH=$((1+$COMMITS))" >>$GITHUB_ENV
       env:
         COMMITS: ${{ github.event.pull_request.commits }}
 

base-commit: 7f7ebe054af6d831b999d6c2241b9227c4e4e08d --
gitgitgadget

#2 lore raw
In reply to Johannes Schindelin via GitGitGadget

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 10 lines · writes:

From: Johannes Schindelin <[email protected]>

The set-env construct was deprecated as of the announcement in
https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
...

.github/workflows/check-whitespace.yml +0 -0
index 9d070b9cdf..c74b47de9e 100644

.github/workflows/check-whitespace.yml jobs: · line 19

Quoted 7 lines
.github/workflows/check-whitespace.yml +1 -1
@@ -14,7 +14,7 @@ jobs:
     steps:
     - name: Set commit count
       shell: bash
-      run: echo "::set-env name=COMMIT_DEPTH::$((1+$COMMITS))"
+      run: echo "COMMIT_DEPTH=$((1+$COMMITS))" >>$GITHUB_ENV
       env:
         COMMITS: ${{ github.event.pull_request.commits }}

Do we need something similar for ci/print-test-failures.sh to prevent failures like https://github.com/git/git/runs/1409815807?

Perhaps like the following (which is copied-and-pasted without understanding what is going on or without doing nothing more than skimming [*1*])?

Reference

*1* https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable

 ci/print-test-failures.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ci/print-test-failures.sh +1 -1
index 92a983a265..c70d6cdbf2 100755
@@ -48,7 +48,7 @@ do
 			;;
 		github-actions)
 			mkdir -p failed-test-artifacts
-			echo "::set-env name=FAILED_TEST_ARTIFACTS::t/failed-test-artifacts"
+			echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
 			cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
 			tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
 			continue
#3 lore raw

Hi Junio,

Quoted 24 lines · Junio C Hamano

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 10 lines · writes:

From: Johannes Schindelin <[email protected]>

The set-env construct was deprecated as of the announcement in
https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
...

.github/workflows/check-whitespace.yml +0 -0
index 9d070b9cdf..c74b47de9e 100644

.github/workflows/check-whitespace.yml jobs: · line 19

Quoted 7 lines
.github/workflows/check-whitespace.yml +1 -1
@@ -14,7 +14,7 @@ jobs:
     steps:
     - name: Set commit count
       shell: bash
-      run: echo "::set-env name=COMMIT_DEPTH::$((1+$COMMITS))"
+      run: echo "COMMIT_DEPTH=$((1+$COMMITS))" >>$GITHUB_ENV
       env:
         COMMITS: ${{ github.event.pull_request.commits }}

Do we need something similar for ci/print-test-failures.sh to prevent failures like https://github.com/git/git/runs/1409815807?

Quoted 3 lines

Perhaps like the following (which is copied-and-pasted without understanding what is going on or without doing nothing more than skimming [*1*])?

Yes, of course, this precisely what we need.

Sorry for not even _thinking_ about git grep set-env. This seems the only remaining use of that construct in our workflows, though.

Thanks,
Dscho

Quoted 25 lines

Reference

*1* https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable

 ci/print-test-failures.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ci/print-test-failures.sh +1 -1
index 92a983a265..c70d6cdbf2 100755
@@ -48,7 +48,7 @@ do
 			;;
 		github-actions)
 			mkdir -p failed-test-artifacts
-			echo "::set-env name=FAILED_TEST_ARTIFACTS::t/failed-test-artifacts"
+			echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
 			cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
 			tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
 			continue
#4 lore raw
Quoted 5 lines · Johannes Schindelin
Quoted 3 lines

Perhaps like the following (which is copied-and-pasted without understanding what is going on or without doing nothing more than skimming [*1*])?

Yes, of course, this precisely what we need.

Thanks.

--- >8 ------ >8 ------ >8 --- cut here --- >8 ------ >8 ------ >8 ---

Subject: [PATCH] ci: avoid set-env construct in print-test-failures.sh

Imitating cac42e47 (ci: avoid using the deprecated set-env construct, 2020-11-07), avoid deprecated ::set-env and use the recommended alternative instead in print-test-failures.sh

---
 ci/print-test-failures.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ci/print-test-failures.sh +1 -1
index 92a983a265..c70d6cdbf2 100755
@@ -48,7 +48,7 @@ do
 			;;
 		github-actions)
 			mkdir -p failed-test-artifacts
-			echo "::set-env name=FAILED_TEST_ARTIFACTS::t/failed-test-artifacts"
+			echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
 			cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
 			tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
 			continue
Signature · 1 line
2.29.2-458-g8cf0a80384
#5 lore raw

Hi Junio,

Quoted 12 lines · Junio C Hamano
Quoted 5 lines · Johannes Schindelin
Quoted 3 lines

Perhaps like the following (which is copied-and-pasted without understanding what is going on or without doing nothing more than skimming [*1*])?

Yes, of course, this precisely what we need.

Thanks.

--- >8 ------ >8 ------ >8 --- cut here --- >8 ------ >8 ------ >8 ---

Quoted 8 lines

Subject: [PATCH] ci: avoid set-env construct in print-test-failures.sh

Imitating cac42e47 (ci: avoid using the deprecated set-env construct, 2020-11-07), avoid deprecated ::set-env and use the recommended alternative instead in print-test-failures.sh

Thank you so much for tying up this loose end,
Dscho

Quoted 21 lines
---
 ci/print-test-failures.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ci/print-test-failures.sh +1 -2
index 92a983a265..c70d6cdbf2 100755
@@ -48,7 +48,7 @@ do
 			;;
 		github-actions)
 			mkdir -p failed-test-artifacts
-			echo "::set-env name=FAILED_TEST_ARTIFACTS::t/failed-test-artifacts"
+			echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
 			cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
 			tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
 			continue
--

2.29.2-458-g8cf0a80384