From 4b5aabb5de7ba99bd6ea0d091743fbb1d6bcbb93 Mon Sep 17 00:00:00 2001 From: Brad Keryan Date: Mon, 14 Apr 2025 12:12:40 -0500 Subject: [PATCH] github: Add caching --- .github/workflows/build.yml | 8 +++++++- .github/workflows/generate_docs.yml | 8 ++++++++ .github/workflows/run_system_tests.yml | 7 +++++++ .github/workflows/run_unit_tests.yml | 17 +++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7405eebc9..92958bd97 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,13 +6,14 @@ on: jobs: build: name: Build - runs-on: + runs-on: - ubuntu-latest steps: - name: Check out repo uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 + id: setup-python with: # The codegen scripts require Python 3.9 or later. python-version: "3.9" @@ -22,6 +23,11 @@ jobs: poetry-version: "1.8.3" - name: Check Poetry version run: poetry --version + - name: Cache virtualenv (all extras) + uses: actions/cache@v4 + with: + path: .venv + key: nidaqmx-all-extras-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/generate_docs.yml b/.github/workflows/generate_docs.yml index 6ba998f6f..567ee3d09 100644 --- a/.github/workflows/generate_docs.yml +++ b/.github/workflows/generate_docs.yml @@ -13,6 +13,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 + id: setup-python with: python-version: "3.9" - name: Set up Poetry @@ -21,6 +22,13 @@ jobs: poetry-version: "1.8.3" - name: Check Poetry version run: poetry --version + - name: Cache virtualenvs + uses: actions/cache@v4 + with: + path: | + .venv + .tox + key: generate-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/run_system_tests.yml b/.github/workflows/run_system_tests.yml index 2f8f0f42c..224f9dba0 100644 --- a/.github/workflows/run_system_tests.yml +++ b/.github/workflows/run_system_tests.yml @@ -23,6 +23,13 @@ jobs: uses: actions/checkout@v4 - name: Import DAQmx config run: C:\nidaqmxconfig\targets\win64U\x64\msvc-14.0\release\nidaqmxconfig.exe --eraseconfig --import tests\max_config\nidaqmxMaxConfig.ini + - name: Cache virtualenvs + uses: actions/cache@v4 + with: + path: | + .venv + .tox + key: run-system-tests-${{ runner.os }}-${{ matrix.configuration }}-${{ hashFiles('poetry.lock') }} - name: Install dependencies run: poetry install - name: Run system tests diff --git a/.github/workflows/run_unit_tests.yml b/.github/workflows/run_unit_tests.yml index 8d6a6c7a5..63ea22138 100644 --- a/.github/workflows/run_unit_tests.yml +++ b/.github/workflows/run_unit_tests.yml @@ -28,12 +28,29 @@ jobs: poetry-version: "1.8.3" - name: Check Poetry version run: poetry --version + - name: Restore cached virtualenv (main only) + uses: actions/cache/restore@v4 + id: restore-nidaqmx-main-only + with: + path: .venv + key: nidaqmx-main-only-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} - name: Install main package dependencies run: | python -m pip install --upgrade pip poetry install --only main - name: check installdriver subcommand can be invoked run: poetry run nidaqmx installdriver --help + - name: Save cached virtualenv (main only) + uses: actions/cache/save@v4 + if: steps.restore-nidaqmx-main-only.outputs.cache-hit != 'true' + with: + path: .venv + key: ${{ steps.restore-nidaqmx-main-only.outputs.cache-primary-key }} + - name: Cache virtualenv (with dev dependencies) + uses: actions/cache@v4 + with: + path: .venv + key: nidaqmx-with-dev-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} - name: Install dev dependencies run: poetry install - name: Run unit tests