From cad763f72ccb7e8bf4c9c8c02bec0d1ba43b1524 Mon Sep 17 00:00:00 2001 From: Ambrose Bonnaire-Sergeant Date: Wed, 19 Oct 2022 11:55:45 -0400 Subject: [PATCH 1/3] first deprecation --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ff38b9b0a9..e113a70783 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -47,7 +47,7 @@ jobs: # https://github.com/zero88/gh-project-context/blob/26a3afdce1fe607734278e5ccec0851d50669ef5/README.md#latest-commit-message fetch-depth: 2 # for grabbing the current commit msg (suprisingly hard!) - - uses: zero88/gh-project-context@af8b62dd9d7ecbb2763268a040d42390ecfeb0f3 + - uses: zero88/gh-project-context@88bdb34d636c3c244f26d109618346dc6a38ba6f id: gh-project-context - name: Binary Cache uses: actions/cache@v3 From a85f6827caf4a200b4a81b74eb125ad1e0eca81a Mon Sep 17 00:00:00 2001 From: Ambrose Bonnaire-Sergeant Date: Wed, 19 Oct 2022 12:09:49 -0400 Subject: [PATCH 2/3] second deprecation --- scripts-test/actions/actions_helpers_test.clj | 9 +++--- scripts-test/actions/test_helpers.clj | 2 +- scripts/actions/actions_helpers.clj | 28 +++++++++++++------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/scripts-test/actions/actions_helpers_test.clj b/scripts-test/actions/actions_helpers_test.clj index 201fc622fc..0106a02a02 100644 --- a/scripts-test/actions/actions_helpers_test.clj +++ b/scripts-test/actions/actions_helpers_test.clj @@ -29,7 +29,8 @@ :v "[\"a\",\"b\",\"c\"]"}]))])) (deftest set-output-test - (is (.contains - (with-out-str - (sut/set-output "foo" "bar")) - "::set-output name=foo::bar\n"))) + (let [github-output-file (File/createTempFile "github-output" nil) + {:keys [grab-history utils]} (th/mk-utils {"GITHUB_OUTPUT" (.getPath github-output-file)}) + _ (sut/set-output utils "foo" "bar") + _ (is (empty? (grab-history))) + _ (is (= "foo=bar\n" (slurp github-output-file)))])) diff --git a/scripts-test/actions/test_helpers.clj b/scripts-test/actions/test_helpers.clj index 00ae0470d9..a9a70405a8 100644 --- a/scripts-test/actions/test_helpers.clj +++ b/scripts-test/actions/test_helpers.clj @@ -22,7 +22,7 @@ (throw (Exception. (format "No default :sh stub (args: %s)" (pr-str args))))) :getenv (fn [k] (get env-map k)) - :set-output (fn [k v] + :set-output (fn [_utils k v] (swap! state update :history conj {:op :set-output :k k diff --git a/scripts/actions/actions_helpers.clj b/scripts/actions/actions_helpers.clj index ae49dac437..d96f778c2e 100644 --- a/scripts/actions/actions_helpers.clj +++ b/scripts/actions/actions_helpers.clj @@ -4,30 +4,40 @@ (:require [cheshire.core :as json] [clojure.java.shell :as sh])) +(defn append-file-var + "Add entry k=v to file pointed to by environment variable file-var. + + eg., useful for: + echo '{name}={value}' >> $GITHUB_STATE" + [{:keys [getenv]} file-var k v] + {:pre [(string? file-var)]} + (println (str "Adding file var " file-var ": " k "=" v)) + (let [f (getenv file-var)] + (assert f (str "append-file-var: file is null! " file-var)) + (spit f + (str k "=" v "\n") + :append true))) + (defn add-env "Add env var k=v to future GitHub Actions steps in this job" - [{:keys [getenv]} k v] + [utils k v] (println (str "Adding env var: " k "=" v)) - (spit (getenv "GITHUB_ENV") - (str k "=" v "\n") - :append true)) + (append-file-var utils "GITHUB_ENV" k v)) (defn getenv ^String [^String s] (System/getenv s)) (defn set-json-output "Create JSON 'output' `n` for this Actions step, accessible with ${{ fromJSON(.outputs.) }}." [{:keys [set-output] :as utils} n v] - (set-output - n - (json/generate-string v {:pretty false}))) + (set-output utils n (json/generate-string v {:pretty false}))) (defn set-output "Create 'output' `n` for this Actions step, accessible with ${{ .outputs. }}." - [n s] + [utils n s] {:pre [(string? s)]} ;; Actions does not print ::set-output commands to the build output (println (format "DEBUG: Setting output: %s %s" n s)) - (println (format "::set-output name=%s::%s" n s))) + (append-file-var utils "GITHUB_OUTPUT" n s)) (defn sh [& args] (apply sh/sh args)) From bc37ac83d6375a06be58e92132b8c5e9e55cce9d Mon Sep 17 00:00:00 2001 From: Ambrose Bonnaire-Sergeant Date: Wed, 19 Oct 2022 12:30:54 -0400 Subject: [PATCH 3/3] docs --- scripts/actions/print_matrix.clj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/actions/print_matrix.clj b/scripts/actions/print_matrix.clj index ffc7eb7e2d..693cfbada9 100755 --- a/scripts/actions/print_matrix.clj +++ b/scripts/actions/print_matrix.clj @@ -3,11 +3,11 @@ ;; determines the build matrix for the GitHub Actions build. ;; try it locally: ;; # normal builds -;; $ GITHUB_ENV=$(mktemp) GITHUB_EVENT_NAME=pull_request ./scripts/actions/print-matrix.clj -;; $ GITHUB_ENV=$(mktemp) GITHUB_EVENT_NAME=push ./scripts/actions/print-matrix.clj +;; $ GITHUB_OUTPUTS=github-outputs.tmp GITHUB_ENV=$(mktemp) GITHUB_EVENT_NAME=pull_request ./scripts/actions/print_matrix.clj +;; $ GITHUB_ENV=$(mktemp) GITHUB_EVENT_NAME=push ./scripts/actions/print_matrix.clj ;; # cron build -;; $ GITHUB_ENV=$(mktemp) GITHUB_EVENT_NAME=schedule ./scripts/actions/print-matrix.clj -;; $ GITHUB_ENV=$(mktemp) CTIA_COMMIT_MESSAGE='{:test-suite :cron} try cron build' GITHUB_EVENT_NAME=push ./scripts/actions/print-matrix.clj +;; $ GITHUB_ENV=$(mktemp) GITHUB_EVENT_NAME=schedule ./scripts/actions/print_matrix.clj +;; $ GITHUB_ENV=$(mktemp) CTIA_COMMIT_MESSAGE='{:test-suite :cron} try cron build' GITHUB_EVENT_NAME=push ./scripts/actions/print_matrix.clj (ns actions.print-matrix (:require [actions.actions-helpers :as h]))