From c72ea67b43b7848e754fcd547da9604b4da27caf Mon Sep 17 00:00:00 2001 From: Julie Schwartz Date: Tue, 16 Jan 2024 22:25:59 +1300 Subject: [PATCH] GitHub CI: Use the new download-bsc action --- .github/workflows/build.yml | 59 ++++++++++++++++------------ .github/workflows/get_latest_bsc.sh | 60 ----------------------------- 2 files changed, 34 insertions(+), 85 deletions(-) delete mode 100755 .github/workflows/get_latest_bsc.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ca6018..074af14 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,14 +15,14 @@ jobs: - uses: actions/checkout@v3 - name: Download bsc - shell: bash - env: - TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ".github/workflows/get_latest_bsc.sh ${{ matrix.os }} " + uses: B-Lang-org/download-bsc@v1 + with: + os: ${{ matrix.os }} + path: ../ - name: Build run: | - export PATH=$PWD/../bsc/inst/bin:$PATH + export PATH=$PWD/../bsc/bin:$PATH make install tar czf inst.tar.gz inst @@ -40,15 +40,16 @@ jobs: runs-on: ${{ matrix. os }} steps: - uses: actions/checkout@v3 + - name: Download bsc - shell: bash - env: - TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ".github/workflows/get_latest_bsc.sh ${{ matrix.os }} " + uses: B-Lang-org/download-bsc@v1 + with: + os: ${{ matrix.os }} + path: ../ - name: Build run: | - export PATH=$PWD/../bsc/inst/bin:$PATH + export PATH=$PWD/../bsc/bin:$PATH make install tar czf inst.tar.gz inst @@ -66,6 +67,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 + - name: Install dependencies shell: bash run: "sudo .github/workflows/install_dependencies_doc_ubuntu.sh" @@ -87,6 +89,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 + - name: Install dependencies shell: bash run: ".github/workflows/install_dependencies_doc_macos.sh" @@ -120,15 +123,18 @@ jobs: # Can this be cached from the previous job? - name: Download bsc - shell: bash - env: - TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ".github/workflows/get_latest_bsc.sh ${{ matrix.os }} " + id: download + uses: B-Lang-org/download-bsc@v1 + with: + os: ${{ matrix.os }} + path: ../ - # This ought to be downloaded at the same version as BSC? + # Checkout the testsuite at the same version - name: Download testsuite run: | - git clone https://github.com/B-Lang-org/bsc ../bsc-testsuite + git clone -n https://github.com/B-Lang-org/bsc ../bsc-testsuite + cd ../bsc-testsuite + git checkout ${{ steps.download.outputs.commit }} - name: Add bdw tests to testsuite run: | cp -r testing/bsc.bdw ../bsc-testsuite/testsuite/ @@ -174,7 +180,7 @@ jobs: cd ../bsc-testsuite/testsuite - export TEST_RELEASE=$PWD/../../bsc/inst + export TEST_RELEASE=$PWD/../../bsc export TEST_CONTRIB= export BDW=$PWD/../../bdw/inst/bin/bdw @@ -217,15 +223,18 @@ jobs: # Can this be cached from the previous job? - name: Download bsc - shell: bash - env: - TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ".github/workflows/get_latest_bsc.sh ${{ matrix.os }} " + id: download + uses: B-Lang-org/download-bsc@v1 + with: + os: ${{ matrix.os }} + path: ../ - # This ought to be downloaded at the same version as BSC? + # Checkout the testsuite at the same version - name: Download testsuite run: | - git clone https://github.com/B-Lang-org/bsc ../bsc-testsuite + git clone -n https://github.com/B-Lang-org/bsc ../bsc-testsuite + cd ../bsc-testsuite + git checkout ${{ steps.download.outputs.commit }} - name: Add bdw tests to testsuite run: | cp -r testing/bsc.bdw ../bsc-testsuite/testsuite/ @@ -261,12 +270,12 @@ jobs: trap ./archive_logs.sh EXIT # Use -O0 for significantly faster C++ compiles (which more - # than make up for slower simulations). + # than make up for slower simulations) export CXXFLAGS="-O0" cd ../bsc-testsuite/testsuite - export TEST_RELEASE=$PWD/../../bsc/inst + export TEST_RELEASE=$PWD/../../bsc export TEST_CONTRIB= export BDW=$PWD/../../bdw/inst/bin/bdw diff --git a/.github/workflows/get_latest_bsc.sh b/.github/workflows/get_latest_bsc.sh deleted file mode 100755 index 5b115b3..0000000 --- a/.github/workflows/get_latest_bsc.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash -set -x - -OS=$1 - -CURL() { - # Don't print progress bar - # Show HTTP request/response ouput (for debugging) - # Follow HTTP 301 redirects - # Retry on temporary failures - # On permanent errors exit with non-zero exit code - # Use a GitHub token so we don't hit rate limits, and can download artifacts - curl --silent \ - --verbose \ - --location \ - --retry 3 \ - --fail \ - --header "Authorization: Bearer $TOKEN" \ - "$@" -} - -# Get the artifacts_url from the most recent successful continuous integration -# build triggered by a push to the main branch on B-Lang-org/bsc. -API=https://api.github.com/repos/B-Lang-org/bsc -LATEST_PUSH="event=push&branch=main&status=success&per_page=1" - -if CURL "$API/actions/workflows/build.yml/runs?$LATEST_PUSH" --output runs.json; then - ARTIFACTS=$(jq -r '.workflow_runs[0].artifacts_url' < runs.json) -else - echo Failed to get workflow runs - cat runs.json - exit 1 -fi - - -# Find the artifact for the specified OS build -if CURL "$ARTIFACTS" --output artifact.json; then - DOWNLOAD_URL=$(jq -r '.artifacts[] | select(.name=="'$OS' build") .archive_download_url' < artifact.json) -else - echo Failed to get latest artifacts - cat artifact.json - exit 1 -fi - -# Download the artifact. Note that unlike the above API methods, this requires -# an authorization token that has at least public repo access. Use the token -# created for github actions -# See https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token -if CURL "$DOWNLOAD_URL" --output inst.zip; then - # The zip file contains a single tarball... - unzip inst.zip - - # Install bsc into a sibling bsc dir that the testsuite automatically finds. - mkdir ../bsc - tar -C../bsc/ -zxf inst.tar.gz - rm inst.zip inst.tar.gz -else - echo Failed to download bsc toolchain - exit 1 -fi