From 71a3f3889a85e5044f87a886ddff0b6dfaaef094 Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Mon, 5 Feb 2024 18:12:14 +0100 Subject: [PATCH] tmt: automatically determine copr version matrix Fixes #79 --- .github/workflows/tmt.yml | 57 +++++++++++++++++++++++++++++++-------- scripts/functions.sh | 5 ++++ 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tmt.yml b/.github/workflows/tmt.yml index 1f996e53..306826d7 100644 --- a/.github/workflows/tmt.yml +++ b/.github/workflows/tmt.yml @@ -15,20 +15,55 @@ permissions: actions: write jobs: + osmatrix: + runs-on: ubuntu-latest + container: + image: "fedora:rawhide" + outputs: + matrix: ${{ steps.osmatrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Copr config file + env: + # You need to have those secrets in your repo. + # See also: https://copr.fedorainfracloud.org/api/. + COPR_CONFIG_FILE: ${{ secrets.COPR_CONFIG }} + run: | + mkdir -p ~/.config + printf "$COPR_CONFIG_FILE" > ~/.config/copr + + - name: Install Copr CLI and required tools + run: | + dnf install -y copr-cli + + - id: osmatrix + shell: bash -e {0} + run: | + source scripts/functions.sh + + # Get OS versions comma separated with properly quoted rawhide + os_versions=`get_os_versions | paste -sd "," - | sed 's/rawhide/"rawhide"/'` + + cat < /tmp/osmatrix + matrix={ + "version": [$os_versions] + "strategy": [standalone, big-merge, bootstrap], + "include": [ + {"strategy": "standalone", "copr_project_tpl": "llvm-snapshots-incubator-YYYYMMDD"}, + {"strategy": "big-merge", "copr_project_tpl": "llvm-snapshots-big-merge-YYYYMMDD"}, + {"strategy": "bootstrap", "copr_project_tpl": "llvm-snapshots-bootstrap-YYYYMMDD"} + ] + } + EOF + + # Store the output + cat /tmp/osmatrix | tr '\n' ' ' >> $GITHUB_OUTPUT run-tmt: + needs: osmatrix strategy: fail-fast: false - matrix: - os: [fedora] - version: [38, 39, rawhide] - strategy: [standalone, big-merge, bootstrap] - include: - - strategy: standalone - copr_project_tpl: "llvm-snapshots-incubator-YYYYMMDD" - - strategy: big-merge - copr_project_tpl: "llvm-snapshots-big-merge-YYYYMMDD" - - strategy: bootstrap - copr_project_tpl: "llvm-snapshots-bootstrap-YYYYMMDD" + matrix: ${{ fromJSON(needs.osmatrix.outputs.matrix) }} runs-on: ubuntu-latest container: image: "${{ matrix.os }}:${{ matrix.version }}" diff --git a/scripts/functions.sh b/scripts/functions.sh index 6f2e3faf..802375f5 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -59,6 +59,11 @@ function get_chroots() { copr list-chroots | grep -P '^fedora-(rawhide|[0-9]+)' | sort | tr '\n' ' ' } +# Returns the Fedora OS versions (including rawhide) that are supported by copr +function get_os_versions() { + get_chroots | grep -ioP 'fedora-\K[0-9,rawhide]+' | sort | uniq +} + # Prints the packages we care about function get_packages() { echo "python-lit llvm clang lld compiler-rt libomp"