Skip to content

Commit 367b5d0

Browse files
authored
github: Add virtualenv caching (#702)
1 parent f80501f commit 367b5d0

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ on:
66
jobs:
77
build:
88
name: Build
9-
runs-on:
9+
runs-on:
1010
- ubuntu-latest
1111
steps:
1212
- name: Check out repo
1313
uses: actions/checkout@v4
1414
- name: Set up Python
1515
uses: actions/setup-python@v5
16+
id: setup-python
1617
with:
1718
# The codegen scripts require Python 3.9 or later.
1819
python-version: "3.9"
@@ -22,6 +23,11 @@ jobs:
2223
poetry-version: "1.8.3"
2324
- name: Check Poetry version
2425
run: poetry --version
26+
- name: Cache virtualenv (all extras)
27+
uses: actions/cache@v4
28+
with:
29+
path: .venv
30+
key: nidaqmx-all-extras-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
2531
- name: Install dependencies
2632
run: |
2733
python -m pip install --upgrade pip

.github/workflows/generate_docs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
uses: actions/checkout@v4
1414
- name: Set up Python
1515
uses: actions/setup-python@v5
16+
id: setup-python
1617
with:
1718
python-version: "3.9"
1819
- name: Set up Poetry
@@ -21,6 +22,13 @@ jobs:
2122
poetry-version: "1.8.3"
2223
- name: Check Poetry version
2324
run: poetry --version
25+
- name: Cache virtualenvs
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
.venv
30+
.tox
31+
key: generate-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
2432
- name: Install dependencies
2533
run: |
2634
python -m pip install --upgrade pip

.github/workflows/run_system_tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ jobs:
2323
uses: actions/checkout@v4
2424
- name: Import DAQmx config
2525
run: C:\nidaqmxconfig\targets\win64U\x64\msvc-14.0\release\nidaqmxconfig.exe --eraseconfig --import tests\max_config\nidaqmxMaxConfig.ini
26+
- name: Cache virtualenvs
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
.venv
31+
.tox
32+
key: run-system-tests-${{ runner.os }}-${{ matrix.configuration }}-${{ hashFiles('poetry.lock') }}
2633
- name: Install dependencies
2734
run: poetry install
2835
- name: Run system tests

.github/workflows/run_unit_tests.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,29 @@ jobs:
2828
poetry-version: "1.8.3"
2929
- name: Check Poetry version
3030
run: poetry --version
31+
- name: Restore cached virtualenv (main only)
32+
uses: actions/cache/restore@v4
33+
id: restore-nidaqmx-main-only
34+
with:
35+
path: .venv
36+
key: nidaqmx-main-only-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
3137
- name: Install main package dependencies
3238
run: |
3339
python -m pip install --upgrade pip
3440
poetry install --only main
3541
- name: check installdriver subcommand can be invoked
3642
run: poetry run nidaqmx installdriver --help
43+
- name: Save cached virtualenv (main only)
44+
uses: actions/cache/save@v4
45+
if: steps.restore-nidaqmx-main-only.outputs.cache-hit != 'true'
46+
with:
47+
path: .venv
48+
key: ${{ steps.restore-nidaqmx-main-only.outputs.cache-primary-key }}
49+
- name: Cache virtualenv (with dev dependencies)
50+
uses: actions/cache@v4
51+
with:
52+
path: .venv
53+
key: nidaqmx-with-dev-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
3754
- name: Install dev dependencies
3855
run: poetry install
3956
- name: Run unit tests

0 commit comments

Comments
 (0)