Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local runner cache #250

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/actions/setup_env/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FASM2BELS_COMMIT ?= master

install_fasm2bels:
rm -rf ${BFASST_PATH_FASM2BELS}
git clone https://github.com/chipsalliance/f4pga-xc-fasm2bels.git ${BFASST_PATH_FASM2BELS}
cd ${BFASST_PATH_FASM2BELS} && git reset --hard ${FASM2BELS_COMMIT}
cd ${BFASST_PATH_FASM2BELS} && make env
cd ${BFASST_PATH_FASM2BELS} && make build
cd ${BFASST_PATH_FASM2BELS} && make test-py

cd ../../.. && python scripts/run_design.py designs/basic/and3/ xilinx_and_reversed



25 changes: 24 additions & 1 deletion .github/actions/setup_env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# TODO: Use https://github.com/actions/cache to cache rapidwright tool

name: "Setup Environment"

inputs:
cache_path:
description: "Path to local runner cache"

runs:
using: "composite"
steps:
Expand All @@ -22,10 +27,28 @@ runs:
run: |
make env

- name: fasm2bels_env
shell: bash
run: |
if [[ -n "${{ inputs.cache_path }}" ]]; then
echo "BFASST_PATH_FASM2BELS=${{ inputs.cache_path }}/fasm2bels" >> "$GITHUB_ENV"
fi

- name: fasm2bels
shell: bash
run: |
make install_fasm2bels
if [[ -n "${{ inputs.cache_path }}" ]]; then
# Check if cache file matches current commit
FASM2BELS_COMMIT=$(git submodule status third_party/fasm2bels/ | awk '{print $1}')
if [ -f ${{ inputs.cache_path }}/fasm2bels_commit.txt ] && [ $FASM2BELS_COMMIT == $(cat ${{ inputs.cache_path }}/fasm2bels_commit.txt) ]; then
# Successful cache, do nothing
echo "Using cached version of fasm2bels"
else
echo "Installing cached version of fasm2bels"
. .venv/bin/activate && cd $GITHUB_ACTION_PATH && CACHE_PATH=${{ inputs.cache_path }} FASM2BELS_COMMIT=$FASM2BELS_COMMIT make install_fasm2bels
echo $FASM2BELS_COMMIT > ${{ inputs.cache_path }}/fasm2bels_commit.txt
fi
fi

- name: fasm2bels_artifacts
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
with:
submodules: 'recursive'
- uses: ./.github/actions/setup_env
with:
cache_path: $HOME/actions-runner/cache
- name: experiments
timeout-minutes: 30
run: |
Expand Down
7 changes: 7 additions & 0 deletions bfasst/paths.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Repository paths using pathlib """

import pathlib
import os

ROOT_PATH = pathlib.Path(__file__).resolve().parent.parent

Expand All @@ -15,3 +16,9 @@
YOSYS_RESOURCES = RESOURCES_PATH / "yosys"
ONESPIN_RESOURCES = RESOURCES_PATH / "onespin"
YOSYS_INSTALL_DIR = THIRD_PARTY_PATH / "yosys"


def get_fasm2bels_path():
if "BFASST_PATH_FASM2BELS" in os.environ:
return pathlib.Path(os.environ["BFASST_PATH_FASM2BELS"])
return THIRD_PARTY_PATH / "fasm2bels"
2 changes: 1 addition & 1 deletion bfasst/reverse_bit/xray.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class XRayReverseBitTool(ReverseBitTool):
def __init__(self, cwd, design, flow_args):
super().__init__(cwd, design, flow_args)

self.fasm2bels_path = paths.ROOT_PATH / "third_party" / "fasm2bels"
self.fasm2bels_path = paths.get_fasm2bels_path()
self.fasm2bels_python_path = (
self.fasm2bels_path
/ "env"
Expand Down