Skip to content

Commit b8f76e3

Browse files
authored
Merge pull request #292 from efabless/precheck_ci
Precheck ci
2 parents 75f9de2 + 292c81d commit b8f76e3

File tree

2 files changed

+125
-1
lines changed

2 files changed

+125
-1
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: MPW Precheck
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
mpw-precheck:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
include:
14+
- repo: 'caravel_user_project'
15+
skip_checks: 'default gpio_defines'
16+
- repo: 'caravel_user_mini'
17+
skip_checks: ''
18+
- repo: 'caravel_user_sram'
19+
skip_checks: 'gpio_defines lvs'
20+
- repo: 'caravel_user_project_analog'
21+
skip_checks: 'default gpio_defines lvs'
22+
- repo: 'openframe_timer_example'
23+
skip_checks: ''
24+
fail-fast: false
25+
26+
steps:
27+
- name: Checkout efabless/mpw_precheck
28+
uses: actions/checkout@v3
29+
with:
30+
repository: efabless/mpw_precheck
31+
path: mpw_precheck
32+
33+
- name: Checkout ${{ matrix.repo }}
34+
uses: actions/checkout@v3
35+
with:
36+
repository: efabless/${{ matrix.repo }}
37+
path: ${{ matrix.repo }}
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v2
41+
42+
- name: Cache Docker layers
43+
uses: actions/cache@v3
44+
with:
45+
path: /tmp/.buildx-cache
46+
key: ${{ runner.os }}-buildx-${{ hashFiles('mpw_precheck/dependencies/Dockerfile') }}
47+
restore-keys: |
48+
${{ runner.os }}-buildx-
49+
50+
- name: Build Docker image
51+
run: |
52+
docker buildx create --use
53+
docker buildx build \
54+
--cache-from=type=local,src=/tmp/.buildx-cache \
55+
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max \
56+
--output type=docker \
57+
--tag mpw_precheck:latest \
58+
mpw_precheck/dependencies
59+
timeout-minutes: 30 # Increased timeout to 30 minutes
60+
61+
- name: Move cache
62+
run: |
63+
rm -rf /tmp/.buildx-cache
64+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
65+
66+
- name: Cache PDK
67+
id: cache-pdk
68+
uses: actions/cache@v3
69+
with:
70+
path: ${{ github.workspace }}/pdk
71+
key: ${{ runner.os }}-pdk-${{ hashFiles('**/volare.toml') }}
72+
73+
- name: Install Volare and PDK
74+
if: steps.cache-pdk.outputs.cache-hit != 'true'
75+
run: |
76+
python3 -m pip install --upgrade --no-cache-dir volare
77+
volare enable 6d4d11780c40b20ee63cc98e645307a9bf2b2ab8 --pdk-root ${{ github.workspace }}/pdk
78+
env:
79+
PDK_ROOT: ${{ github.workspace }}/pdk
80+
81+
- name: Run MPW Precheck
82+
run: |
83+
export INPUT_DIRECTORY=${{ github.workspace }}/${{ matrix.repo }}
84+
export PRECHECK_ROOT=${{ github.workspace }}/mpw_precheck
85+
export OUTPUT_DIRECTORY=$INPUT_DIRECTORY/mpw_precheck_result
86+
export OUTPUT=$OUTPUT_DIRECTORY/logs/precheck.log
87+
export PDK_ROOT=${{ github.workspace }}/pdk
88+
export PDKPATH=$PDK_ROOT/sky130A
89+
90+
SKIP_CHECKS_ARG=""
91+
if [ -n "${{ matrix.skip_checks }}" ]; then
92+
SKIP_CHECKS_ARG="--skip_checks ${{ matrix.skip_checks }}"
93+
fi
94+
95+
docker run -v "$PRECHECK_ROOT":"$PRECHECK_ROOT" \
96+
-v "$INPUT_DIRECTORY":"$INPUT_DIRECTORY" \
97+
-v "$PDK_ROOT":"$PDK_ROOT" \
98+
-e INPUT_DIRECTORY="$INPUT_DIRECTORY" \
99+
-e PDK_ROOT="$PDK_ROOT" \
100+
-e PDKPATH="$PDKPATH" \
101+
-u $(id -u "$USER"):$(id -g "$USER") \
102+
mpw_precheck:latest \
103+
bash -c "cd $PRECHECK_ROOT && python3 mpw_precheck.py --input_directory $INPUT_DIRECTORY --pdk_path $PDKPATH --output_directory $OUTPUT_DIRECTORY --skip_checks $SKIP_CHECKS_ARG"
104+
105+
if grep -q "All Checks Passed" "$OUTPUT"; then
106+
echo "All checks passed for ${{ matrix.repo }}"
107+
exit 0
108+
else
109+
echo "Checks failed for ${{ matrix.repo }}"
110+
exit 1
111+
fi
112+
113+
- name: Upload MPW Precheck output
114+
uses: actions/upload-artifact@v3
115+
if: failure()
116+
with:
117+
name: mpw-precheck-results-${{ matrix.repo }}
118+
path: ${{ github.workspace }}/${{ matrix.repo }}/mpw_precheck_result

mpw_precheck.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def main(*args, **kwargs):
109109
parser.add_argument('-o', '--output_directory', required=False, help="OUTPUT_DIRECTORY, default=<input_directory>/precheck_results/DD_MMM_YYYY___HH_MM_SS.")
110110
parser.add_argument('--private', action='store_true', help=f"If provided, precheck skips {open_source_checks.keys() - private_checks.keys()} checks that qualify the project to be Open Source")
111111
parser.add_argument('checks', metavar='check', type=str, nargs='*', choices=list(open_source_checks.keys()).append([]), help=f"Checks to be run by the precheck: {' '.join(open_source_checks.keys())}")
112+
parser.add_argument('--skip_checks', metavar='check', type=str, nargs='*', choices=list(open_source_checks.keys()).append([]), help=f"Checks not to be run by the precheck: {' '.join(open_source_checks.keys())}")
112113
args = parser.parse_args()
113114

114115
# NOTE Separated to allow the option later on for a run tag
@@ -129,7 +130,12 @@ def main(*args, **kwargs):
129130
logging.critical("`GOLDEN_CARAVEL` environment variable is not set. Please set it to point to absolute path to the golden caravel")
130131
sys.exit(1)
131132

132-
sequence = args.checks if args.checks else [x for x in private_checks.keys()] if args.private else [x for x in open_source_checks.keys()]
133+
all_checks = [check.lower() for check in (private_checks.keys() if args.private else open_source_checks.keys())]
134+
input_checks = [check.lower() for check in args.checks] if args.checks else all_checks
135+
skip_checks = [check.lower() for check in args.skip_checks] if args.skip_checks else []
136+
input_checks = [check for check in input_checks if check in all_checks]
137+
skip_checks = [check for check in skip_checks if check in all_checks]
138+
sequence = [check for check in input_checks if check not in skip_checks]
133139

134140
main(input_directory=args.input_directory,
135141
output_directory=output_directory,

0 commit comments

Comments
 (0)