Skip to content

Commit

Permalink
chore: update CI triggers to minify useless runs (#1483)
Browse files Browse the repository at this point in the history
* chore: run CQ CI only with PR and by cron

* chore: run DR CI only if pyproject changed

* format: correct deploy docs CI

* chore: run coverage publish CI only after PR merged

* chore: run tests only in PR

* chore: fix test CI

* chore: add CI workflows names conversation

* chore: add docs update references CI

* chore: make update references CI writeable

* chore: finalize CI

* chore: correct name in check links CI

* chore: run tests only if required

* chore: run CQ CI if required

* chore: fix broken links CI

* chore: make References autocommit

* Apply automatic changes

* chore: change GHA commit message

* chore: make extra trigger for tests

* chore: update tests triggers

* chore: run tests anyway

* chore: add merge queue trigger to CI

* chore: make real testsuites fail-fast

* chore: remove useless conditions in CI

---------

Co-authored-by: Lancetnik <Lancetnik@users.noreply.github.com>
Co-authored-by: Kumaran Rajendhiran <kumaran@airt.ai>
  • Loading branch information
3 people committed Jun 3, 2024
1 parent 82c9acd commit a628529
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Deploy Docs
name: Deploy Docs to GitHub Pages

on:
push:
branches:
Expand All @@ -10,6 +11,7 @@ on:

permissions:
contents: write

jobs:
deploy_docs:
runs-on: ubuntu-latest
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/docs_update-references.yaml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/codeql.yml → .github/workflows/pr_codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
119 changes: 52 additions & 67 deletions .github/workflows/test.yaml → .github/workflows/pr_tests.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/publish_coverage.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 }}
Expand Down
Loading

0 comments on commit a628529

Please sign in to comment.