From 501d188e147f04e9bc0890ac3f7c22889e18d91c Mon Sep 17 00:00:00 2001 From: Ding Haonan Date: Wed, 16 Oct 2024 00:46:13 +0800 Subject: [PATCH] chore(workflow): cache verilator builds (#29) --- .github/workflows/scenario-CoupledL2.yml | 90 ++++++++++++++++++++---- 1 file changed, 75 insertions(+), 15 deletions(-) diff --git a/.github/workflows/scenario-CoupledL2.yml b/.github/workflows/scenario-CoupledL2.yml index 6d35cdc..54434e8 100644 --- a/.github/workflows/scenario-CoupledL2.yml +++ b/.github/workflows/scenario-CoupledL2.yml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [ubuntu-22.04] case: - { id: l2l3, name: L2-L3 } - { id: l2l3l2, name: L2-L3-L2 } @@ -72,8 +72,67 @@ jobs: path: ${{ github.workspace }}/${{ env.COUPLEDL2_ARCHIVE }} name: ${{ env.COUPLEDL2_ARCHIVE }} + setup-verilator: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + compiler: + - { cc: clang-16, cxx: clang++-16 } + - { cc: gcc, cxx: g++ } + exclude: + - { os: ubuntu-20.04, compiler: { cc: gcc, cxx: g++ } } + runs-on: ${{ matrix.os }} + name: Verilator | ${{ matrix.os }} | ${{ matrix.compiler.cc }} + env: + CI_BUILD_STAGE_NAME: build + CI_RUNS_ON: ${{ matrix.os }} + CC: ${{ matrix.compiler.cc }} + CXX: ${{ matrix.compiler.cxx }} + VERILATOR_ARCHIVE: verilator-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz + steps: + + - name: Cache Verilator + id: cache + uses: actions/cache@v4 + env: + cache-name: verilator-cache-${{ matrix.os }}-${{ matrix.compiler.cc }} + with: + path: ${{ github.workspace }}/${{ env.VERILATOR_ARCHIVE }} + key: verilator-cache-${{ matrix.os }}-${{ matrix.compiler.cc }} + + - name: Setup Clang 16 + if: steps.cache.outputs.cache-hit != 'true' && matrix.compiler.cc == 'clang-16' + working-directory: ${{ github.workspace }} + run: | + wget https://apt.llvm.org/llvm.sh + chmod u+x llvm.sh + sudo ./llvm.sh 16 + + - name: Build Verilator + if: steps.cache.outputs.cache-hit != 'true' + working-directory: ${{ github.workspace }} + run: | + sudo apt-get install -y git help2man perl python3 make autoconf g++ flex bison clang + sudo apt-get install -y libfl2 # Ubuntu only (ignore if gives error) + sudo apt-get install -y libfl-dev # Ubuntu only (ignore if gives error) + sudo apt-get install -y zlib1g zlib1g-dev # Ubuntu only (ignore if gives error) + git clone https://github.com/verilator/verilator + unset VERILATOR_ROOT + cd verilator + git checkout v5.020 + autoconf + ./configure CC=${{ matrix.compiler.cc }} CXX=${{ matrix.compiler.cxx }} LINK=${{ matrix.compiler.cxx }} + make -j4 + + - name: Tar-up Verilator + if: steps.cache.outputs.cache-hit != 'true' + working-directory: ${{ github.workspace }} + run: tar -zcf ${{ env.VERILATOR_ARCHIVE }} verilator + build: - needs: prebuild-ootb-coupledL2 + needs: + - prebuild-ootb-coupledL2 + - setup-verilator strategy: fail-fast: false matrix: @@ -95,6 +154,7 @@ jobs: CXX: ${{ matrix.compiler.cxx }} COUPLEDL2_ARCHIVE: coupledL2-${{ matrix.case.id }}-${{ github.sha }}.tar.gz TLTEST_ARCHIVE: tl-test-new-${{ matrix.case.id }}-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz + VERILATOR_ARCHIVE: verilator-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz steps: - name: Checkout @@ -110,30 +170,30 @@ jobs: chmod u+x llvm.sh sudo ./llvm.sh 16 - - name: Setup Verilator + - name: Fetch cached Verilator + uses: actions/cache/restore@v4 + env: + cache-name: verilator-cache-${{ matrix.os }}-${{ matrix.compiler.cc }} + with: + path: ${{ github.workspace }}/${{ env.VERILATOR_ARCHIVE }} + key: verilator-cache-${{ matrix.os }}-${{ matrix.compiler.cc }} + fail-on-cache-miss: true + + - name: Install Verilator working-directory: ${{ github.workspace }} run: | - sudo apt-get install -y git help2man perl python3 make autoconf g++ flex bison clang - sudo apt-get install -y libfl2 # Ubuntu only (ignore if gives error) - sudo apt-get install -y libfl-dev # Ubuntu only (ignore if gives error) - sudo apt-get install -y zlib1g zlib1g-dev # Ubuntu only (ignore if gives error) - git clone https://github.com/verilator/verilator - unset VERILATOR_ROOT + tar -zxf ${{ env.VERILATOR_ARCHIVE }} cd verilator - git checkout v5.020 - autoconf - ./configure CC=${{ matrix.compiler.cc }} CXX=${{ matrix.compiler.cxx }} LINK=${{ matrix.compiler.cxx }} - make -j4 sudo make install verilator --version - - name: Download artifact + - name: Download CoupledL2 artifact uses: actions/download-artifact@v4 with: name: ${{ env.COUPLEDL2_ARCHIVE }} path: ${{ github.workspace }} - - name: Unpack artifact + - name: Unpack CoupledL2 artifact working-directory: ${{ github.workspace }} run: tar -zxf ${{ env.COUPLEDL2_ARCHIVE }}