-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b99dc3
commit aff3c46
Showing
332 changed files
with
18,168 additions
and
12,382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Create releases | ||
on: | ||
schedule: | ||
- cron: '0 5 * * *' # every day at 5am UTC | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
name: release | ||
if: github.ref == 'refs/heads/main' && github.repository == 'intercom/intercom-python' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: stainless-api/trigger-release-please@v1 | ||
id: release | ||
with: | ||
repo: ${{ github.event.repository.full_name }} | ||
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} | ||
|
||
- name: Install Rye | ||
if: ${{ steps.release.outputs.releases_created }} | ||
run: | | ||
curl -sSf https://rye.astral.sh/get | bash | ||
echo "$HOME/.rye/shims" >> $GITHUB_PATH | ||
env: | ||
RYE_VERSION: 0.24.0 | ||
RYE_INSTALL_OPTION: "--yes" | ||
|
||
- name: Publish to PyPI | ||
if: ${{ steps.release.outputs.releases_created }} | ||
run: | | ||
bash ./bin/publish-pypi | ||
env: | ||
PYPI_TOKEN: ${{ secrets.INTERCOM_PYPI_TOKEN || secrets.PYPI_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Handle release PR title edits | ||
on: | ||
pull_request: | ||
types: | ||
- edited | ||
- unlabeled | ||
|
||
jobs: | ||
update_pr_content: | ||
name: Update pull request content | ||
if: | | ||
((github.event.action == 'edited' && github.event.changes.title.from != github.event.pull_request.title) || | ||
(github.event.action == 'unlabeled' && github.event.label.name == 'autorelease: custom version')) && | ||
startsWith(github.event.pull_request.head.ref, 'release-please--') && | ||
github.event.pull_request.state == 'open' && | ||
github.event.sender.login != 'stainless-bot' && | ||
github.event.sender.login != 'stainless-app' && | ||
github.repository == 'intercom/intercom-python' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: stainless-api/trigger-release-please@v1 | ||
with: | ||
repo: ${{ github.event.repository.full_name }} | ||
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# workflow for re-running publishing to PyPI in case it fails for some reason | ||
# you can run this workflow by navigating to https://www.github.com/intercom/intercom-python/actions/workflows/publish-pypi.yml | ||
name: Publish PyPI | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
name: publish | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Rye | ||
run: | | ||
curl -sSf https://rye.astral.sh/get | bash | ||
echo "$HOME/.rye/shims" >> $GITHUB_PATH | ||
env: | ||
RYE_VERSION: 0.24.0 | ||
RYE_INSTALL_OPTION: "--yes" | ||
|
||
- name: Publish to PyPI | ||
run: | | ||
bash ./bin/publish-pypi | ||
env: | ||
PYPI_TOKEN: ${{ secrets.INTERCOM_PYPI_TOKEN || secrets.PYPI_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Release Doctor | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release_doctor: | ||
name: release doctor | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'intercom/intercom-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Check release environment | ||
run: | | ||
bash ./bin/check-release-environment | ||
env: | ||
STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} | ||
PYPI_TOKEN: ${{ secrets.INTERCOM_PYPI_TOKEN || secrets.PYPI_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ dist | |
.env | ||
.envrc | ||
codegen.log | ||
Brewfile.lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
".": "0.0.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
configured_endpoints: 103 | ||
configured_endpoints: 109 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-d02ca8e30fc99f5cb4f6b9b3f6300ccb515819f7a75c6c56fcad9de0a744c1ce.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
brew "rye" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
## Setting up the environment | ||
|
||
### With Rye | ||
|
||
We use [Rye](https://rye.astral.sh/) to manage dependencies so we highly recommend [installing it](https://rye.astral.sh/guide/installation/) as it will automatically provision a Python environment with the expected Python version. | ||
|
||
After installing Rye, you'll just have to run this command: | ||
|
||
```sh | ||
$ rye sync --all-features | ||
``` | ||
|
||
You can then run scripts using `rye run python script.py` or by activating the virtual environment: | ||
|
||
```sh | ||
$ rye shell | ||
# or manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work | ||
$ source .venv/bin/activate | ||
|
||
# now you can omit the `rye run` prefix | ||
$ python script.py | ||
``` | ||
|
||
### Without Rye | ||
|
||
Alternatively if you don't want to install `Rye`, you can stick with the standard `pip` setup by ensuring you have the Python version specified in `.python-version`, create a virtual environment however you desire and then install dependencies using this command: | ||
|
||
```sh | ||
$ pip install -r requirements-dev.lock | ||
``` | ||
|
||
## Modifying/Adding code | ||
|
||
Most of the SDK is generated code, and any modified code will be overridden on the next generation. The | ||
`src/intercom/lib/` and `examples/` directories are exceptions and will never be overridden. | ||
|
||
## Adding and running examples | ||
|
||
All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or | ||
added to. | ||
|
||
```bash | ||
# add an example to examples/<your-example>.py | ||
|
||
#!/usr/bin/env -S rye run python | ||
… | ||
``` | ||
|
||
``` | ||
chmod +x examples/<your-example>.py | ||
# run the example against your api | ||
./examples/<your-example>.py | ||
``` | ||
|
||
## Using the repository from source | ||
|
||
If you’d like to use the repository from source, you can either install from git or link to a cloned repository: | ||
|
||
To install via git: | ||
|
||
```bash | ||
pip install git+ssh://[email protected]/intercom/intercom-python.git | ||
``` | ||
|
||
Alternatively, you can build from source and install the wheel file: | ||
|
||
Building this package will create two files in the `dist/` directory, a `.tar.gz` containing the source files and a `.whl` that can be used to install the package efficiently. | ||
|
||
To create a distributable version of the library, all you have to do is run this command: | ||
|
||
```bash | ||
rye build | ||
# or | ||
python -m build | ||
``` | ||
|
||
Then to install: | ||
|
||
```sh | ||
pip install ./path-to-wheel-file.whl | ||
``` | ||
|
||
## Running tests | ||
|
||
Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. | ||
|
||
```bash | ||
# you will need npm installed | ||
npx prism mock path/to/your/openapi.yml | ||
``` | ||
|
||
```bash | ||
rye run pytest | ||
``` | ||
|
||
## Linting and formatting | ||
|
||
This repository uses [ruff](https://github.com/astral-sh/ruff) and | ||
[black](https://github.com/psf/black) to format the code in the repository. | ||
|
||
To lint: | ||
|
||
```bash | ||
rye run lint | ||
``` | ||
|
||
To format and fix all ruff issues automatically: | ||
|
||
```bash | ||
rye run format | ||
``` | ||
|
||
## Publishing and releases | ||
|
||
Changes made to this repository via the automated release PR pipeline should publish to PyPI automatically. If | ||
the changes aren't made through the automated pipeline, you may want to make releases manually. | ||
|
||
### Publish with a GitHub workflow | ||
|
||
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/intercom/intercom-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up. | ||
|
||
### Publish manually | ||
|
||
If you need to manually release a package, you can run the `bin/publish-pypi` script with a `PYPI_TOKEN` set on | ||
the environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.