Skip to content

Commit

Permalink
fix: Update set_data method to accept an optional callback parameter
Browse files Browse the repository at this point in the history
when callback is set, the data is stored in the subscriber's queue,
otherwise, the data is stored in all subscribers' queues.
  • Loading branch information
inean committed Aug 19, 2024
1 parent f474798 commit 996029f
Show file tree
Hide file tree
Showing 27 changed files with 404 additions and 281 deletions.
4 changes: 4 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--container-architecture linux/arm64
--container-options --security-opt label:disable
--action-offline-mode
--artifact-server-path /tmp
2 changes: 0 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# syntax=docker/dockerfile:1.0

# Builder image
FROM debian:bookworm-slim AS builder

Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:

traefik:
image: traefik:v3.1
container_name: traefik
command:
- "--api.insecure=true"
- "--providers.docker=true"
Expand All @@ -45,5 +46,6 @@ services:

whoami:
image: containous/whoami
container_name: whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
50 changes: 42 additions & 8 deletions .github/actions/setup-python-with-rye/action.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,69 @@
name: Install Python with Rye
---
name: Setup Rye
description: Install Python with Rye

inputs:
python-version:
description: Python version
required: true
required: false
rye-version:
description: Rye version
required: false
default: "latest"

outputs:
python-version:
description: The Python version to use
value: ${{ steps.compute-python-version.outputs.python-version }}

runs:
using: composite
steps:
- name: Compute Python Version
id: compute-python-version
run: |
PYTHON_VERSION="${{ inputs.python-version }}"
if [ -z "$PYTHON_VERSION" ]; then
PYTHON_VERSION=$(cat .python-version)
fi
if [ -z "$PYTHON_VERSION" ]; then
echo "No Python version specified, and no .python-version file found"
exit 1
fi
echo "Python version specified: $PYTHON_VERSION"
echo "python-version=$PYTHON_VERSION" >> $GITHUB_OUTPUT
shell: bash

- name: Install Rye
uses: eifinger/setup-rye@v3
uses: eifinger/setup-rye@v4
with:
enable-cache: true
version: ${{ inputs.rye-version }}
cache-prefix: ${{ steps.compute-python-version.outputs.python-version }}

- name: Set Rye Config
run: |
rye config --set-bool behavior.global-python=true
rye config --set-bool behavior.use-uv=true
shell: bash

- name: Set up Python ${{ inputs.python-version }}
- name: Pin Python Version ${{ steps.compute-python-version.outputs.python-version }}
run: |
export PYTHONUNBUFFERED=True
rye pin ${{ inputs.python-version }}
rye pin ${{ steps.compute-python-version.outputs.python-version }}
shell: bash

- name: Install Dependencies
run: rye sync
- name: Install dependencies
if: steps.setup-rye.outputs.cache-hit != 'true'
run: |
if [ -f requirements.lock ] && [ -f requirements-dev.lock ]; then
rye sync --no-lock
else
rye sync
fi
shell: bash

- name: Cache pre-commit
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.cache/pre-commit
key: pre-commit-|${{ steps.compute-python-version.outputs.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }}
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
version: 2
updates:

- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
interval: weekly
commit-message:
prefix: "chore(rye)"

- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
interval: weekly
commit-message:
prefix: "chore(github-actions)"
21 changes: 21 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Actions CI

on:
push:
branches: [ main ]

pull_request:
branches: [ main ]

jobs:
lint-actions:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Lint GitHub Actions
uses: eifinger/actionlint-action@v1
91 changes: 91 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
name: Code CI

on:

push:
branches: [ main ]

pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python with Rye
uses: ./.github/actions/setup-python-with-rye

- name: Lint
run: rye run ruff check --output-format=github .

format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python with Rye
uses: ./.github/actions/setup-python-with-rye

- name: Format
run: rye run ruff format . --check --diff

tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }} with Rye
uses: ./.github/actions/setup-python-with-rye
with:
python-version: ${{ matrix.python-version }}

- name: Run Pytest if directory exists
run: rye run pytest --cov=src --cov-report=xml --junitxml=junit.xml

- name: Upload test results to Codecov
if: ${{ !env.ACT }}
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
file: junit.xml
flags: ${{ matrix.python-version }}
name: ${{ github.repository }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload Coverage files
uses: actions/upload-artifact@v3
with:
name: coverage-xml
path: coverage.xml

coverage:
runs-on: ubuntu-latest
needs: tests
if: ${{ always() && ! cancelled() }}

steps:
- name: Download coverage.xml
uses: actions/download-artifact@v3
with:
name: coverage-xml
path: .

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
if: ${{ !env.ACT }}
with:
fail_ci_if_error: true
file: coverage.xml
flags: unittests
name: ${{ github.repository }}
token: ${{ secrets.CODECOV_TOKEN }}

43 changes: 30 additions & 13 deletions .github/workflows/docker.yml → .github/workflows/containers.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Docker
---
name: Container CI

on:
push:
Expand All @@ -7,7 +8,7 @@ on:
branches: [ main ]

jobs:
lint:
lint-container:
runs-on: ubuntu-latest

steps:
Expand All @@ -19,10 +20,10 @@ jobs:
with:
dockerfile: Dockerfile

build:
container:
runs-on: ubuntu-latest

needs: lint
needs: lint-container
if: ${{ success() }}

steps:
Expand All @@ -32,19 +33,36 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
- name: Build
uses: docker/build-push-action@v6
with:
context: .
load: true
file: ./Dockerfile
push: false
tags: latest
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ github.repository }}:latest

- name: Test Image
run: |
docker run --rm ${{ github.repository }}
lint-devcontainer:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Lint Dockerfile
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: ./.devcontainer/Dockerfile

devcontainer:
runs-on: ubuntu-latest

needs: lint-devcontainer
if: ${{ success() }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -56,8 +74,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
load: true
file: ./.devcontainer/Dockerfile
push: false
tags: latest
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ github.repository }}:latest

Loading

0 comments on commit 996029f

Please sign in to comment.