Replace Squeaky CI advice with custom advice (#897)

Closes https://github.com/Qiskit/documentation/issues/838.

Replaces the message in CI with correct instructions for our repository.
I've added a switch to remove the advice from the printed message, I
think this is the neatest net logic change:
33e24f8eb6.


<img width="600" alt="Screenshot 2024-02-27 at 17 20 42"
src="https://github.com/Qiskit/documentation/assets/36071638/dff70ada-2eca-4041-83fd-e0177bc52bca">

See https://github.com/frankharkins/documentation/pull/2 for the test
PR.

This doesn't display the message when running `tox -e lint`, but I think
it's unlikely a contributor would run that command locally without first
encountering it in CI.

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
This commit is contained in:
Frank Harkins 2024-02-27 18:14:29 +00:00 committed by GitHub
parent c703c5c952
commit 5c9c97b520
4 changed files with 23 additions and 5 deletions

View File

@ -77,12 +77,23 @@ jobs:
- name: Check lint
shell: python
run: |
import subprocess
import subprocess, sys
files = """${{ steps.all-changed-files.outputs.all_changed_files }}"""
args = ["tox", "-e", "lint", "--"] + files.split("\n")
try:
subprocess.run(args, check=True)
except:
print(
"To fix, install `tox` and run `tox -e fix` or download the fixed "
"notebook from this run by clicking \"Summary\" on the upper-left "
"of this page, and downloading the \"Executed notebooks\" artifact."
"\n\n"
"For more information, see https://github.com/Qiskit/documentation/blob/main/README.md#lint-notebooks"
)
sys.exit(1)
- name: Execute notebooks
if: "!cancelled()"
shell: python
run: |
import subprocess
@ -91,6 +102,7 @@ jobs:
subprocess.run(args, check=True)
- name: Upload executed notebooks
if: "!cancelled()"
uses: actions/upload-artifact@v4
with:
name: Executed notebooks

View File

@ -148,7 +148,13 @@ page, click "Summary", then download "Executed notebooks".
## Lint notebooks
We use [`squeaky`](https://github.com/frankharkins/squeaky) to lint our
notebooks. To check if a notebook needs linting:
notebooks. First install `tox` using [pipx](https://pipx.pypa.io/stable/).
```sh
pipx install tox
```
To check if a notebook needs linting:
```sh
# Check all notebooks in ./docs

View File

@ -6,4 +6,4 @@ ipykernel~=6.29.2
qiskit[all]~=1.0
qiskit-aer~=0.13.1
qiskit-ibm-runtime~=0.19.1
squeaky==0.5.0
squeaky==0.6.0

View File

@ -9,7 +9,7 @@ setenv = PYDEVD_DISABLE_FILE_VALIDATION=1
commands = python scripts/nb-tester/test-notebook.py {posargs}
[testenv:lint]
commands = squeaky --check {posargs}
commands = squeaky --check --no-advice {posargs}
[testenv:fix]
commands = squeaky {posargs}