Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look into caching .tox in GitHub actions #2

Closed
jonathansick opened this issue Feb 11, 2020 · 3 comments
Closed

Look into caching .tox in GitHub actions #2

jonathansick opened this issue Feb 11, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@jonathansick
Copy link
Member

If we can cache .tox in GitHub Actions we could speed up the CI a lot. However, in practice, I find that Tox won't run from a cached .tox directory. It could be worth looking into this.

The workflow is:

name: Python CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python:
          - 3.7
          - 3.8

    steps:
      - uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python }}

      - name: Install tox
        run: pip install tox

      - name: Cache tox environments
        id: cache-tox
        uses: actions/cache@v1
        with:
          path: .tox
          # setup.cfg, pyproject.toml, and .pre-commit-config.yaml have
          # versioning info that would impact the tox environment. hashFiles
          # only takes a single file path or pattern at the moment.
          key: ${{ runner.os }}-${{ matrix.python }}-tox-${{ hashFiles('setup.cfg') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}

      - name: Run tox
        run: tox -e py,lint,typing  # run tox using Python in path

The error is:

 Run tox 1s
15
##[error]Process completed with exit code 2.
1
Run tox -e py,lint,typing
6
ERROR: invocation failed (exit code 1), logfile: /home/runner/work/safir/safir/.tox/.package/log/.package-4.log
7
================================== log start ===================================
8
Traceback (most recent call last):
9
  File "/opt/hostedtoolcache/Python/3.8.1/x64/lib/python3.8/site-packages/tox/helper/build_requires.py", line 7, in <module>
10
    backend = __import__(backend_spec, fromlist=[None])
11
ModuleNotFoundError: No module named 'setuptools'
12

13
=================================== log end ====================================
14
ERROR: FAIL could not package project - v = InvocationError("/home/runner/work/safir/safir/.tox/.package/bin/python /opt/hostedtoolcache/Python/3.8.1/x64/lib/python3.8/site-packages/tox/helper/build_requires.py setuptools.build_meta ''", 1)
15
##[error]Process completed with exit code 2.
@jonathansick jonathansick added the enhancement New feature or request label Feb 11, 2020
@rra
Copy link
Member

rra commented Mar 16, 2022

We are now caching the tox environments and everything seems to work fine, so presumably this is a bug that was subsequently fixed.

@hughesadam87
Copy link

@rra you're caching tox like this or some other way?

  - name: Cache tox environments
    id: cache-tox
    uses: actions/cache@v1
    with:
      path: .tox

@rra
Copy link
Member

rra commented Sep 27, 2023

We're using the https://github.com/lsst-sqre/run-tox shared action now, but internally it does the following:

    - name: Cache tox environments
      id: cache-tox
      uses: actions/cache@v3
      if: fromJSON(${{ inputs.use-cache }})
      with:
        path: ${{ inputs.working-directory }}/.tox
        # setup.cfg and pyproject.toml have versioning info that would
        # impact the tox environment.
        key: ${{ inputs.cache-key-prefix}}-${{ inputs.python-version }}-${{ hashFiles('pyproject.toml', 'setup.cfg') }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants