From a9e77c32ed78932b743f5129cc26bb4ccfd6efa1 Mon Sep 17 00:00:00 2001 From: KotlinIsland Date: Fri, 9 Dec 2022 08:24:36 +1000 Subject: [PATCH] =?UTF-8?q?=E2=9D=8C=20Don't=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_wheels.yml | 20 ---- .github/workflows/docs.yml | 33 ------ .github/workflows/mypy_primer.yml | 82 --------------- .github/workflows/mypy_primer_comment.yml | 98 ------------------ .github/workflows/sync_typeshed.yml | 33 ------ .github/workflows/test.yml | 117 ---------------------- .github/workflows/test_stubgenc.yml | 30 ------ mypyc/test/test_run.py | 6 ++ tox.ini | 3 +- 9 files changed, 8 insertions(+), 414 deletions(-) delete mode 100644 .github/workflows/build_wheels.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/mypy_primer.yml delete mode 100644 .github/workflows/mypy_primer_comment.yml delete mode 100644 .github/workflows/sync_typeshed.yml delete mode 100644 .github/workflows/test_stubgenc.yml diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml deleted file mode 100644 index 7edfa03584c1c..0000000000000 --- a/.github/workflows/build_wheels.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Trigger wheel build - -on: - push: - branches: [master, 'release*'] - tags: ['*'] - -jobs: - build-wheels: - if: github.repository == 'python/mypy' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.7' - - name: Trigger script - env: - WHEELS_PUSH_TOKEN: ${{ secrets.WHEELS_PUSH_TOKEN }} - run: ./misc/trigger_wheel_build.sh diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 9f984e3a346ba..0000000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Check documentation build - -on: - workflow_dispatch: - push: - branches: [master, 'release*'] - tags: ['*'] - pull_request: - paths: - - 'docs/**' - - 'mypyc/doc/**' - - '**/*.rst' - - '**/*.md' - - CREDITS - - LICENSE - -jobs: - docs: - runs-on: ubuntu-latest - env: - TOXENV: docs - TOX_SKIP_MISSING_INTERPRETERS: False - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.7' - - name: Install tox - run: pip install --upgrade 'setuptools!=50' tox==3.24.5 - - name: Setup tox environment - run: tox -e ${{ env.TOXENV }} --notest - - name: Test - run: tox -e ${{ env.TOXENV }} --skip-pkg-install diff --git a/.github/workflows/mypy_primer.yml b/.github/workflows/mypy_primer.yml deleted file mode 100644 index d26372aa66359..0000000000000 --- a/.github/workflows/mypy_primer.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Run mypy_primer - -on: - # Only run on PR, since we diff against master - pull_request: - paths-ignore: - - 'docs/**' - - '**/*.rst' - - '**/*.md' - - 'misc/**' - - 'mypyc/**' - - 'mypy/stubtest.py' - - 'mypy/stubgen.py' - - 'mypy/stubgenc.py' - - 'mypy/test/**' - - 'test-data/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - mypy_primer: - name: Run mypy_primer - runs-on: ubuntu-latest - permissions: - contents: read - strategy: - matrix: - shard-index: [0, 1, 2, 3, 4] - fail-fast: false - steps: - - uses: actions/checkout@v3 - with: - path: mypy_to_test - fetch-depth: 0 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install -U pip - pip install git+https://github.com/hauntsaninja/mypy_primer.git - - name: Run mypy_primer - shell: bash - run: | - cd mypy_to_test - echo "new commit" - git rev-list --format=%s --max-count=1 $GITHUB_SHA - - MERGE_BASE=$(git merge-base $GITHUB_SHA origin/master) - git checkout -b base_commit $MERGE_BASE - echo "base commit" - git rev-list --format=%s --max-count=1 base_commit - - echo '' - cd .. - # fail action if exit code isn't zero or one - ( - mypy_primer \ - --repo mypy_to_test \ - --new $GITHUB_SHA --old base_commit \ - --num-shards 5 --shard-index ${{ matrix.shard-index }} \ - --debug \ - --output concise \ - | tee diff_${{ matrix.shard-index }}.txt - ) || [ $? -eq 1 ] - - name: Upload mypy_primer diff - uses: actions/upload-artifact@v3 - with: - name: mypy_primer_diffs - path: diff_${{ matrix.shard-index }}.txt - - if: ${{ matrix.shard-index }} == 0 - name: Save PR number - run: | - echo ${{ github.event.pull_request.number }} | tee pr_number.txt - - if: ${{ matrix.shard-index }} == 0 - name: Upload PR number - uses: actions/upload-artifact@v3 - with: - name: mypy_primer_diffs - path: pr_number.txt diff --git a/.github/workflows/mypy_primer_comment.yml b/.github/workflows/mypy_primer_comment.yml deleted file mode 100644 index b20eaf471c9a3..0000000000000 --- a/.github/workflows/mypy_primer_comment.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Comment with mypy_primer diff - -on: - workflow_run: - workflows: - - Run mypy_primer - types: - - completed - -permissions: - contents: read - pull-requests: write - -jobs: - comment: - name: Comment PR from mypy_primer - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Download diffs - uses: actions/github-script@v6 - with: - script: | - const fs = require('fs'); - const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{ github.event.workflow_run.id }}, - }); - const [matchArtifact] = artifacts.data.artifacts.filter((artifact) => - artifact.name == "mypy_primer_diffs"); - - const download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: "zip", - }); - fs.writeFileSync("diff.zip", Buffer.from(download.data)); - - - run: unzip diff.zip - - run: | - cat diff_*.txt | tee fulldiff.txt - - - name: Post comment - id: post-comment - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const MAX_CHARACTERS = 30000 - const MAX_CHARACTERS_PER_PROJECT = MAX_CHARACTERS / 3 - - const fs = require('fs') - let data = fs.readFileSync('fulldiff.txt', { encoding: 'utf8' }) - - function truncateIfNeeded(original, maxLength) { - if (original.length <= maxLength) { - return original - } - let truncated = original.substring(0, maxLength) - // further, remove last line that might be truncated - truncated = truncated.substring(0, truncated.lastIndexOf('\n')) - let lines_truncated = original.split('\n').length - truncated.split('\n').length - return `${truncated}\n\n... (truncated ${lines_truncated} lines) ...` - } - - const projects = data.split('\n\n') - // don't let one project dominate - data = projects.map(project => truncateIfNeeded(project, MAX_CHARACTERS_PER_PROJECT)).join('\n\n') - // posting comment fails if too long, so truncate - data = truncateIfNeeded(data, MAX_CHARACTERS) - - console.log("Diff from mypy_primer:") - console.log(data) - - let body - if (data.trim()) { - body = 'Diff from [mypy_primer](https://github.com/hauntsaninja/mypy_primer), showing the effect of this PR on open source code:\n```diff\n' + data + '```' - } else { - body = 'According to [mypy_primer](https://github.com/hauntsaninja/mypy_primer), this change has no effect on the checked open source code. 🤖🎉' - } - const prNumber = parseInt(fs.readFileSync("pr_number.txt", { encoding: "utf8" })) - await github.rest.issues.createComment({ - issue_number: prNumber, - owner: context.repo.owner, - repo: context.repo.repo, - body - }) - return prNumber - - - name: Hide old comments - # v0.3.0 - uses: kanga333/comment-hider@bbdf5b562fbec24e6f60572d8f712017428b92e0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - leave_visible: 1 - issue_number: ${{ steps.post-comment.outputs.result }} diff --git a/.github/workflows/sync_typeshed.yml b/.github/workflows/sync_typeshed.yml deleted file mode 100644 index 1db2e846f099d..0000000000000 --- a/.github/workflows/sync_typeshed.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Sync typeshed - -on: - workflow_dispatch: - schedule: - - cron: "0 0 1,15 * *" - -permissions: - contents: write - pull-requests: write - -jobs: - sync_typeshed: - name: Sync typeshed - if: github.repository == 'python/mypy' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # TODO: use whatever solution ends up working for - # https://github.com/python/typeshed/issues/8434 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: git config - run: | - git config --global user.name mypybot - git config --global user.email '<>' - - name: Sync typeshed - run: | - python -m pip install requests==2.28.1 - GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python misc/sync-typeshed.py --make-pr diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a02378cc01ab0..aaa59b6278bb6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,123 +20,6 @@ concurrency: cancel-in-progress: true jobs: - main: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: Test suite with py37-windows-64 - python: '3.7' - arch: x64 - os: windows-latest - toxenv: py37 - - name: Test suite with py38-ubuntu - python: '3.8' - arch: x64 - os: ubuntu-latest - toxenv: py - tox_extra_args: "-n 2" - - name: Test suite with py39-ubuntu - python: '3.9' - arch: x64 - os: ubuntu-latest - toxenv: py - tox_extra_args: "-n 2" - - name: Test suite with py37-ubuntu, mypyc-compiled - python: '3.7' - arch: x64 - os: ubuntu-latest - toxenv: py - tox_extra_args: "-n 2" - test_mypyc: true - - name: Test suite with py310-ubuntu, mypyc-compiled - python: '3.10' - arch: x64 - os: ubuntu-latest - toxenv: py - tox_extra_args: "-n 2" - test_mypyc: true - - name: Test suite with py310-ubuntu - python: '3.10' - arch: x64 - os: ubuntu-latest - toxenv: py - tox_extra_args: "-n 2" - - name: Test suite with py311-ubuntu, mypyc-compiled - python: '3.11' - arch: x64 - os: ubuntu-latest - toxenv: py - tox_extra_args: "-n 2" - test_mypyc: true - - name: mypyc runtime tests with py37-macos - python: '3.7' - arch: x64 - os: macos-latest - toxenv: py - tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py" - - name: mypyc runtime tests with py37-debug-build-ubuntu - python: '3.7.13' - arch: x64 - os: ubuntu-latest - toxenv: py - tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py" - debug_build: true - - name: Type check our own code (py37-ubuntu) - python: '3.7' - arch: x64 - os: ubuntu-latest - toxenv: type - - name: Type check our own code (py37-windows-64) - python: '3.7' - arch: x64 - os: windows-latest - toxenv: type - - name: Formatting with Black + isort and code style with flake8 - python: '3.7' - arch: x64 - os: ubuntu-latest - toxenv: lint - - name: ${{ matrix.name }} - env: - TOX_SKIP_MISSING_INTERPRETERS: False - # Rich (pip) - FORCE_COLOR: 1 - # Tox - PY_COLORS: 1 - # Mypy (see https://github.com/python/mypy/issues/7771) - TERM: xterm-color - MYPY_FORCE_COLOR: 1 - MYPY_FORCE_TERMINAL_WIDTH: 200 - # Pytest - PYTEST_ADDOPTS: --color=yes - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: ${{ matrix.arch }} - - name: Debug build - if: ${{ matrix.debug_build }} - run: | - PYTHONVERSION=${{ matrix.python }} - PYTHONDIR=~/python-debug/python-$PYTHONVERSION - VENV=$PYTHONDIR/env - ./misc/build-debug-python.sh $PYTHONVERSION $PYTHONDIR $VENV - source $VENV/bin/activate - - name: Install tox - run: pip install --upgrade 'setuptools!=50' tox==3.24.5 - - name: Compiled with mypyc - if: ${{ matrix.test_mypyc }} - run: | - pip install -r test-requirements.txt - CC=clang MYPYC_OPT_LEVEL=0 MYPY_USE_MYPYC=1 pip install -e . - - name: Setup tox environment - run: tox -e ${{ matrix.toxenv }} --notest - - name: Test - run: tox -e ${{ matrix.toxenv }} --skip-pkg-install -- ${{ matrix.tox_extra_args }} python-nightly: runs-on: ubuntu-latest diff --git a/.github/workflows/test_stubgenc.yml b/.github/workflows/test_stubgenc.yml deleted file mode 100644 index b48031e5c18f6..0000000000000 --- a/.github/workflows/test_stubgenc.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Test stubgenc on pybind11-mypy-demo - -on: - workflow_dispatch: - push: - branches: [master, 'release*'] - tags: ['*'] - pull_request: - paths: - - 'misc/test-stubgenc.sh' - - 'mypy/stubgenc.py' - - 'mypy/stubdoc.py' - - 'test-data/stubgen/**' - -jobs: - stubgenc: - # Check stub file generation for a small pybind11 project - # (full text match is required to pass) - runs-on: ubuntu-latest - steps: - - - uses: actions/checkout@v3 - - - name: Setup 🐍 3.8 - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Test stubgenc - run: misc/test-stubgenc.sh diff --git a/mypyc/test/test_run.py b/mypyc/test/test_run.py index fff775ebfab5f..6b213a2e11643 100644 --- a/mypyc/test/test_run.py +++ b/mypyc/test/test_run.py @@ -312,6 +312,12 @@ def run_case_step(self, testcase: DataDrivenTestCase, incremental_step: int) -> stderr=subprocess.STDOUT, env=env, ) + try: + proc.wait(timeout=0) + except subprocess.TimeoutExpired: + print("Timed out with:") + print(proc.stdout.read().decode()) + raise output = proc.communicate()[0].decode("utf8") outlines = output.splitlines() diff --git a/tox.ini b/tox.ini index a155ec7263869..3511786918aa3 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,8 @@ isolated_build = true description = run the test driver with {basepython} passenv = PYTEST_XDIST_WORKER_COUNT PROGRAMDATA PROGRAMFILES(X86) PYTEST_ADDOPTS deps = -rtest-requirements.txt -commands = python -m pytest {posargs} +commands = + python -m pytest -vvv -n0 mypyc/test/test_run.py::TestRun::run-functions.test::testDecorators1 [testenv:lint] description = check the code style