Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 5
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Python CI

on:
push:
branches:
- main
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

env:
LATEST_SUPPORTED_PY: "3.15"

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python ${{ env.LATEST_SUPPORTED_PY }}
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ env.LATEST_SUPPORTED_PY }}
- name: Run lint verification
run: ./scripts/lint.sh

unittest:
name: Unit tests
runs-on: ubuntu-22.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
- "3.15"
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U pip
pip install -r requirements/testing.txt
- name: Run tests
run: |
pytest --junitxml=reports/test.xml
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
directory: ./reports/
fail_ci_if_error: true
flags: ${{ matrix.python-version }}
report_type: test_results
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

codecov:
name: Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python ${{ env.LATEST_SUPPORTED_PY }}
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ env.LATEST_SUPPORTED_PY }}
- name: Install dependencies
run: |
pip install -U pip
pip install -e .
pip install -r requirements/testing.txt
- name: Run all tests for codecov
run: |
pytest --cov=./slack_discovery_sdk/ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
fail_ci_if_error: true
report_type: coverage
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
35 changes: 0 additions & 35 deletions .github/workflows/flake8.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/py_compile.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/pytype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U pip
pip install -e ".[testing]"
./scripts/install.sh
# As pytype can change its behavior in newer versions, we manually upgrade it
pip install "pytype==2023.9.27"
- name: Run pytype
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
> 🚨 Note: This SDK is only accessible to customer developers with access to the Discovery API (Enterprise accounts) or partners who have been onboarded to the Security and Compliance partner program. To learn more about the Discovery APIs, please [visit our help center](https://slack.com/help/articles/360002079527-A-guide-to-Slacks-Discovery-APIs). 🚨

## Prerequisites For Using the SDK
* Python version 3.6 or greater
* Python version 3.7 or greater
* Latest version of pip
* A token with discovery scopes (`discovery:read` and or `discovery:write`)
> Note: Please see the [OAuth guide](https://api.slack.com/enterprise/discovery/oauth-guide) on how to get this token if you don't already have one.
Expand Down Expand Up @@ -60,7 +60,7 @@ To view all of the methods offered by the SDK, please see the [client.py file](h
In order to speed up the development process, we've provided you with a script called
`set_env_vars.sh` in the scripts folder to automate a few things needed to run the SDK.
The script accomplishes the following things using the following code:
* Prints your current Python version (**you will need Python version 3.6 or greater for this SDK**)
* Prints your current Python version (**you will need Python version 3.7 or greater for this SDK**)
```bash
python3 --version
```
Expand All @@ -75,7 +75,7 @@ The script accomplishes the following things using the following code:
```
* Installs required packages and dependencies
```bash
pip install -e ".[testing]"
./scripts/install.sh
```

## 👨🏻‍💻 Adding Env Variables to Setup Script 👩🏻‍💻
Expand Down Expand Up @@ -238,11 +238,11 @@ And then, setting the bot / user tokens in the env variables as below:

```bash
# Setup your virtual environment
python --version # make sure if you're using Python 3.6+
python --version # make sure if you're using Python 3.7+
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -e ".[testing]"
./scripts/install.sh

# Set required env variables
# 1. An admin user token with discovery:read, discovery:write
Expand All @@ -257,6 +257,8 @@ export SLACK_DISCOVERY_SDK_TEST_TEAM_ID=T1234567890
export SLACK_DISCOVERY_SDK_TEST_CHANNEL_ID=C1234567890
pytest tests/

# Without SLACK_DISCOVERY_SDK_TEST_ENTERPRISE_TOKEN, the tests that call the Discovery API are skipped

# You can check logs/pytest.log for trouble shooting
```

Expand Down
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage:
status:
project:
default:
threshold: 2.0%
patch:
default:
target: 50%
79 changes: 79 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "slack-discovery-sdk"
dynamic = ["version", "readme"]
description = "The Slack Discovery API SDK for Python"
license = { text = "MIT" }
authors = [{ name = "Slack Technologies, LLC", email = "opensource@slack.com" }]
requires-python = ">=3.7"
dependencies = []
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Communications :: Chat",
"Topic :: Office/Business",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Programming Language :: Python :: Implementation :: CPython",
]


[project.urls]
Homepage = "https://github.com/slackapi/python-slack-discovery-sdk"
Documentation = "https://slack.com/help/articles/360002079527-A-guide-to-Slacks-Discovery-APIs"
Source = "https://github.com/slackapi/python-slack-discovery-sdk"

[tool.setuptools.packages.find]
include = ["slack_discovery_sdk*"]

[tool.setuptools.dynamic]
version = { attr = "slack_discovery_sdk.version.__version__" }
readme = { file = ["README.md"], content-type = "text/markdown" }

[tool.ruff]
line-length = 125

[tool.ruff.lint]
select = ["E", "W", "F", "D"]
ignore = [
# missing-docstring: do not add docstrings where none exist
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",
]

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.format]
docstring-code-format = true

[tool.pytest.ini_options]
testpaths = ["tests"]
log_file = "logs/pytest.log"
log_file_level = "DEBUG"
log_format = "%(asctime)s %(levelname)s %(message)s"
log_date_format = "%Y-%m-%d %H:%M:%S"
markers = ["live: calls the real Discovery API and needs the SLACK_DISCOVERY_SDK_TEST_* env variables"]
filterwarnings = [
'ignore:"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead:DeprecationWarning',
"ignore:The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.:DeprecationWarning",
]
10 changes: 0 additions & 10 deletions pytest.ini

This file was deleted.

7 changes: 7 additions & 0 deletions requirements/build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pip install -r requirements/build.txt

# twine
twine

# build
build
4 changes: 4 additions & 0 deletions requirements/dev-tools.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# pip install -r requirements/dev-tools.txt

# ruff
ruff==0.17.4
15 changes: 15 additions & 0 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pip install -r requirements/testing.txt

# slack_sdk
# Note: used by the live tests to post the messages and files that the Discovery API reads.
slack_sdk>=3.21.3,<4

# pytest
# Note: pytest 9 requires Python >=3.10; cap older interpreters below it.
pytest>=7.0.1,<9; python_version < "3.10"
pytest>=9.1.1,<10; python_version >= "3.10"

# pytest-cov
# Note: pytest-cov 7.1+ requires Python >=3.9; cap older interpreters below it.
pytest-cov>=4,<7.1.0; python_version < "3.9"
pytest-cov>=7.1.0,<8; python_version >= "3.9"
Loading
Loading