Skip to content

Commit

Permalink
chore(workflow): cache verilator builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumonda221-CrO3 committed Oct 15, 2024
1 parent 3887d67 commit adfedde
Showing 1 changed file with 76 additions and 16 deletions.
92 changes: 76 additions & 16 deletions .github/workflows/scenario-CoupledL2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
run:
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 }}

Expand Down

0 comments on commit adfedde

Please sign in to comment.