From ce0bd7801c10eb81744568d2f106f509c9f56f90 Mon Sep 17 00:00:00 2001 From: Manu Bretelle Date: Wed, 12 Oct 2022 14:55:53 -0700 Subject: [PATCH] actions: use env file to set environment variables [set-output is being deprecated](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/). Instead, the new recommended way it to set the the name/value pair in GITHUB_OUTPUT file. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter Fixes #142 Signed-off-by: Manu Bretelle --- .github/workflows/test.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 33b9faf7..a98060e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: bpf-ci on: pull_request: -concurrency: +concurrency: group: ci-test-${{ github.head_ref }} cancel-in-progress: true @@ -17,18 +17,24 @@ jobs: uses: libbpf/ci/get-llvm-version@master - id: llvm-toolchain-impl shell: bash - run: echo "::set-output name=version::llvm-${{ steps.llvm-version.outputs.version }}" + run: echo "version=llvm-${{ steps.llvm-version.outputs.version }}" >> $GITHUB_OUTPUT set-matrix: needs: llvm-toolchain runs-on: ubuntu-latest outputs: - build-matrix: ${{ steps.set-matrix-impl.outputs.build_matrix }} - test-matrix: ${{ steps.set-matrix-impl.outputs.test_matrix }} + build-matrix: ${{ env.build_matrix }} + test-matrix: ${{ env.test_matrix }} steps: - id: set-matrix-impl shell: python3 -I {0} run: | from json import dumps + import os + + # write an environemt variable in the GH env file. + def setOutput(name, value): + with open(os.getenv("GITHUB_OUTPUT"), "a") as f: + f.write(f"{name}={value}\n") matrix = [ {"kernel": "LATEST", "runs_on": ["ubuntu-latest", "self-hosted"], "arch": "x86_64", "toolchain": "gcc"}, @@ -51,13 +57,13 @@ jobs: matrix[idx]["runs_on"].remove("self-hosted") build_matrix = {"include": matrix} - print(f"::set-output name=build_matrix::{dumps(build_matrix)}") + setOutput("build_matrix", dumps(build_matrix)) tests = ["test_progs", "test_progs_no_alu32", "test_maps", "test_verifier"] test_matrix = {"include": [{**config, **{"test": test}} for config in matrix for test in tests]} - print(f"::set-output name=test_matrix::{dumps(test_matrix)}") + setOutput("test_matrix", dumps(test_matrix)) build: name: build for ${{ matrix.arch }} with ${{ matrix.toolchain }} needs: set-matrix