Skip to content

Commit

Permalink
Add nox target for tests without reports in pyenv
Browse files Browse the repository at this point in the history
Internal-tag: [#53659]
Signed-off-by: Robert Szczepanski <[email protected]>
  • Loading branch information
robertszczepanski committed Feb 27, 2024
1 parent 64b970a commit 6568f74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lint:
- tuttest README.md | bash -
script:
- cd examples/$EXAMPLE
- tuttest README.md generate | bash -
- tuttest README.md install-deps,generate | bash -

run_tests:
stage: test
Expand Down Expand Up @@ -83,7 +83,7 @@ run_tests:
- python3 -m pip install git+https://github.com/antmicro/tuttest
- tuttest README.md | bash -
script:
- nox -s test_all_in_env
- nox -s tests_with_reports_in_env

generate_hdmi:
extends: .generate_example
Expand All @@ -110,9 +110,9 @@ build_docs:
stage: build_docs
tags: ['ace-x86_64']
before_script:
- cd docs
- pip3 install -r requirements.txt
- pip3 install -r docs/requirements.txt
script:
- cd docs
- echo -en "\nhtml_js_files = [ '$ANNOTANT' ]" >> source/conf.py
- make html latexpdf
- cp build/latex/*.pdf build/html/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
- name: Run pytest with nox
run: |
source venv/bin/activate
nox -s test_all_in_env
nox -s tests_with_reports_in_env
Examples:
runs-on: ubuntu-latest
Expand Down
17 changes: 14 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def tests_with_report(session: nox.Session) -> None:
session.run("pytest", "-rs", "--cov-report", "html:cov_html", "--cov=fpga_topwrap", "tests")


@nox.session
def test_all_in_env(session: nox.Session) -> None:
def prepare_pyenv(session: nox.Session) -> dict:
project_dir = os.path.dirname(os.path.abspath(__file__))
pyenv_dir = f"{project_dir}/build/.pyenv"
pyenv_bin = f"{os.path.join(pyenv_dir, 'bin')}"
Expand All @@ -76,7 +75,7 @@ def test_all_in_env(session: nox.Session) -> None:
env["PATH"] = path
env["PYENV_ROOT"] = pyenv_dir

# Install pyenv
# Install Pyenv
if not shutil.which("pyenv", path=path):
p = subprocess.run(
"curl https://pyenv.run | bash",
Expand Down Expand Up @@ -127,4 +126,16 @@ def test_all_in_env(session: nox.Session) -> None:
if p.returncode:
session.error()

return env


@nox.session
def tests_in_env(session: nox.Session) -> None:
env = prepare_pyenv(session)
session.run("nox", "-s", "tests", external=True, env=env)


@nox.session
def tests_with_reports_in_env(session: nox.Session) -> None:
env = prepare_pyenv(session)
session.run("nox", "-s", "tests_with_report", external=True, env=env)

0 comments on commit 6568f74

Please sign in to comment.