Skip to content

Commit 9372dc1

Browse files
authored
CI: parallelize tasks, and support local 'act' runs (#69)
most work is now parallelized. If running locally with act, only 3.8 is run - this is because typically that's where most of the errors (like typing) will be found (e.g. stuff that's supported post-3.8 won't break unless tried on 3.8) On act, pip package caching doesn't work (via actions/setup-python); instead, run act with -r. After the first run, it should complete in ~30-40s.
1 parent 53255a4 commit 9372dc1

File tree

4 files changed

+51
-26
lines changed

4 files changed

+51
-26
lines changed

.github/workflows/main.yml

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,62 @@
22

33
name: MLGO CI
44

5-
on: [push]
5+
on: [push, repository_dispatch]
66

77
jobs:
8-
build:
8+
LicenseCheck:
99
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- run: ./check-license.sh
13+
Envvars:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
version_matrix: ${{ steps.set-output.outputs.version_matrix }}
17+
do_cache: ${{ steps.set-output.outputs.do_cache }}
18+
steps:
19+
- id: set-output
20+
run: |
21+
if [ -z $ACT ]
22+
then
23+
_ver="[3.8, 3.9]"
24+
_cache="1"
25+
else
26+
_ver="[3.8]"
27+
_cache="0"
28+
fi
29+
echo "::set-output name=version_matrix::$_ver"
30+
echo "::set-output name=do_cache::$_cache"
31+
Checks:
32+
runs-on: ubuntu-latest
33+
needs: [Envvars]
1034
strategy:
1135
matrix:
12-
python-version: ["3.8", "3.9"]
36+
python-version: ${{ fromJSON(needs.Envvars.outputs.version_matrix) }}
37+
task: [Typecheck, Lint, Yapf, Test]
38+
include:
39+
- task: Typecheck
40+
cmd: pytype -j auto .
41+
- task: Lint
42+
cmd: pylint --rcfile .pylintrc --recursive yes .
43+
- task: Yapf
44+
cmd: yapf . -drp
45+
- task: Test
46+
cmd: pytest
1347
steps:
1448
- uses: actions/checkout@v3
15-
- name: Set up Python ${{ matrix.python-version }}
49+
- name: Install Python With Cached pip Packages
50+
if: needs.Envvars.outputs.do_cache == '1'
1651
uses: actions/setup-python@v3
1752
with:
1853
python-version: ${{ matrix.python-version }}
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install -r dev-requirements.txt
23-
pip install -r ./compiler_opt/benchmark/requirements.txt
24-
pylint --version
25-
- name: Type check
26-
run: |
27-
pytype -j auto .
28-
- name: Test
29-
run: |
30-
pytest
31-
- name: Lint
32-
run: |
33-
pylint --rcfile .pylintrc --recursive yes .
34-
- name: Check License Header
35-
run: |
36-
./check-license.sh
37-
- name: yapf formatting check
38-
run: |
39-
yapf . -drp
54+
cache: 'pip'
55+
cache-dependency-path: '**/requirements*.txt'
56+
- name: Install Python, no cache
57+
if: needs.Envvars.outputs.do_cache == '0'
58+
uses: actions/setup-python@v3
59+
with:
60+
python-version: ${{ matrix.python-version }}
61+
- run: pip install -r requirements-ci.txt -q
62+
- name: ${{ matrix.task }}
63+
run: ${{ matrix.cmd }}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
-r ../../requirements.txt
21
joblib==1.1.0

requirements-ci.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-r requirements-dev.txt
2+
-r ./compiler_opt/benchmark/requirements.txt
File renamed without changes.

0 commit comments

Comments
 (0)