diff --git a/.forgejo/workflows/deps.yml b/.forgejo/workflows/deps.yml new file mode 100644 index 0000000..3b7e537 --- /dev/null +++ b/.forgejo/workflows/deps.yml @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# See Notices.txt for copyright information +on: + workflow_call: + outputs: + cache-primary-key: + value: ${{ jobs.deps.outputs.cache-primary-key }} + +jobs: + deps: + runs-on: debian-12 + outputs: + cache-primary-key: ${{ steps.restore-deps.outputs.cache-primary-key }} + steps: + - uses: https://code.forgejo.org/actions/checkout@v3 + with: + fetch-depth: 0 + - uses: https://code.forgejo.org/actions/cache/restore@v3 + id: restore-deps + with: + path: deps + key: deps-${{ runner.os }}-${{ hashFiles('.forgejo/workflows/deps.yml') }} + lookup-only: true + - name: Install Apt packages + if: steps.restore-deps.outputs.cache-hit != 'true' + run: | + apt-get update -qq + apt-get install -qq \ + bison \ + build-essential \ + ccache \ + clang \ + cvc5 \ + flex \ + gawk \ + g++ \ + git \ + libboost-filesystem-dev \ + libboost-python-dev \ + libboost-system-dev \ + libffi-dev \ + libreadline-dev \ + lld \ + pkg-config \ + python3 \ + python3-click \ + tcl-dev \ + zlib1g-dev + - name: Install Firtool + if: steps.restore-deps.outputs.cache-hit != 'true' + run: | + mkdir -p deps + wget -O deps/firrtl.tar.gz https://github.com/llvm/circt/releases/download/firtool-1.86.0/firrtl-bin-linux-x64.tar.gz + sha256sum -c - <<<'bf6f4ab18ae76f135c944efbd81e25391c31c1bd0617c58ab0592640abefee14 deps/firrtl.tar.gz' + tar -C deps -xvaf deps/firrtl.tar.gz + rm -rf deps/firtool + mv deps/firtool-1.86.0 deps/firtool + - name: Get SymbiYosys + if: steps.restore-deps.outputs.cache-hit != 'true' + run: | + git clone --depth=1 --branch=yosys-0.45 https://github.com/YosysHQ/sby.git deps/sby + - name: Build Z3 + if: steps.restore-deps.outputs.cache-hit != 'true' + run: | + git clone --depth=1 --recursive --branch=z3-4.13.3 https://github.com/Z3Prover/z3.git deps/z3 + (cd deps/z3; PYTHON=python3 ./configure --prefix=/usr/local) + make -C deps/z3/build -j"$(nproc)" + - name: Build Yosys + if: steps.restore-deps.outputs.cache-hit != 'true' + run: | + git clone --depth=1 --recursive --branch=0.45 https://github.com/YosysHQ/yosys.git deps/yosys + make -C deps/yosys -j"$(nproc)" + - uses: https://code.forgejo.org/actions/cache/save@v3 + if: steps.restore-deps.outputs.cache-hit != 'true' + with: + path: deps + key: ${{ steps.restore-deps.outputs.cache-primary-key }} diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 1246015..969d691 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -3,8 +3,11 @@ on: [push, pull_request] jobs: + deps: + uses: ./.forgejo/workflows/deps.yml test: runs-on: debian-12 + needs: deps steps: - uses: https://code.forgejo.org/actions/checkout@v3 with: @@ -33,39 +36,21 @@ jobs: python3-click \ tcl-dev \ z3 \ - zlib1g-dev \ - - name: Cache ccache dir - uses: https://code.forgejo.org/actions/cache@v3 - with: - path: .ccache - key: ${{ runner.os }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}- - - name: Setup ccache - run: | - ccache --set-config=cache_dir="${{ github.workspace }}/.ccache" - ccache --set-config=compression=true - ccache --set-config=compression_level=6 - ccache -M 4G - ccache -z - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" - echo "$PATH" >> "$GITHUB_PATH" + zlib1g-dev - run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.80.1 source "$HOME/.cargo/env" echo "$PATH" >> "$GITHUB_PATH" + - uses: https://code.forgejo.org/actions/cache/restore@v3 + with: + path: deps + key: ${{ needs.deps.outputs.cache-primary-key }} + fail-on-cache-miss: true - run: | - git clone --depth=1 --branch=yosys-0.45 https://github.com/YosysHQ/sby.git - make -C sby install - - run: | - git clone --depth=1 --recursive --branch=0.45 https://github.com/YosysHQ/yosys.git - make -C yosys -j2 - make -C yosys install - - run: | - wget -O firrtl.tar.gz https://github.com/llvm/circt/releases/download/firtool-1.86.0/firrtl-bin-linux-x64.tar.gz - sha256sum -c - <<<'bf6f4ab18ae76f135c944efbd81e25391c31c1bd0617c58ab0592640abefee14 firrtl.tar.gz' - tar -xvaf firrtl.tar.gz - export PATH="$(realpath firtool-1.86.0/bin):$PATH" + make -C deps/z3/build install + make -C deps/sby install + make -C deps/yosys install + export PATH="$(realpath deps/firtool/bin):$PATH" echo "$PATH" >> "$GITHUB_PATH" - uses: https://github.com/Swatinem/rust-cache@v2 with: