diff --git a/.github/workflows/check-broken-links-in-docs.yaml b/.github/workflows/docs_check-broken-links.yaml similarity index 88% rename from .github/workflows/check-broken-links-in-docs.yaml rename to .github/workflows/docs_check-broken-links.yaml index 98ce376519..e09f0704fd 100644 --- a/.github/workflows/check-broken-links-in-docs.yaml +++ b/.github/workflows/docs_check-broken-links.yaml @@ -2,8 +2,10 @@ name: Check docs for broken links on: workflow_run: - workflows: ["pages-build-deployment"] - types: [completed] + types: + - completed + workflows: + - Deploy Docs to GitHub Pages jobs: check-broken-link: diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/docs_deploy.yaml similarity index 97% rename from .github/workflows/deploy-docs.yaml rename to .github/workflows/docs_deploy.yaml index c9da5942b6..d3cd1ce1d2 100644 --- a/.github/workflows/deploy-docs.yaml +++ b/.github/workflows/docs_deploy.yaml @@ -1,4 +1,5 @@ -name: Deploy Docs +name: Deploy Docs to GitHub Pages + on: push: branches: @@ -10,6 +11,7 @@ on: permissions: contents: write + jobs: deploy_docs: runs-on: ubuntu-latest diff --git a/.github/workflows/docs_update-references.yaml b/.github/workflows/docs_update-references.yaml new file mode 100644 index 0000000000..92e306784e --- /dev/null +++ b/.github/workflows/docs_update-references.yaml @@ -0,0 +1,34 @@ +name: Generate API References documentation + +on: + pull_request: + types: + - opened + - synchronize + paths: + - faststream/** + +permissions: + contents: write + +jobs: + check-docs-changes: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "pip" + cache-dependency-path: pyproject.toml + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: pip install -e ".[dev]" + - name: Run build docs + run: bash scripts/build-docs.sh + - name: Commit + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "docs: generate API References" diff --git a/.github/workflows/update_release_notes.yaml b/.github/workflows/docs_update-release-notes.yaml similarity index 95% rename from .github/workflows/update_release_notes.yaml rename to .github/workflows/docs_update-release-notes.yaml index b03ea6977f..1c3b3c0e1e 100644 --- a/.github/workflows/update_release_notes.yaml +++ b/.github/workflows/docs_update-release-notes.yaml @@ -1,10 +1,10 @@ -name: Update Release Notes +name: Create PR with updated Release Notes on: workflow_dispatch: null - push: - tags: - - '*' + release: + types: + - published jobs: update-release-notes: diff --git a/.github/workflows/codeql.yml b/.github/workflows/pr_codeql.yml similarity index 96% rename from .github/workflows/codeql.yml rename to .github/workflows/pr_codeql.yml index e0c92f423e..f1fb50d463 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/pr_codeql.yml @@ -12,11 +12,14 @@ name: "CodeQL" on: - push: - branches: [ "main"] pull_request: - # The branches below must be a subset of the branches above - branches: [ "main" ] + types: + - opened + - synchronize + branches: + - main + paths: + - faststream/** schedule: - cron: '39 20 * * 0' diff --git a/.github/workflows/dependency-review.yaml b/.github/workflows/pr_dependency-review.yaml similarity index 87% rename from .github/workflows/dependency-review.yaml rename to .github/workflows/pr_dependency-review.yaml index 0bc48198f8..11ad023407 100644 --- a/.github/workflows/dependency-review.yaml +++ b/.github/workflows/pr_dependency-review.yaml @@ -5,7 +5,16 @@ # Source repository: https://github.com/actions/dependency-review-action # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement name: 'Dependency Review' -on: [pull_request] + +on: + pull_request: + types: + - opened + - synchronize + branches: + - main + paths: + - pyproject.toml permissions: contents: read diff --git a/.github/workflows/test.yaml b/.github/workflows/pr_tests.yaml similarity index 94% rename from .github/workflows/test.yaml rename to .github/workflows/pr_tests.yaml index ddf783ded9..788837e2fa 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/pr_tests.yaml @@ -1,11 +1,11 @@ -name: Test +name: Run all tests on: - push: - branches: - - main pull_request: - types: [opened, synchronize] + types: + - opened + - synchronize + # https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue#triggering-merge-group-checks-with-github-actions merge_group: jobs: @@ -40,27 +40,7 @@ jobs: shell: bash run: semgrep scan --config auto --error - check-docs-changes: - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - cache: "pip" - cache-dependency-path: pyproject.toml - - name: Install Dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: pip install -e ".[dev]" - - name: Run build docs - run: bash scripts/build-docs.sh - - name: Check for changes - id: git-diff - run: git diff --exit-code - - test: + test-basic: if: github.event.pull_request.draft == false runs-on: ubuntu-latest strategy: @@ -165,8 +145,28 @@ jobs: - name: Test run: bash scripts/test.sh -m "(slow and (not nats and not kafka and not confluent and not rabbit and not redis)) or (not nats and not kafka and not confluent and not rabbit and not redis)" + test-kafka-smoke: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "pip" + cache-dependency-path: pyproject.toml + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: pip install .[kafka,test-core] + - name: Test + run: bash scripts/test.sh -m "not kafka" tests/brokers/kafka/test_test_client.py + test-kafka-real: if: github.event.pull_request.draft == false + needs: + - test-basic + - test-kafka-smoke runs-on: ubuntu-latest services: kafka: @@ -208,7 +208,7 @@ jobs: path: coverage if-no-files-found: error - test-kafka-smoke: + test-confluent-smoke: if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: @@ -221,12 +221,15 @@ jobs: cache-dependency-path: pyproject.toml - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' - run: pip install .[kafka,test-core] + run: pip install .[confluent,test-core] - name: Test - run: bash scripts/test.sh -m "not kafka" tests/brokers/kafka/test_test_client.py + run: bash scripts/test.sh -m "not confluent" tests/brokers/confluent/test_test_client.py test-confluent-real: if: github.event.pull_request.draft == false + needs: + - test-basic + - test-confluent-smoke runs-on: ubuntu-latest services: kafka: @@ -268,7 +271,7 @@ jobs: path: coverage if-no-files-found: error - test-confluent-smoke: + test-rabbit-smoke: if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: @@ -281,12 +284,15 @@ jobs: cache-dependency-path: pyproject.toml - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' - run: pip install .[confluent,test-core] + run: pip install .[rabbit,test-core] - name: Test - run: bash scripts/test.sh -m "not confluent" tests/brokers/confluent/test_test_client.py + run: bash scripts/test.sh -m "not rabbit" tests/brokers/rabbit/test_test_client.py test-rabbit-real: if: github.event.pull_request.draft == false + needs: + - test-basic + - test-rabbit-smoke runs-on: ubuntu-latest services: rabbitmq: @@ -317,7 +323,7 @@ jobs: path: coverage if-no-files-found: error - test-rabbit-smoke: + test-nats-smoke: if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: @@ -330,12 +336,15 @@ jobs: cache-dependency-path: pyproject.toml - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' - run: pip install .[rabbit,test-core] + run: pip install .[nats,test-core] - name: Test - run: bash scripts/test.sh -m "not rabbit" tests/brokers/rabbit/test_test_client.py + run: bash scripts/test.sh -m "not nats" tests/brokers/nats/test_test_client.py test-nats-real: if: github.event.pull_request.draft == false + needs: + - test-basic + - test-nats-smoke runs-on: ubuntu-latest services: nats: @@ -366,7 +375,7 @@ jobs: path: coverage if-no-files-found: error - test-nats-smoke: + test-redis-smoke: if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: @@ -379,13 +388,16 @@ jobs: cache-dependency-path: pyproject.toml - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' - run: pip install .[nats,test-core] + run: pip install .[redis,test-core] - name: Test - run: bash scripts/test.sh -m "not nats" tests/brokers/nats/test_test_client.py + run: bash scripts/test.sh -m "not redis" tests/brokers/redis/test_test_client.py test-redis-real: if: github.event.pull_request.draft == false runs-on: ubuntu-latest + needs: + - test-basic + - test-redis-smoke services: nats: image: redis:alpine @@ -415,27 +427,10 @@ jobs: path: coverage if-no-files-found: error - test-redis-smoke: - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - cache: "pip" - cache-dependency-path: pyproject.toml - - name: Install Dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: pip install .[redis,test-core] - - name: Test - run: bash scripts/test.sh -m "not redis" tests/brokers/redis/test_test_client.py - coverage-combine: if: github.event.pull_request.draft == false needs: - - test + - test-basic - test-kafka-real - test-confluent-real - test-rabbit-real @@ -478,20 +473,10 @@ jobs: needs: - static_analysis - - check-docs-changes - coverage-combine - test-macos-latest - test-windows-latest - - test-kafka-real - - test-kafka-smoke - - test-confluent-real - - test-confluent-smoke - - test-rabbit-real - - test-rabbit-smoke - - test-nats-real - - test-nats-smoke - - test-redis-real - - test-redis-smoke + - test-orjson runs-on: ubuntu-latest diff --git a/.github/workflows/publish_coverage.yml b/.github/workflows/publish_coverage.yml index f263ee33d4..04983682f8 100644 --- a/.github/workflows/publish_coverage.yml +++ b/.github/workflows/publish_coverage.yml @@ -1,18 +1,15 @@ -name: Smokeshow +name: Publish tests coverage to Smokeshow and set coverage % status to commit on: - workflow_run: - workflows: [Test] - types: [completed] - + push: + branches: + - main permissions: statuses: write - jobs: smokeshow: - if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest steps: @@ -22,15 +19,16 @@ jobs: - run: pip install smokeshow - - uses: dawidd6/action-download-artifact@v3.1.4 # nosemgrep + - uses: dawidd6/action-download-artifact@v3.1.4 # nosemgrep with: - workflow: test.yaml - commit: ${{ github.event.workflow_run.head_sha }} + workflow: pr_tests.yaml + workflow_conclusion: success + if_no_artifact_found: fail - run: smokeshow upload coverage-html env: SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage} - SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 70 + SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 90 SMOKESHOW_GITHUB_CONTEXT: coverage SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/release_pypi.yml similarity index 96% rename from .github/workflows/publish_pypi.yml rename to .github/workflows/release_pypi.yml index 1f03e52ae0..f1ed153dde 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -2,9 +2,9 @@ name: Publish to PyPi on: workflow_dispatch: null - push: - tags: - - "*" + release: + types: + - published jobs: publish: diff --git a/faststream/broker/middlewares/base.py b/faststream/broker/middlewares/base.py index ab8ccb7c4d..5710c8ec1c 100644 --- a/faststream/broker/middlewares/base.py +++ b/faststream/broker/middlewares/base.py @@ -97,7 +97,7 @@ async def publish_scope( **kwargs: Any, ) -> Any: """Publish a message and return an async iterator.""" - err: Optional[Exception] + err: Optional[Exception] = None try: result = await call_next( await self.on_publish(msg, *args, **kwargs), @@ -109,7 +109,6 @@ async def publish_scope( err = e else: - err = None return result finally: