Closed edgarrmondragon closed 12 months ago
Hello, I never ran it with nox before but I managed to make it work :)
Here is the noxfile I used
import nox
@nox.session
def codspeed(session):
session.install('pytest')
session.install('pytest-codspeed')
session.run('pytest', '--codspeed')
Along with this workflow:
name: benchmarks
on:
workflow_dispatch:
push:
branches:
- "main"
pull_request:
jobs:
benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.12.0"
- name: Install Nox
run: pip install nox
- name: Install dependencies
run: nox --sessions codspeed --install-only
- name: Run the action
uses: CodSpeedHQ/action@v1
with:
run: nox --sessions codspeed --reuse-existing-virtualenvs --no-install
token: ${{ secrets.CODSPEED_TOKEN }}
Splitting the install and the run part by reusing the venv is optional, but it will significantly reduce the time to run everything.
Nox creates a Python virtual environment under .nox/benches but this actions seems to expect dependencies to be installed in the runner's own Python venv because I see the following:
Yes, this is, unfortunately a legacy operation we need to remove in the next major release. #83
I added those details in https://docs.codspeed.io/benchmarks/python#usage-with-nox Don't hesitate to reopen if you think something is missing!
@art049 I tried that and I see a message like this:
Prepare environment
Warning: pytest-codspeed is not installed in your environment. Installing it...
Which may be the reason why CodSpeed is reporting a performance degradation when I tried it.
I'm following the docs to set up CodSpeed for a public Python project.
The project uses Nox to manage environments, so I'd want it to also use Nox to run benchmarks. The project already uses
pytest-benchmark
for this purpose, but I seem unable to use this action with that approach.Here's what the step looks like:
Nox creates a Python virtual environment under
.nox/benches
but this actions seems to expect dependencies to be installed in the runner's own Python venv because I see the following:Locally, running with Nox works:
I'm also unsure how I would use Poetry directly if I gave up on using Nox:
poetry install
doesn't seem to cut it because of the same issue of having a managed virtual environment, so maybepoetry export > requirements.txt
followed bypip install -r requirements.txt
?Thanks in advance!