Skip to content
Draft
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
58 changes: 50 additions & 8 deletions .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ on:
CHIPFLOW_API_KEY:
required: true

permissions:
contents: write

jobs:
test-submit:
test-all:
runs-on: ubuntu-latest
strategy:
matrix:
dry: [true, false]
repo:
- name: "ChipFlow/chipflow-examples"
design: "minimal"
artifact: chipflow-examples
env:
DRY: ${{ matrix.dry && '--dry-run' || '' }}
is_dry: ${{ matrix.dry && '(dry run)' || '' }}
Expand All @@ -36,18 +40,34 @@ jobs:
path: ${{ env.test_repo_path }}

- name: Check for branch ${{ github.head_ref }}
id: check-head-ref
working-directory: ${{ env.test_repo_path }}
if: github.event_name == 'pull_request'
run: |
git remote update
git checkout ${{ github.head_ref }} || echo "${{github.head_ref}} not found, checking base ${{github.base_ref}}"
git checkout ${{ github.head_ref }}
if [ $? -eq 0 ]; then
echo "Using branch ${{github.head_ref}}"
echo "found-branch=1\n" >> $GITHUB_OUTPUT
else
echo "${{github.head_ref}} not found, checking base ${{github.base_ref}}"
echo "found-branch=0\n" >> $GITHUB_OUTPUT
fi

- name: Check for branch ${{ github.base_ref }}
working-directory: ${{ env.test_repo_path }}
if: github.event_name == 'pull_request'
id: check-base-ref
working-directory: ${{ env.test_repo_path }}x
if: github.event_name == 'pull_request' && steps.check-head-ref == 0
run: |
git remote update
git checkout ${{ github.base_ref }} || echo "${{github.base_ref}} not found Falling back to main"
git checkout ${{ github.base_ref }}
if [ $? -eq 0 ]; then
echo "Using branch ${{github.base_ref}}"
echo "found-branch=1\n" >> $GITHUB_OUTPUT
else
|| echo "${{github.base_ref}} not found Falling back to main"
echo "found-branch=0\n" >> $GITHUB_OUTPUT
fi


- name: Set up PDM
Expand All @@ -65,12 +85,34 @@ jobs:
- name: Run tests
working-directory: ${{ env.test_repo_path }}
run: |
pdm test
pdm test-cov

- name: Run sim
working-directory: ${{ env.test_repo_path }}/${{ matrix.repo.design }}
run: |
pdm run coverage run -a ../.venv/bin/chipflow pin lock
pdm run coverage run -a ../.venv/bin/chipflow sim
pdm run coverage run -a ../.venv/bin/chipflow software
./build/sim/sim_soc

- name: Submit build ${{ env.is_dry }}
working-directory: ${{ env.test_repo_path }}/${{ matrix.repo.design }}
run: |
pdm run chipflow pin lock
pdm run chipflow silicon submit --wait $DRY | cat
pdm run coverage run -a ../.venv/bin/chipflow pin lock
pdm run coverage run -a ../.venv/bin/chipflow silicon submit --wait $DRY | cat
env:
CHIPFLOW_API_KEY: ${{ secrets.CHIPFLOW_API_KEY}}

- name: Generate coverage report
working-directory: ${{ env.test_repo_path }}/${{ matrix.repo.design }}
run: pdm run coverage html

- name: deploy to Github Pages
uses: robtaylor/github-pages-deploy-action@10882fae8fe8df6ed2aec9be2ac59f7c828c898c
with:
folder: '${{ env.test_repo_path }}/${{ matrix.repo.design }}/htmlcov/'
branch: gh-pages
clean: false
force: false
silent: false
target-folder: coverage-${{matrix.artifact}}-${{matrix.dry}}
2 changes: 1 addition & 1 deletion chipflow_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _ensure_chipflow_root():

if os.environ["CHIPFLOW_ROOT"] not in sys.path:
sys.path.append(os.environ["CHIPFLOW_ROOT"])
_ensure_chipflow_root.root = os.environ["CHIPFLOW_ROOT"]
_ensure_chipflow_root.root = Path(os.environ["CHIPFLOW_ROOT"]).absolute()
return _ensure_chipflow_root.root


Expand Down
10 changes: 9 additions & 1 deletion chipflow_lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ class UnexpectedError(ChipFlowError):

log_level = logging.WARNING


DEFAULT_STEPS = {
"silicon": "chipflow_lib.steps.silicon:SiliconStep",
"sim": "chipflow_lib.steps.sim:SimStep",
}


def run(argv=sys.argv[1:]):
config = _parse_config()

commands = {}
commands["pin"] = PinCommand(config)

for step_name, step_reference in config["chipflow"]["steps"].items():
steps = DEFAULT_STEPS | config["chipflow"]["steps"]
for step_name, step_reference in steps.items():
step_cls = _get_cls_by_reference(step_reference, context=f"step `{step_name}`")
try:
commands[step_name] = step_cls(config)
Expand Down
Loading
Loading