From 9ed111f2b24f731eca1b84c332b320de2db74902 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 13 Apr 2022 10:19:19 -0500 Subject: [PATCH 1/7] clean up ci --- .github/workflows/test.yml | 98 +++++++++++++++++++++++++++----------- .pre-commit-config.yaml | 6 +++ pyproject.toml | 11 +++++ setup.cfg | 6 +++ 4 files changed, 93 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 03a3fda..2dec7bf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,15 @@ name: Python package on: push: pull_request: - branches: ["master"] + schedule: + - cron: "0 8 * * *" + +concurrency: + group: >- + ${{ github.workflow }}- + ${{ github.ref_type }}- + ${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true jobs: build: @@ -15,42 +23,76 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: [3.7, 3.8, 3.9, "3.10", pypy-3.7] - exclude: - # pywin32 not available + python-version: ["3.7", "3.10"] + include: - os: windows-latest - python-version: "3.10" + python-version: "3.9" + - os: ubuntu-latest + python-version: "pypy-3.8" + - os: macos-latest + python-version: "3.8" steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: pip cache - uses: actions/cache@v2 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: | - ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('dev-requirements.txt', 'setup.cfg') }} - restore-keys: | - ${{ runner.os }}-pip-${{ matrix.python-version }}- - ${{ runner.os }}-pip- + - with: jupyterlab/maintainer-tools/.github/actions/base-action@v1 - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install --upgrade setuptools wheel pip install -r dev-requirements.txt . - name: Test with pytest run: | - pytest -vv jupyter_core --timeout 60 --cov jupyter_core --cov-report term-missing:skip-covered - - name: Check manifest + python -m pytest -vv jupyter_core --timeout 60 --cov jupyter_core --cov-report term-missing:skip-covered + + test_miniumum_versions: + name: Test Minimum Versions + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - name: Base Setup + uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + with: + python_version: "3.7" + - name: Install miniumum versions + uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1 + - name: Run the unit tests + run: pytest -vv -W default traitlets || pytest -vv -W default traitlets --lf + + test_prereleases: + name: Test Prereleases + timeout-minutes: 10 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Base Setup + uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - name: Install the Python dependencies + run: | + pip install --upgrade --upgrade-strategy eager --pre -e ".[test]" + - name: List installed packages + run: | + pip freeze + pip check + - name: Run the tests run: | - pip install check-manifest - check-manifest -v + pytest -vv traitlets || pytest -vv traitlets --lf + + make_sdist: + name: Make SDist + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/make-sdist@v1 + + test_sdist: + runs-on: ubuntu-latest + needs: [make_sdist] + name: Install from SDist and Test + timeout-minutes: 20 + steps: + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/test-sdist@v1 pre-commit: name: pre-commit diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4d64ad..7978c66 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,6 +72,12 @@ repos: scripts/jupyter )$ + - repo: https://github.com/mgedmin/check-manifest + rev: '0.48' + hooks: + - id: check-manifest + stages: [manual] + - repo: https://github.com/sirosen/check-jsonschema rev: 0.14.2 hooks: diff --git a/pyproject.toml b/pyproject.toml index f8ea8b2..aac4f58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,3 +27,14 @@ module = [ "entrypoints" ] ignore_missing_imports = true + + +[tool.pytest.ini_options] +addopts = "-raXs --durations 10 --color=yes --doctest-modules --ignore-glob=jupyter_core/tests/dotipython*" +testpaths = [ + "jupyter_core/tests/" +] +filterwarnings= [ + # Fail on warnings + "error" +] diff --git a/setup.cfg b/setup.cfg index d7e6f8e..cfd3221 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,6 +38,12 @@ console_scripts = jupyter-migrate = jupyter_core.migrate:main jupyter-troubleshoot = jupyter_core.troubleshoot:main +[options.extras_require] +test = + pytest + pytest-cov + pytest-timeout + [flake8] ignore = E501, W503, E402 builtins = c, get_config From f665c64be82ae31e40beb2f9e0d8e61537e503de Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 13 Apr 2022 10:22:38 -0500 Subject: [PATCH 2/7] remove dev-requirements.txt --- .github/workflows/test.yml | 2 +- MANIFEST.in | 1 - README.md | 3 +-- dev-requirements.txt | 5 ----- setup.cfg | 2 ++ 5 files changed, 4 insertions(+), 9 deletions(-) delete mode 100644 dev-requirements.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2dec7bf..b069afe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: - with: jupyterlab/maintainer-tools/.github/actions/base-action@v1 - name: Install dependencies run: | - pip install -r dev-requirements.txt . + pip install -e ".[test]" - name: Test with pytest run: | python -m pytest -vv jupyter_core --timeout 60 --cov jupyter_core --cov-report term-missing:skip-covered diff --git a/MANIFEST.in b/MANIFEST.in index 5d16ae4..9a3f619 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include COPYING.md include CONTRIBUTING.md include README.md -include dev-requirements.txt include jupyter_core/py.typed exclude .pre-commit-config.yaml diff --git a/README.md b/README.md index e9884dc..7bb85d4 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,7 @@ Now create an [editable install](https://pip.pypa.io/en/stable/reference/pip_ins and download the dependencies of code and test suite by executing: cd /my/projects/jupyter_core/ - pip install -e . - pip install -r dev-requirements.txt + pip install -e ".[test]" py.test The last command runs the test suite to verify the setup. During development, you can pass filenames to `py.test`, and it will execute only those tests. diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 4dac42c..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -ipykernel -pre-commit -pytest -pytest-cov -pytest-timeout diff --git a/setup.cfg b/setup.cfg index cfd3221..f53fa6c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,6 +40,8 @@ console_scripts = [options.extras_require] test = + ipykernel + pre-commit pytest pytest-cov pytest-timeout From d04f4ea7a51ddbbe1e19cc5852cc9ac2a60cfc36 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 13 Apr 2022 10:23:04 -0500 Subject: [PATCH 3/7] remove dev-requirements.txt --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7978c66..40d5ba1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -73,10 +73,10 @@ repos: )$ - repo: https://github.com/mgedmin/check-manifest - rev: '0.48' + rev: "0.48" hooks: - - id: check-manifest - stages: [manual] + - id: check-manifest + stages: [manual] - repo: https://github.com/sirosen/check-jsonschema rev: 0.14.2 From 72f8813d15d63c8671e46a8a93a41a01e9d1eb99 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 13 Apr 2022 10:28:42 -0500 Subject: [PATCH 4/7] fix workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b069afe..e99da3d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: python-version: "3.8" steps: - uses: actions/checkout@v2 - - with: jupyterlab/maintainer-tools/.github/actions/base-action@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/base-action@v1 - name: Install dependencies run: | pip install -e ".[test]" From 6c74c7265acefbb8b5f6f21f566b19c691441500 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 13 Apr 2022 10:30:58 -0500 Subject: [PATCH 5/7] fix action name --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e99da3d..373829f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: python-version: "3.8" steps: - uses: actions/checkout@v2 - - uses: jupyterlab/maintainer-tools/.github/actions/base-action@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - name: Install dependencies run: | pip install -e ".[test]" From 30fd3f51981e006b8895430a992675aba89c0bed Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 13 Apr 2022 10:32:59 -0500 Subject: [PATCH 6/7] more cleanup in workflow --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 373829f..2e2f485 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: pip install -e ".[test]" - name: Test with pytest run: | - python -m pytest -vv jupyter_core --timeout 60 --cov jupyter_core --cov-report term-missing:skip-covered + python -m pytest -vv --timeout 60 --cov jupyter_core --cov-report term-missing:skip-covered test_miniumum_versions: name: Test Minimum Versions @@ -54,7 +54,7 @@ jobs: - name: Install miniumum versions uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1 - name: Run the unit tests - run: pytest -vv -W default traitlets || pytest -vv -W default traitlets --lf + run: pytest -vv -W default || pytest -vv -W default --lf test_prereleases: name: Test Prereleases @@ -74,7 +74,7 @@ jobs: pip check - name: Run the tests run: | - pytest -vv traitlets || pytest -vv traitlets --lf + pytest -vv || pytest -vv --lf make_sdist: name: Make SDist From b213591984af367ab54644783cc8112d89cc86c8 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 13 Apr 2022 10:44:48 -0500 Subject: [PATCH 7/7] windows fixes --- jupyter_core/tests/test_command.py | 2 +- jupyter_core/tests/test_paths.py | 5 ++++- pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jupyter_core/tests/test_command.py b/jupyter_core/tests/test_command.py index 0be1962..4ef38cd 100644 --- a/jupyter_core/tests/test_command.py +++ b/jupyter_core/tests/test_command.py @@ -56,7 +56,7 @@ def write_executable(path, source): import pkg_resources w = pkg_resources.resource_string("setuptools", "cli-32.exe") - except (ImportError, FileNotFoundError): + except (ImportError, FileNotFoundError, SystemError): pytest.skip("Need pkg_resources/setuptools to make scripts executable on Windows") exe.write(w, "wb") exe.chmod(0o700) diff --git a/jupyter_core/tests/test_paths.py b/jupyter_core/tests/test_paths.py index 1aca383..36811f6 100644 --- a/jupyter_core/tests/test_paths.py +++ b/jupyter_core/tests/test_paths.py @@ -417,7 +417,10 @@ def test_secure_write_win32(): def fetch_win32_permissions(filename): """Extracts file permissions on windows using icacls""" role_permissions = {} - for index, line in enumerate(os.popen("icacls %s" % filename).read().splitlines()): + proc = os.popen("icacls %s" % filename) + lines = proc.read().splitlines() + proc.close() + for index, line in enumerate(lines): if index == 0: line = line.split(filename)[-1].strip().lower() match = re.match(r"\s*([^:]+):\(([^\)]*)\)", line) diff --git a/pyproject.toml b/pyproject.toml index aac4f58..2d139bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,5 +36,5 @@ testpaths = [ ] filterwarnings= [ # Fail on warnings - "error" + "error", ]