Skip to content

Commit 28e3295

Browse files
authored
Add GHA for circular imports regressions (#46436)
1 parent 314a3fb commit 28e3295

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/valid-style.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,62 @@ jobs:
8787
spack -d bootstrap now --dev
8888
spack style -t black
8989
spack unit-test -V
90+
import-check:
91+
runs-on: ubuntu-latest
92+
steps:
93+
- uses: julia-actions/setup-julia@v2
94+
with:
95+
version: '1.10'
96+
- uses: julia-actions/cache@v2
97+
98+
# PR: use the base of the PR as the old commit
99+
- name: Checkout PR base commit
100+
if: github.event_name == 'pull_request'
101+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
102+
with:
103+
ref: ${{ github.event.pull_request.base.sha }}
104+
path: old
105+
# not a PR: use the previous commit as the old commit
106+
- name: Checkout previous commit
107+
if: github.event_name != 'pull_request'
108+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
109+
with:
110+
fetch-depth: 2
111+
path: old
112+
- name: Checkout previous commit
113+
if: github.event_name != 'pull_request'
114+
run: git -C old reset --hard HEAD^
115+
116+
- name: Checkout new commit
117+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
118+
with:
119+
path: new
120+
- name: Install circular import checker
121+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
122+
with:
123+
repository: haampie/circular-import-fighter
124+
ref: 555519c6fd5564fd2eb844e7b87e84f4d12602e2
125+
path: circular-import-fighter
126+
- name: Install dependencies
127+
working-directory: circular-import-fighter
128+
run: make -j dependencies
129+
- name: Import cycles before
130+
working-directory: circular-import-fighter
131+
run: make SPACK_ROOT=../old && cp solution solution.old
132+
- name: Import cycles after
133+
working-directory: circular-import-fighter
134+
run: make clean-graph && make SPACK_ROOT=../new && cp solution solution.new
135+
- name: Compare import cycles
136+
working-directory: circular-import-fighter
137+
run: |
138+
edges_before="$(grep -oP 'edges to delete: \K\d+' solution.old)"
139+
edges_after="$(grep -oP 'edges to delete: \K\d+' solution.new)"
140+
if [ "$edges_after" -gt "$edges_before" ]; then
141+
printf '\033[1;31mImport check failed: %s imports need to be deleted, ' "$edges_after"
142+
printf 'previously this was %s\033[0m\n' "$edges_before"
143+
printf 'Compare \033[1;97m"Import cycles before"\033[0m and '
144+
printf '\033[1;97m"Import cycles after"\033[0m to see problematic imports.\n'
145+
exit 1
146+
else
147+
printf '\033[1;32mImport check passed: %s <= %s\033[0m\n' "$edges_after" "$edges_before"
148+
fi

0 commit comments

Comments
 (0)