From 775dc9380e670695cb5766391c5dd89df9f5150b 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 | 74 ++++++++++++++++++++++++-------- .github/workflows/test-macos.yml | 9 +++- 2 files changed, 63 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 5d929f581e6..3d5352e0ed4 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -1,9 +1,15 @@ name: Build and run tests (Linux) -on: [push, pull_request] +on: + pull_request: + branches: + - master + push: + branches: + - master jobs: - test-linux: + build-linux: runs-on: ${{ matrix.os.id }} strategy: matrix: @@ -14,17 +20,6 @@ jobs: - 'gcc-11' cpp_std: - 'c++11' - - 'c++14' - - 'c++17' - - 'c++20' - include: - # Limit the older compilers to C++11 mode - - os: { id: ubuntu-20.04, name: focal } - compiler: 'clang-11' - cpp_std: 'c++11' - - os: { id: ubuntu-20.04, name: focal } - compiler: 'gcc-10' - cpp_std: 'c++11' fail-fast: false steps: - name: Install Dependencies @@ -107,14 +102,57 @@ 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 }} CCXXSTD=${{ 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: Run tests + - 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: build-artifact + path: build.tar + retention-days: 1 + + test-linux: + name: Run tests + needs: build-linux + runs-on: ubuntu-latest + steps: + - name: Install Dependencies + shell: bash + run: | + 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: Runtime environment + shell: bash + env: + WORKSPACE: ${{ github.workspace }} + run: | + 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 CXXSTD=${{ matrix.cpp_std }} CC=$CC CXX=$CC LD=$CC + make -j${{ env.procs }} test TARGETS= EXTRA_TARGETS= diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 17e2ae33155..8ef777278ff 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: test-macos: @@ -11,7 +17,6 @@ jobs: - { id: macos-13, name: 'Ventura' } cpp_std: - 'c++11' - - 'c++17' fail-fast: false steps: - name: Install Dependencies