Skip to content

Commit dfa5e5f

Browse files
fix: improve CI and helper scripts (#1803)
Co-authored-by: Eden Zimbelman <[email protected]>
1 parent 4601f8a commit dfa5e5f

File tree

9 files changed

+65
-29
lines changed

9 files changed

+65
-29
lines changed
Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
2-
name: Test
1+
name: Python CI
32

43
on:
54
push:
@@ -10,27 +9,44 @@ on:
109
- cron: "0 0 * * *"
1110
workflow_dispatch:
1211

12+
env:
13+
LATEST_SUPPORTED_PY: "3.14"
14+
1315
jobs:
16+
lint:
17+
name: Lint
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 5
20+
permissions:
21+
contents: read
22+
steps:
23+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
24+
with:
25+
persist-credentials: false
26+
- name: Set up Python ${{ env.LATEST_SUPPORTED_PY }}
27+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
28+
with:
29+
python-version: ${{ env.LATEST_SUPPORTED_PY }}
30+
- name: Run lint verification
31+
run: ./scripts/lint.sh
32+
1433
typecheck:
15-
name: Typechecks
34+
name: Typecheck
1635
runs-on: ubuntu-latest
1736
timeout-minutes: 5
18-
strategy:
19-
matrix:
20-
python-version: ["3.14"]
2137
permissions:
2238
contents: read
2339
steps:
2440
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2541
with:
2642
persist-credentials: false
27-
- name: Set up Python ${{ matrix.python-version }}
43+
- name: Set up Python ${{ env.LATEST_SUPPORTED_PY }}
2844
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
2945
with:
30-
python-version: ${{ matrix.python-version }}
46+
python-version: ${{ env.LATEST_SUPPORTED_PY }}
3147
- name: Run mypy verification
32-
run: |
33-
./scripts/run_mypy.sh
48+
run: ./scripts/run_mypy.sh
49+
3450
unittest:
3551
name: Unit tests
3652
runs-on: ubuntu-22.04
@@ -48,6 +64,7 @@ jobs:
4864
- "3.8"
4965
- "3.7"
5066
- "pypy3.10"
67+
- "pypy3.11"
5168
permissions:
5269
contents: read
5370
env:
@@ -67,10 +84,8 @@ jobs:
6784
pip install -U pip
6885
pip install -r requirements/testing.txt
6986
pip install -r requirements/optional.txt
70-
- name: Run validation (black/flake8/pytest)
87+
- name: Run tests
7188
run: |
72-
black --check slack/ slack_sdk/ tests/ integration_tests/
73-
flake8 slack/ slack_sdk/
7489
PYTHONPATH=$PWD:$PYTHONPATH pytest --cov-report=xml --cov=slack_sdk/ --junitxml=reports/test_report.xml tests/
7590
- name: Run tests for SQLAlchemy v1.4 (backward-compatibility)
7691
run: |
@@ -89,7 +104,7 @@ jobs:
89104
token: ${{ secrets.CODECOV_TOKEN }}
90105
verbose: true
91106
- name: Upload test coverage to Codecov (only with latest supported version)
92-
if: startsWith(matrix.python-version, '3.14')
107+
if: startsWith(matrix.python-version, env.LATEST_SUPPORTED_PY)
93108
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
94109
with:
95110
fail_ci_if_error: true
@@ -98,10 +113,12 @@ jobs:
98113
report_type: coverage
99114
token: ${{ secrets.CODECOV_TOKEN }}
100115
verbose: true
116+
101117
notifications:
102118
name: Regression notifications
103119
runs-on: ubuntu-latest
104120
needs:
121+
- lint
105122
- typecheck
106123
- unittest
107124
if: ${{ !success() && github.ref == 'refs/heads/main' && github.event_name != 'workflow_dispatch' }}

requirements/testing.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ moto>=4.0.13,<6
1212
# For AsyncSQLAlchemy tests
1313
greenlet<=4
1414
aiosqlite<=1
15-
-r tools.txt

requirements/tools.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# We only need to install mypy with CPython runtimes
2-
# Typechecking using the PyPy runtime is not planned
3-
mypy<=1.19.0; platform_python_implementation == "CPython"
1+
mypy<=1.19.0;
42
# while flake8 5.x have issues with Python 3.12, flake8 6.x requires Python >= 3.8.1,
53
# so 5.x should be kept in order to stay compatible with Python 3.7/3.8
64
flake8>=5.0.4,<8

scripts/format.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
script_dir=`dirname $0`
55
cd ${script_dir}/..
66

7-
pip install -U pip
8-
pip install -U -r requirements/tools.txt
7+
if [[ "$1" != "--no-install" ]]; then
8+
export PIP_REQUIRE_VIRTUALENV=1
9+
pip install -U pip
10+
pip install -U -r requirements/tools.txt
11+
fi
912

1013
black slack/ slack_sdk/ tests/ integration_tests/

scripts/lint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#!/bin/bash
3+
# ./scripts/lint.sh
4+
5+
script_dir=`dirname $0`
6+
cd ${script_dir}/..
7+
8+
if [[ "$1" != "--no-install" ]]; then
9+
pip install -U pip
10+
pip install -U -r requirements/tools.txt
11+
fi
12+
13+
black --check slack/ slack_sdk/ tests/ integration_tests/
14+
flake8 slack/ slack_sdk/

scripts/run_integration_tests.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ cd ${script_dir}/..
1010

1111
pip install -U pip
1212
pip install -U -r requirements/testing.txt \
13-
-U -r requirements/optional.txt
13+
-U -r requirements/optional.txt \
14+
-U -r requirements/tools.txt
1415

1516
echo "Generating code ..." && python scripts/codegen.py --path .
16-
echo "Running black (code formatter) ..." && black slack_sdk/
17+
echo "Running black (code formatter) ..." && ./scripts/format.sh --no-install
1718

1819
test_target="${1:-tests/integration_tests/}"
1920
PYTHONPATH=$PWD:$PYTHONPATH pytest $test_target

scripts/run_mypy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cd ${script_dir}/..
88

99
pip install -U pip setuptools wheel
1010
pip install -U -r requirements/testing.txt \
11-
-U -r requirements/optional.txt
11+
-U -r requirements/optional.txt \
12+
-U -r requirements/tools.txt
1213

1314
mypy --config-file pyproject.toml

scripts/run_unit_tests.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ cd ${script_dir}/..
1010

1111
pip install -U pip
1212
pip install -U -r requirements/testing.txt \
13-
-U -r requirements/optional.txt
13+
-U -r requirements/optional.txt \
14+
-U -r requirements/tools.txt
1415

1516
echo "Generating code ..." && python scripts/codegen.py --path .
16-
echo "Running black (code formatter) ..." && black slack_sdk/
17+
echo "Running black (code formatter) ..." && ./scripts/format.sh --no-install
1718

19+
echo "Running tests ..."
1820
test_target="${1:-tests/}"
1921
PYTHONPATH=$PWD:$PYTHONPATH pytest $test_target

scripts/run_validation.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ script_dir=`dirname $0`
88
cd ${script_dir}/..
99

1010
pip install -U -r requirements/testing.txt \
11-
-U -r requirements/optional.txt
11+
-U -r requirements/optional.txt \
12+
-U -r requirements/tools.txt
1213

1314
echo "Generating code ..." && python scripts/codegen.py --path .
14-
echo "Running black (code formatter) ..." && black slack_sdk/
15+
echo "Running black (code formatter) ..." && ./scripts/format.sh --no-install
1516

16-
black --check slack/ slack_sdk/ tests/ integration_tests/
17-
flake8 slack/ slack_sdk/
17+
echo "Running linting checks ..." && ./scripts/lint.sh --no-install
1818

19+
echo "Running tests with coverage reporting ..."
1920
test_target="${1:-tests/}"
2021
PYTHONPATH=$PWD:$PYTHONPATH pytest --cov-report=xml --cov=slack_sdk/ $test_target

0 commit comments

Comments
 (0)