From 610ecb772e7dfb25f486d64504e8c3029dff7567 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Tue, 2 Dec 2025 12:07:29 -0500 Subject: [PATCH 1/3] fix: improve CI and helper scripts --- .github/workflows/lint.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/tests.yml | 27 ++------------------------- .github/workflows/typecheck.yml | 29 +++++++++++++++++++++++++++++ requirements/testing.txt | 1 - requirements/tools.txt | 4 +--- scripts/format.sh | 6 ++++-- scripts/lint.sh | 14 ++++++++++++++ scripts/run_integration_tests.sh | 5 +++-- scripts/run_mypy.sh | 3 ++- scripts/run_unit_tests.sh | 6 ++++-- scripts/run_validation.sh | 9 +++++---- 11 files changed, 93 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/typecheck.yml create mode 100755 scripts/lint.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..a85a58459 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,29 @@ +name: Lint + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +env: + PYTHON_VERSION: "3.14" + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + with: + persist-credentials: false + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Run lint verification + run: ./scripts/lint.sh diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac34e26fd..addac2dff 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,3 @@ -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Test on: @@ -11,26 +10,6 @@ on: workflow_dispatch: jobs: - typecheck: - name: Typechecks - runs-on: ubuntu-latest - timeout-minutes: 5 - strategy: - matrix: - python-version: ["3.14"] - permissions: - contents: read - steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - persist-credentials: false - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 - with: - python-version: ${{ matrix.python-version }} - - name: Run mypy verification - run: | - ./scripts/run_mypy.sh unittest: name: Unit tests runs-on: ubuntu-22.04 @@ -48,6 +27,7 @@ jobs: - "3.8" - "3.7" - "pypy3.10" + - "pypy3.11" permissions: contents: read env: @@ -67,10 +47,8 @@ jobs: pip install -U pip pip install -r requirements/testing.txt pip install -r requirements/optional.txt - - name: Run validation (black/flake8/pytest) + - name: Run tests run: | - black --check slack/ slack_sdk/ tests/ integration_tests/ - flake8 slack/ slack_sdk/ PYTHONPATH=$PWD:$PYTHONPATH pytest --cov-report=xml --cov=slack_sdk/ --junitxml=reports/test_report.xml tests/ - name: Run tests for SQLAlchemy v1.4 (backward-compatibility) run: | @@ -102,7 +80,6 @@ jobs: name: Regression notifications runs-on: ubuntu-latest needs: - - typecheck - unittest if: ${{ !success() && github.ref == 'refs/heads/main' && github.event_name != 'workflow_dispatch' }} steps: diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml new file mode 100644 index 000000000..93f07c542 --- /dev/null +++ b/.github/workflows/typecheck.yml @@ -0,0 +1,29 @@ +name: Typecheck + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +env: + PYTHON_VERSION: "3.14" + +jobs: + typecheck: + name: Typecheck + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + with: + persist-credentials: false + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Run mypy verification + run: ./scripts/run_mypy.sh diff --git a/requirements/testing.txt b/requirements/testing.txt index 9b702718c..9e1a3fd67 100644 --- a/requirements/testing.txt +++ b/requirements/testing.txt @@ -12,4 +12,3 @@ moto>=4.0.13,<6 # For AsyncSQLAlchemy tests greenlet<=4 aiosqlite<=1 --r tools.txt diff --git a/requirements/tools.txt b/requirements/tools.txt index dd09cd46f..4c0751dbd 100644 --- a/requirements/tools.txt +++ b/requirements/tools.txt @@ -1,6 +1,4 @@ -# We only need to install mypy with CPython runtimes -# Typechecking using the PyPy runtime is not planned -mypy<=1.19.0; platform_python_implementation == "CPython" +mypy<=1.19.0; # while flake8 5.x have issues with Python 3.12, flake8 6.x requires Python >= 3.8.1, # so 5.x should be kept in order to stay compatible with Python 3.7/3.8 flake8>=5.0.4,<8 diff --git a/scripts/format.sh b/scripts/format.sh index d4236258f..aa18459ab 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -4,7 +4,9 @@ script_dir=`dirname $0` cd ${script_dir}/.. -pip install -U pip -pip install -U -r requirements/tools.txt +if [[ "$1" != "--no-install" ]]; then + pip install -U pip + pip install -U -r requirements/tools.txt +fi black slack/ slack_sdk/ tests/ integration_tests/ diff --git a/scripts/lint.sh b/scripts/lint.sh new file mode 100755 index 000000000..8fac67888 --- /dev/null +++ b/scripts/lint.sh @@ -0,0 +1,14 @@ + +#!/bin/bash +# ./scripts/lint.sh + +script_dir=`dirname $0` +cd ${script_dir}/.. + +if [[ "$1" != "--no-install" ]]; then + pip install -U pip + pip install -U -r requirements/tools.txt +fi + +black --check slack/ slack_sdk/ tests/ integration_tests/ +flake8 slack/ slack_sdk/ diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index a5d86801b..1a6f254cb 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -10,10 +10,11 @@ cd ${script_dir}/.. pip install -U pip pip install -U -r requirements/testing.txt \ - -U -r requirements/optional.txt + -U -r requirements/optional.txt \ + -U -r requirements/tools.txt echo "Generating code ..." && python scripts/codegen.py --path . -echo "Running black (code formatter) ..." && black slack_sdk/ +echo "Running black (code formatter) ..." && ./scripts/format.sh --no-install test_target="${1:-tests/integration_tests/}" PYTHONPATH=$PWD:$PYTHONPATH pytest $test_target diff --git a/scripts/run_mypy.sh b/scripts/run_mypy.sh index 0d27346bc..cc1146f15 100755 --- a/scripts/run_mypy.sh +++ b/scripts/run_mypy.sh @@ -8,6 +8,7 @@ cd ${script_dir}/.. pip install -U pip setuptools wheel pip install -U -r requirements/testing.txt \ - -U -r requirements/optional.txt + -U -r requirements/optional.txt \ + -U -r requirements/tools.txt mypy --config-file pyproject.toml diff --git a/scripts/run_unit_tests.sh b/scripts/run_unit_tests.sh index cec153388..c8ab0af78 100755 --- a/scripts/run_unit_tests.sh +++ b/scripts/run_unit_tests.sh @@ -10,10 +10,12 @@ cd ${script_dir}/.. pip install -U pip pip install -U -r requirements/testing.txt \ - -U -r requirements/optional.txt + -U -r requirements/optional.txt \ + -U -r requirements/tools.txt echo "Generating code ..." && python scripts/codegen.py --path . -echo "Running black (code formatter) ..." && black slack_sdk/ +echo "Running black (code formatter) ..." && ./scripts/format.sh --no-install +echo "Running tests ..." test_target="${1:-tests/}" PYTHONPATH=$PWD:$PYTHONPATH pytest $test_target diff --git a/scripts/run_validation.sh b/scripts/run_validation.sh index 8a61d03a6..366f0d321 100755 --- a/scripts/run_validation.sh +++ b/scripts/run_validation.sh @@ -8,13 +8,14 @@ script_dir=`dirname $0` cd ${script_dir}/.. pip install -U -r requirements/testing.txt \ - -U -r requirements/optional.txt + -U -r requirements/optional.txt \ + -U -r requirements/tools.txt echo "Generating code ..." && python scripts/codegen.py --path . -echo "Running black (code formatter) ..." && black slack_sdk/ +echo "Running black (code formatter) ..." && ./scripts/format.sh --no-install -black --check slack/ slack_sdk/ tests/ integration_tests/ -flake8 slack/ slack_sdk/ +echo "Running linting checks ..." && ./scripts/lint.sh --no-install +echo "Running tests with coverage reporting ..." test_target="${1:-tests/}" PYTHONPATH=$PWD:$PYTHONPATH pytest --cov-report=xml --cov=slack_sdk/ $test_target From ff7a25c76f665653e283b5b964542b44375577ac Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Fri, 5 Dec 2025 15:17:19 -0500 Subject: [PATCH 2/3] Update scripts/format.sh Co-authored-by: Eden Zimbelman --- scripts/format.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/format.sh b/scripts/format.sh index aa18459ab..56ca68077 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -5,6 +5,7 @@ script_dir=`dirname $0` cd ${script_dir}/.. if [[ "$1" != "--no-install" ]]; then + export PIP_REQUIRE_VIRTUALENV=1 pip install -U pip pip install -U -r requirements/tools.txt fi From d7fc1f660b865fa26e963b67ba7c7da7932e1bf6 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Fri, 5 Dec 2025 15:30:52 -0500 Subject: [PATCH 3/3] Use one file to define all jobs --- .github/workflows/{tests.yml => ci-build.yml} | 44 ++++++++++++++++++- .github/workflows/lint.yml | 29 ------------ .github/workflows/typecheck.yml | 29 ------------ 3 files changed, 42 insertions(+), 60 deletions(-) rename .github/workflows/{tests.yml => ci-build.yml} (71%) delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/typecheck.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/ci-build.yml similarity index 71% rename from .github/workflows/tests.yml rename to .github/workflows/ci-build.yml index addac2dff..7e9e4e28d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/ci-build.yml @@ -1,4 +1,4 @@ -name: Test +name: Python CI on: push: @@ -9,7 +9,44 @@ on: - cron: "0 0 * * *" workflow_dispatch: +env: + LATEST_SUPPORTED_PY: "3.14" + jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + with: + persist-credentials: false + - name: Set up Python ${{ env.LATEST_SUPPORTED_PY }} + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.LATEST_SUPPORTED_PY }} + - name: Run lint verification + run: ./scripts/lint.sh + + typecheck: + name: Typecheck + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + with: + persist-credentials: false + - name: Set up Python ${{ env.LATEST_SUPPORTED_PY }} + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.LATEST_SUPPORTED_PY }} + - name: Run mypy verification + run: ./scripts/run_mypy.sh + unittest: name: Unit tests runs-on: ubuntu-22.04 @@ -67,7 +104,7 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} verbose: true - name: Upload test coverage to Codecov (only with latest supported version) - if: startsWith(matrix.python-version, '3.14') + if: startsWith(matrix.python-version, env.LATEST_SUPPORTED_PY) uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 with: fail_ci_if_error: true @@ -76,10 +113,13 @@ jobs: report_type: coverage token: ${{ secrets.CODECOV_TOKEN }} verbose: true + notifications: name: Regression notifications runs-on: ubuntu-latest needs: + - lint + - typecheck - unittest if: ${{ !success() && github.ref == 'refs/heads/main' && github.event_name != 'workflow_dispatch' }} steps: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index a85a58459..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Lint - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -env: - PYTHON_VERSION: "3.14" - -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: - contents: read - steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - persist-credentials: false - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Run lint verification - run: ./scripts/lint.sh diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml deleted file mode 100644 index 93f07c542..000000000 --- a/.github/workflows/typecheck.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Typecheck - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -env: - PYTHON_VERSION: "3.14" - -jobs: - typecheck: - name: Typecheck - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: - contents: read - steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - persist-credentials: false - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Run mypy verification - run: ./scripts/run_mypy.sh