Skip to content

tests: Improve GitHub CI action #3469

tests: Improve GitHub CI action

tests: Improve GitHub CI action #3469

Workflow file for this run

name: ci
on: [push, pull_request]
env:
GHDL_VERSION: "v4.1.0"
VERILATOR_VERSION: "v5.030"
CT_NG_VERSION: "32f288e61fee8528931bcd55bf106cf0cfb4e2a1"
jobs:
build:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.8", "3.12"]
steps:
# Checkout Repository
- name: Checkout
uses: actions/checkout@v4
- name: Setup CCache
uses: hendrikmuhs/[email protected]
with:
create-symlink: true
# Install Tools
- name: Install Tools
run: |
sudo apt-get install wget build-essential ninja-build libtool libtool-bin
sudo apt-get install libevent-dev libjson-c-dev flex bison
sudo apt-get install libfl-dev libfl2 zlib1g-dev libncurses5-dev
sudo apt-get install llvm gnat help2man mold clang lld
- name: Set up SBT
uses: sbt/setup-sbt@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "setup.py"
- name: Install Python dependencies
run: |
python3 -m pip install setuptools requests pexpect meson
# Install GCC Toolchains
- name: Install GCC Toolchains
run: |
sudo python3 litex_setup.py --gcc=riscv
sudo python3 litex_setup.py --gcc=openrisc
sudo python3 litex_setup.py --gcc=powerpc
# Build / Install crosstool-ng
- name: Cache crosstool-ng
id: cache-crosstool-ng
uses: actions/cache@v3
with:
path: crosstool-ng
key: crosstool-ng-${{ env.CT_NG_VERSION }}-${{ runner.os }}
- name: Checkout crosstool-ng
if: steps.cache-crosstool-ng.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: crosstool-ng/crosstool-ng
ref: ${{ env.CT_NG_VERSION }}
path: crosstool-ng
- name: Build crosstool-ng
if: steps.cache-crosstool-ng.outputs.cache-hit != 'true'
run: |
cd crosstool-ng
./bootstrap
./configure
make -j$(nproc)
- name: Install crosstool-ng
run: |
cd crosstool-ng
sudo make install
- name: Cache x-tools
id: cache-x-tools
uses: actions/cache@v3
with:
path: x-tools
key: x-tools-${{ runner.os }}
- name: Build lm32 toolchain
if: steps.cache-x-tools.outputs.cache-hit != 'true'
run: |
unset LD_LIBRARY_PATH
ct-ng lm32-unknown-elf
sed -i -e '/CT_LOG_PROGRESS_BAR/s/y$/n/' .config
sed -i -e '/CT_LOCAL_TARBALLS_DIR/s/HOME/CT_TOP_DIR/' .config
sed -i -e '/CT_PREFIX_DIR/s/HOME/CT_TOP_DIR/' .config
ct-ng build
- name: Add toolchains to PATH
run: |
for d in $(pwd)/x-tools/*/bin; do echo "$d" >> $GITHUB_PATH; done
# Build / Install GHDL
- name: Cache GHDL
id: cache-ghdl
uses: actions/cache@v3
with:
path: ghdl
key: ghdl-${{ env.GHDL_VERSION }}-${{ runner.os }}
- name: Checkout GHDL
if: steps.cache-ghdl.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: ghdl/ghdl
ref: ${{ env.GHDL_VERSION }}
path: ghdl
- name: Build GHDL
if: steps.cache-ghdl.outputs.cache-hit != 'true'
run: |
cd ghdl
./configure --with-llvm-config
make -j$(nproc)
- name: Install GHDL
run: |
cd ghdl
sudo make install
# Build / Install Verilator
- name: Cache Verilator
id: cache-verilator
uses: actions/cache@v3
with:
path: verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ runner.os }}
- name: Checkout Verilator
if: steps.cache-verilator.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: verilator/verilator
ref: ${{ env.VERILATOR_VERSION }}
path: verilator
- name: Build Verilator
if: steps.cache-verilator.outputs.cache-hit != 'true'
run: |
cd verilator
autoconf
./configure CC=clang CXX=clang++
make -j$(nproc)
- name: Install Verilator
run: |
cd verilator
sudo make install
# Install (n)Migen / LiteX / Cores
- name: Install LiteX
run: |
python3 litex_setup.py --config=full --init --install --user --dev
# Install Project
- name: Install Project
run: python3 setup.py develop --user
# Test
- name: Run Tests
run: python3 -m unittest discover -v