-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Canadian-Light-Source/testpypi
TestPyPI publishing
- Loading branch information
Showing
16 changed files
with
377 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
on: | ||
workflow_call: | ||
outputs: | ||
branch-pr: | ||
description: The PR number if the branch is in one | ||
value: ${{ jobs.pr.outputs.branch-pr }} | ||
|
||
jobs: | ||
pr: | ||
runs-on: "ubuntu-latest" | ||
outputs: | ||
branch-pr: ${{ steps.script.outputs.result }} | ||
steps: | ||
- uses: actions/github-script@v7 | ||
id: script | ||
if: github.event_name == 'push' | ||
with: | ||
script: | | ||
const prs = await github.rest.pulls.list({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
head: context.repo.owner + ':${{ github.ref_name }}' | ||
}) | ||
if (prs.data.length) { | ||
console.log(`::notice ::Skipping CI on branch push as it is already run in PR #${prs.data[0]["number"]}`) | ||
return prs.data[0]["number"] | ||
} |
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 @@ | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
runs-on: "ubuntu-latest" | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
# Need this to get version number from last tag | ||
fetch-depth: 0 | ||
|
||
- name: Build sdist and wheel | ||
run: > | ||
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && | ||
pipx run build | ||
- name: Upload sdist and wheel as artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist | ||
|
||
- name: Check for packaging errors | ||
run: pipx run twine check --strict dist/* |
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,26 @@ | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
upload: | ||
runs-on: ubuntu-latest | ||
environment: release | ||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
steps: | ||
- name: Download dist artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist | ||
|
||
# - name: Publish to PyPI using trusted publishing | ||
# uses: pypa/gh-action-pypi-publish@release/v1 | ||
# with: | ||
# attestations: false | ||
|
||
- name: Publish package distributions to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
attestations: false |
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 @@ | ||
name: Pytest | ||
on: | ||
workflow_call: | ||
inputs: | ||
python-version: | ||
type: string | ||
description: The version of python to install | ||
required: true | ||
runs-on: | ||
type: string | ||
description: The runner to run this job on | ||
required: true | ||
|
||
jobs: | ||
pytest: | ||
runs-on: ${{ inputs.runs-on }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install the latest version of uv and set the python version | ||
uses: astral-sh/setup-uv@v4 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
- name: Test with python ${{ matrix.python-version }} | ||
run: | | ||
uv run --frozen pytest | ||
uv run --frozen coverage run -m pytest -v | ||
uv run --frozen coverage report |
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,49 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
|
||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
- uses: pre-commit/action@v3.0.1 | ||
|
||
check: | ||
uses: ./.github/workflows/_check.yml | ||
|
||
lint: | ||
needs: check | ||
if: needs.check.outputs.branch-pr == '' | ||
uses: ./.github/workflows/ruff.yml | ||
|
||
test: | ||
needs: check | ||
if: needs.check.outputs.branch-pr == '' | ||
strategy: | ||
matrix: | ||
# runs-on: ["ubuntu-latest", "windows-latest", "macos-latest"] | ||
runs-on: ["ubuntu-latest"] # Linux for now | ||
# python-version: ["3.10","3.11","3.12"] | ||
python-version: ["3.12"] # single Python version for now | ||
fail-fast: false | ||
uses: ./.github/workflows/_test.yml | ||
with: | ||
runs-on: ${{ matrix.runs-on }} | ||
python-version: ${{ matrix.python-version }} | ||
|
||
dist: | ||
needs: check | ||
if: needs.check.outputs.branch-pr == '' | ||
uses: ./.github/workflows/_dist.yml | ||
|
||
pypi: | ||
if: github.ref_type == 'tag' | ||
needs: dist | ||
uses: ./.github/workflows/_pypi.yml | ||
# permissions: | ||
# id-token: write |
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,9 @@ | ||
name: Ruff | ||
on: | ||
workflow_call: | ||
jobs: | ||
ruff: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: astral-sh/ruff-action@v2 |
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 |
---|---|---|
|
@@ -164,3 +164,4 @@ cython_debug/ | |
|
||
# VSCode | ||
.vscode | ||
src/bluesky_nats/_version.py |
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,12 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-ast | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-yaml | ||
- id: debug-statements |
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,50 @@ | ||
# bluesky-nats | ||
|
||
This module allows to: | ||
|
||
* publish Bluesky documents to a NATS JetStream | ||
* consume a NATS JetStream | ||
|
||
## Installation | ||
|
||
Install from pypi | ||
```bash | ||
uv add bluesky-nats | ||
``` | ||
|
||
Install with dependecies to run the `examples` | ||
```bash | ||
uv add bluesky-nats --extra examples | ||
``` | ||
|
||
## Prerequisites | ||
|
||
The module requires a NATS JetStream-enabled server. | ||
If not explicitly specified, the Publisher will automatically publish to the NATS JetStream "bluesky". | ||
Make sure that the respective JetStream is available on the server and that your "subject" pattern matches the configuration. | ||
|
||
A simple Docker setup for local development and testing is provided in the [docker](https://github.com/Canadian-Light-Source/bluesky-nats/tree/main/docker) directory, with a [Readme](https://github.com/Canadian-Light-Source/bluesky-nats/tree/main/docker/Readme.adoc) for guidance. | ||
|
||
## Examples | ||
|
||
This is the most basic example to create a NATS publisher subscribed to RE documents. | ||
```python | ||
from bluesky.run_engine import RunEngine | ||
|
||
from bluesky_nats.nats_client import NATSClientConfig | ||
from bluesky_nats.nats_publisher import CoroutineExecutor, NATSPublisher | ||
|
||
if __name__ == "__main__": | ||
RE = RunEngine({}) | ||
config = NATSClientConfig() | ||
|
||
nats_publisher = NATSPublisher( | ||
client_config=config, | ||
executor=CoroutineExecutor(RE.loop), | ||
subject_factory="events.nats-bluesky", | ||
) | ||
|
||
RE.subscribe(nats_publisher) | ||
``` | ||
|
||
Follow the [instructions](https://github.com/Canadian-Light-Source/bluesky-nats/tree/main/examples) for more information about the examples. |
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
"""nats-bluesky examples.""" | ||
|
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 |
---|---|---|
|
@@ -27,4 +27,4 @@ | |
"inbox_prefix": "_INBOX", | ||
"pending_size": 2097152, | ||
"flush_timeout": null | ||
} | ||
} |
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
Oops, something went wrong.