Skip to content

Commit 3dba1e2

Browse files
committed
Add caching of python deps in CI
1 parent 152dd06 commit 3dba1e2

File tree

4 files changed

+72
-10
lines changed

4 files changed

+72
-10
lines changed

.github/workflows/pip.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,24 @@ jobs:
1414
steps:
1515
- name: checkout
1616
uses: actions/checkout@v6
17+
# Note that in the requirements.txt,
18+
# we find the latest "compatible release" of drake
19+
# using ~=. This means that, with the caching disabled,
20+
# poetry will find the most recent version of drake
21+
# that uses the same major number. With the caching enabled, however,
22+
# setup-python will use the version of drake that is in the cache,
23+
# until the requirements.txt file is updated
24+
# (see the cache-dependency-path argument below).
25+
# We update the requirements.txt file monthly after a new minor
26+
# version of drake using automated renovate PRs.
27+
# Note that between a new minor release of drake and the renovate
28+
# PR for that release being merged in, setup-python will
29+
# pull in the older version of drake.
1730
- name: python setup
1831
uses: actions/setup-python@v6
1932
with:
2033
python-version: ${{ env.PYTHON_VERSION }}
34+
cache: 'pip'
2135
- name: venv setup and install
2236
working-directory: drake_pip
2337
run: |

.github/workflows/poetry.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,31 @@ jobs:
1414
steps:
1515
- name: checkout
1616
uses: actions/checkout@v6
17+
- name: install poetry
18+
working-directory: drake_poetry
19+
run: .github/setup
20+
# Note that in the pyproject.toml,
21+
# we find the latest "compatible release" of drake
22+
# using ~=. This means that, with the caching disabled,
23+
# poetry will find the most recent version of drake
24+
# that uses the same major number. With the caching enabled, however,
25+
# setup-python will use the version of drake that is in the cache,
26+
# until the pyproject.toml file is updated
27+
# (see the cache-dependency-path argument below).
28+
# We update the pyproject.toml file monthly after a new minor
29+
# version of drake using automated renovate PRs.
30+
# Note that between a new minor release of drake and the renovate
31+
# PR for that release being merged in, setup-python will
32+
# pull in the older version of drake.
1733
- name: python setup
1834
uses: actions/setup-python@v6
1935
with:
2036
python-version: ${{ env.PYTHON_VERSION }}
37+
cache: 'poetry'
38+
cache-dependency-path: 'drake_poetry/pyproject.toml'
2139
- name: poetry setup
2240
working-directory: drake_poetry
2341
run: |
24-
.github/setup
2542
args=(--python-version $PYTHON_VERSION)
2643
if [[ '${{ github.event.inputs.mac_arm_sequoia_wheel }}' != '' ]]; then
2744
args+=(--wheel-url ${{ github.event.inputs.mac_arm_sequoia_wheel }})
@@ -35,17 +52,30 @@ jobs:
3552
ubuntu_noble_poetry:
3653
name: ubuntu 24.04 noble
3754
runs-on: ubuntu-latest
55+
env:
56+
PYTHON_VERSION: '3.12'
3857
container: ubuntu:noble
3958
steps:
4059
- name: checkout
4160
uses: actions/checkout@v6
42-
# setup and test must occur in one step
43-
# because when poetry is installed, the update to PATH
44-
# does not persist between steps on GHA
45-
- name: poetry setup and test
61+
- name: install poetry
4662
working-directory: drake_poetry
63+
# When poetry is installed, the update to the PATH
64+
# environment variable does not persist between steps on
65+
# GHA. Thus, we update the path after installing.
4766
run: |
4867
.github/setup
68+
PIPX_BIN=$(pipx environment --value PIPX_BIN_DIR)
69+
echo "$PIPX_BIN" >> $GITHUB_PATH
70+
- name: python setup
71+
uses: actions/setup-python@v6
72+
with:
73+
python-version: ${{ env.PYTHON_VERSION }}
74+
cache: 'poetry'
75+
cache-dependency-path: 'drake_poetry/pyproject.toml'
76+
- name: poetry setup and test
77+
working-directory: drake_poetry
78+
run: |
4979
source $HOME/.profile
5080
args=()
5181
if [[ '${{ github.event.inputs.linux_noble_wheel }}' != '' ]]; then

drake_pip/.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
uses: actions/setup-python@v6
3838
with:
3939
python-version: ${{ env.PYTHON_VERSION }}
40+
cache: 'pip'
4041
- name: venv setup and install
4142
working-directory: drake_pip
4243
run: |

drake_poetry/.github/workflows/ci.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ jobs:
3333
steps:
3434
- name: checkout
3535
uses: actions/checkout@v6
36+
- name: install poetry
37+
working-directory: drake_poetry
38+
run: .github/setup
3639
- name: python setup
3740
uses: actions/setup-python@v6
3841
with:
3942
python-version: ${{ env.PYTHON_VERSION }}
43+
cache: 'poetry'
44+
cache-dependency-path: 'drake_poetry/pyproject.toml'
4045
- name: poetry setup
4146
working-directory: drake_poetry
4247
run: |
43-
.github/setup
4448
args=(--python-version $PYTHON_VERSION)
4549
if [[ '${{ github.event.inputs.mac_arm_sequoia_wheel }}' != '' ]]; then
4650
args+=(--wheel-url ${{ github.event.inputs.mac_arm_sequoia_wheel }})
@@ -54,17 +58,30 @@ jobs:
5458
ubuntu_noble_poetry:
5559
name: ubuntu 24.04 noble
5660
runs-on: ubuntu-latest
61+
env:
62+
PYTHON_VERSION: '3.12'
5763
container: ubuntu:noble
5864
steps:
5965
- name: checkout
6066
uses: actions/checkout@v6
61-
# setup and test must occur in one step
62-
# because when poetry is installed, the update to PATH
63-
# does not persist between steps on GHA
64-
- name: poetry setup and test
67+
- name: install poetry
6568
working-directory: drake_poetry
69+
# When poetry is installed, the update to the PATH
70+
# environment variable does not persist between steps on
71+
# GHA. Thus, we update the path after installing.
6672
run: |
6773
.github/setup
74+
PIPX_BIN=$(pipx environment --value PIPX_BIN_DIR)
75+
echo "$PIPX_BIN" >> $GITHUB_PATH
76+
- name: python setup
77+
uses: actions/setup-python@v6
78+
with:
79+
python-version: ${{ env.PYTHON_VERSION }}
80+
cache: 'poetry'
81+
cache-dependency-path: 'drake_poetry/pyproject.toml'
82+
- name: poetry setup and test
83+
working-directory: drake_poetry
84+
run: |
6885
source $HOME/.profile
6986
args=()
7087
if [[ '${{ github.event.inputs.linux_noble_wheel }}' != '' ]]; then

0 commit comments

Comments
 (0)