From 373d3db35ffada7776268e69adb597fa7e8d5f7e Mon Sep 17 00:00:00 2001 From: exquo <62397152+exquo@users.noreply.github.com> Date: Thu, 23 Mar 2023 07:12:16 +0000 Subject: [PATCH] Simplify matrix --- .github/workflows/libclient-build.yaml | 72 +++++++----- .gitignore | 1 + filename_for_matrix_item.py | 59 +++------- generate_matrix.py | 154 +++++++++---------------- util.py | 15 +++ util.sh | 7 ++ 6 files changed, 137 insertions(+), 171 deletions(-) create mode 100644 .gitignore create mode 100644 util.py diff --git a/.github/workflows/libclient-build.yaml b/.github/workflows/libclient-build.yaml index eb7e9ef..d80dca8 100644 --- a/.github/workflows/libclient-build.yaml +++ b/.github/workflows/libclient-build.yaml @@ -9,6 +9,7 @@ on: schedule: - cron: '33 3 * * *' + defaults: run: shell: bash # Explicit for windows @@ -45,10 +46,9 @@ jobs: [ -n "$upstream_ver" ] || upstream_ver=$(bash util.sh get_latest_release_name "$LIB_REPO") echo "upstream_ver=$upstream_ver" | tee -a $GITHUB_OUTPUT release_name=$(bash util.sh release_name "$LIB_REPO" "$upstream_ver") - echo "release_name = $release_name" this_repo_release=$(bash util.sh get_release_data "$release_name") [ -z "$this_repo_release" ] || release_name='' - echo "release_name=$release_name" >> $GITHUB_OUTPUT + echo "release_name=$release_name" | tee -a $GITHUB_OUTPUT new_release: @@ -79,6 +79,7 @@ jobs: matrix_setup: + needs: - new_release - compare_releases @@ -110,12 +111,13 @@ jobs: matrix: ${{ fromJSON(needs.matrix_setup.outputs.matrix) }} fail-fast: false # do not abort all if some of the builds fail - name: build_${{ matrix.cross.target || matrix.host.triple }} + name: build_${{ matrix.build-env.target || matrix.build-env.triple }} - runs-on: ${{ matrix.host.runner }} + runs-on: ${{ matrix.build-env.runner }} + container: ${{ matrix.build-env.container }} env: - TARGET: ${{ matrix.cross.target }} + TARGET: ${{ matrix.build-env.target }} THIS_REPO_DIR: _this_repo_checkout # Ref: @@ -134,9 +136,19 @@ jobs: - name: Checkout this repo sources uses: actions/checkout@v3 + - name: Install required packages + if: ${{ matrix.build-env.req-pkg }} + env: + INSTALL_CMD: ${{ matrix.build-env.install-cmd }} + PKGS: ${{ matrix.build-env.req-pkg }} + run: | + bash -c "$INSTALL_CMD $PKGS" + - name: Generate file names for the current matrix item id: filenames - run: python3 filename_for_matrix_item.py '${{ needs.matrix_setup.outputs.matrix }}' '${{ matrix.lib.name }}' '${{ matrix.host.runner }}' '${{ matrix.cross.target }}' + env: + MATRIX_RUN: ${{ toJSON(matrix) }} + run: python3 filename_for_matrix_item.py "$MATRIX_RUN" - name: Clone upstream source uses: actions/checkout@v3 @@ -146,33 +158,26 @@ jobs: - name: Install Rust toolchain run: rustup toolchain install nightly --profile minimal - # Why nightly: https://github.com/signalapp/libsignal/issues/141#issuecomment-1211192153 + # Why nightly: https://github.com/signalapp/libsignal/issues/141#issuecomment-1211192153 - name: Add target to rust toolchain - if: ${{ matrix.cross.target }} + if: ${{ matrix.build-env.target }} run: rustup target add $TARGET - - name: Install required packages - if: ${{ matrix.host.req-pkg || matrix.cross.req-pkg }} - run: | - bash -c "$INSTALL_CMD $PKGS" - env: - INSTALL_CMD: ${{ matrix.host.install-cmd }} - PKGS: ${{ matrix.host.req-pkg }} ${{ matrix.cross.req-pkg }} - - name: Add linker to cargo config # Alternatively can add to rust flags - #RUSTFLAGS: -C linker=${{ matrix.cross.linker }} - if: ${{ matrix.cross.linker }} + #RUSTFLAGS: -C linker=${{ matrix.build-env.linker }} + if: ${{ matrix.build-env.linker }} + env: + LINKER: ${{ matrix.build-env.linker }} run: | - cat >>~/.cargo/config <> ~/.cargo/config </dev/null || apt install curl -y + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null +} "$@"