Skip to content

Commit

Permalink
actions: use env file to set environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
chantra committed Oct 12, 2022
1 parent 646baa5 commit ce0bd78
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: bpf-ci
on:
pull_request:

concurrency:
concurrency:
group: ci-test-${{ github.head_ref }}
cancel-in-progress: true

Expand All @@ -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"},
Expand All @@ -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
Expand Down

0 comments on commit ce0bd78

Please sign in to comment.