Skip to content

Commit 0ce8de2

Browse files
committed
Use overrides for using the same branchname over multiple repos
1 parent 95ac3d8 commit 0ce8de2

File tree

4 files changed

+72
-68
lines changed

4 files changed

+72
-68
lines changed

.github/workflows/coverage.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ jobs:
2525
- name: Set up PDM
2626
uses: pdm-project/setup-pdm@v4
2727

28+
- name: Generate overrides to use current branch if PR
29+
if: github.event_name == 'pull_request'
30+
run: |
31+
pdm run tools/gen_overrides.py ${{github.head_ref}} > overrides.txt
32+
echo "Generated overrides:"
33+
cat overrides.txt
34+
35+
- name: Relock PDM
36+
if: github.event_name != 'pull_request'
37+
run: pdm lock -d
38+
39+
- name: Relock PDM (PR)
40+
if: github.event_name == 'pull_request'
41+
run: pdm lock -d --override overrides.txt
42+
2843
- name: Install dependencies
2944
run: |
3045
pdm install

.github/workflows/main.yaml

Lines changed: 38 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ jobs:
1919
- name: Set up PDM
2020
uses: pdm-project/setup-pdm@v4
2121

22-
- name: Re-lock PDM dependencies
23-
run: pdm lock -d
24-
25-
- name: Install dependencies
26-
run: pdm install
22+
- name: Install dependencies with multirepo
23+
uses: chipflow/pdm-multirepo@v1
2724

2825
- name: Run tests
2926
run: pdm run test
@@ -42,89 +39,62 @@ jobs:
4239
with:
4340
fetch-depth: 0
4441
- name: Check source code licenses
45-
run: |
46-
docker run --platform=linux/amd64 -v ${PWD}:/src ghcr.io/google/addlicense -v -check -l BSD-2-Clause -c "ChipFlow" -s=only -ignore **/__init__.py **/*.py
42+
run: ./tools/license_check.sh
4743

4844
test-submit:
4945
runs-on: ubuntu-latest
46+
strategy:
47+
matrix:
48+
dry: [true, false]
49+
repo:
50+
- name: "ChipFlow/chipflow-examples"
51+
design: "minimal"
52+
env:
53+
DRY: ${{ matrix.dry && '--dry-run' || '' }}
54+
is_dry: ${{ matrix.dry && '(dry run)' || '' }}
55+
our_path: "${{ github.workspace}}/${{ github.repo }}"
56+
test_repo_path: "${{ github.workspace }}/${{ matrix.repo.name }}"
57+
58+
name: ${{ matrix.dry && 'Test Submit - Dry run' || 'Test submit' }}
59+
5060
steps:
5161
- name: Check out source code
5262
uses: actions/checkout@v4
5363
with:
54-
fetch-depth: 0
55-
path: chipflow-lib
64+
path: ${{ env.our_path }}
5665

57-
- name: Check out chipflow-examples
66+
- name: Check out ${{ matrix.repo.name }}
5867
uses: actions/checkout@v4
5968
with:
60-
repository: ChipFlow/chipflow-examples
61-
fetch-depth: 0
62-
path: chipflow-examples
69+
repository: ${{ matrix.repo.name }}
70+
path: ${{ env.test_repo_path }}
6371

64-
- name: Set up PDM
65-
uses: pdm-project/setup-pdm@v4
66-
with:
67-
python-version: "3.10"
68-
cache: true
69-
cache-dependency-path: "./**/pyproject.toml"
70-
71-
- name: Re-lock PDM dependencies
72-
working-directory: ./chipflow-examples
73-
run: pdm lock -d
74-
75-
- name: Install dependencies
76-
working-directory: ./chipflow-examples
72+
- name: Check for branch ${{ github.head_ref }}
73+
working-directory: ${{ env.test_repo_path }}
74+
if: github.event_name == 'pull_request'
7775
run: |
78-
pdm install
79-
pdm run python -m ensurepip
80-
pdm run python -m pip install -e ../chipflow-lib
81-
82-
- name: Run tests
83-
working-directory: ./chipflow-examples/minimal
84-
run: |
85-
pdm test
86-
pdm run chipflow pin lock
87-
pdm run chipflow silicon submit --wait
88-
env:
89-
CHIPFLOW_API_KEY: ${{ secrets.CHIPFLOW_API_KEY}}
90-
91-
test-submit-dry:
92-
runs-on: ubuntu-latest
93-
steps:
94-
- name: Check out source code
95-
uses: actions/checkout@v4
96-
with:
97-
fetch-depth: 0
98-
path: chipflow-lib
99-
100-
- name: Check out chipflow-examples
101-
uses: actions/checkout@v4
102-
with:
103-
repository: ChipFlow/chipflow-examples
104-
fetch-depth: 0
105-
path: chipflow-examples
76+
git remote update
77+
git checkout ${{ github.head_ref }} || echo "Falling back to main"
10678
10779
- name: Set up PDM
10880
uses: pdm-project/setup-pdm@v4
10981
with:
110-
python-version: "3.10"
82+
python-version: '3.10'
11183
cache: true
112-
cache-dependency-path: "./**/pyproject.toml"
84+
cache-dependency-path: './**/pyproject.toml'
11385

114-
- name: Re-lock PDM dependencies
115-
working-directory: ./chipflow-examples
116-
run: pdm lock -d
117-
118-
- name: Install dependencies
119-
working-directory: ./chipflow-examples
120-
run: |
121-
pdm install
122-
pdm run python -m ensurepip
123-
pdm run python -m pip install -e ../chipflow-lib
86+
- name: Install dependencies with multirepo
87+
uses: chipflow/pdm-multirepo@v1
12488

12589
- name: Run tests
126-
working-directory: ./chipflow-examples/minimal
90+
working-directory: ${{ env.test_repo_path }}
12791
run: |
12892
pdm test
93+
94+
- name: Submit build ${{ env.is_dry }}
95+
working-directory: ${{ env.test_repo_path }}/${{ matrix.repo.design }}
96+
run: |
12997
pdm run chipflow pin lock
130-
pdm run chipflow silicon submit --dry-run
98+
pdm run chipflow silicon submit --wait $DRY
99+
env:
100+
CHIPFLOW_API_KEY: ${{ secrets.CHIPFLOW_API_KEY}}

.github/workflows/preview-docs.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ jobs:
2020
python-version: 3.12
2121
cache: true
2222

23+
- name: Generate overrides to use current branch if PR
24+
if: github.event_name == 'pull_request'
25+
run: |
26+
pdm run tools/gen_overrides.py ${{github.head_ref}} > overrides.txt
27+
echo "Generated overrides:"
28+
cat overrides.txt
29+
30+
- name: Relock PDM
31+
if: github.event_name != 'pull_request'
32+
run: pdm lock -d
33+
34+
- name: Relock PDM (PR)
35+
if: github.event_name == 'pull_request'
36+
run: pdm lock -d --override overrides.txt
37+
2338
- name: Install dependencies
2439
run: pdm install
2540

tools/license_check.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
docker run --platform=linux/amd64 -v ${PWD}:/src ghcr.io/google/addlicense -v -check -l BSD-2-Clause -c "ChipFlow" -s=only -ignore **/__init__.py **/*.py
3+
4+

0 commit comments

Comments
 (0)