From 69eb39582b36101f005ca6c73eb908ca708f3417 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:48:25 +1300 Subject: [PATCH] ci: Introduce artifacts Separates `test-linux` into `build-linux` and `test-linux`, wherein `build-` builds out of tree, and uploading the build for the `test-` job. Tar compression is done to retain execution permissions when downloading build artifact. When calling `make test`, override `TARGETS` and `EXTRA_TARGETS` to prevent rebuild. --- .github/workflows/test-linux.yml | 66 ++++++++++++++++++++++++++------ .github/workflows/test-macos.yml | 9 ++++- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 911b3b66e..c4098edbe 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -1,6 +1,12 @@ name: Build and run tests (Linux) -on: [push, pull_request] +on: + pull_request: + branches: + - master + push: + branches: + - master jobs: pre_job: @@ -17,7 +23,7 @@ jobs: # only run on push *or* pull_request, not both concurrent_skipping: 'same_content_newer' - test-linux: + build-linux: needs: pre_job if: needs.pre_job.outputs.should_skip != 'true' runs-on: ${{ matrix.os.id }} @@ -123,25 +129,61 @@ jobs: make -j${{ env.procs }} make install - - name: Build yosys + - name: Build yosys out-of-tree shell: bash run: | - make config-${CC%%-*} - make -j${{ env.procs }} CXXSTD=${{ matrix.cpp_std }} CC=$CC CXX=$CC LD=$CC + mkdir build + cd build + make -f ../Makefile config-${CC%%-*} + make -f ../Makefile -j${{ env.procs }} CXXSTD=${{ matrix.cpp_std }} CC=$CC CXX=$CC LD=$CC + + - name: Log yosys-config output + run: | + ./yosys-config || true + + - name: Compress build + shell: bash + run: | + cd build + tar -cvf ../build.tar Makefile.conf share/ yosys yosys-* - name: Store build artifact if: (matrix.cpp_std == 'c++11') && (matrix.compiler == 'gcc-11') uses: actions/upload-artifact@v4 with: - name: compiled-yosys - path: yosys + name: build-artifact + path: build.tar + retention-days: 1 - - name: Run tests - if: (matrix.cpp_std == 'c++11') && (matrix.compiler == 'gcc-11') + test-linux: + name: Run tests + needs: build-linux + runs-on: ubuntu-latest + steps: + - name: Install Dependencies shell: bash run: | - make -j${{ env.procs }} test CXXSTD=${{ matrix.cpp_std }} CC=$CC CXX=$CC LD=$CC + sudo apt-get update + sudo apt-get install gperf build-essential bison flex libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot pkg-config python3 libboost-system-dev libboost-python-dev libboost-filesystem-dev zlib1g-dev - - name: Log yosys-config output + - name: Runtime environment + shell: bash + env: + WORKSPACE: ${{ github.workspace }} run: | - ./yosys-config || true + echo "procs=$(nproc)" >> $GITHUB_ENV + + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: build-artifact + + - name: Uncompress build + shell: bash + run: + tar -xvf build.tar + + - name: Run tests + shell: bash + run: | + make -j${{ env.procs }} test TARGETS= EXTRA_TARGETS= diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index cbba8adbd..ed63c8f35 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -1,6 +1,12 @@ name: Build and run tests (macOS) -on: [push, pull_request] +on: + pull_request: + branches: + - master + push: + branches: + - master jobs: pre_job: @@ -27,7 +33,6 @@ jobs: - { id: macos-13, name: 'Ventura' } cpp_std: - 'c++11' - - 'c++17' fail-fast: false steps: - name: Install Dependencies