Skip to content
100 changes: 90 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# This workflow will install Python dependencies, run tests (unit and integration), lint, build env with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
#
# Only triggers the lint, tests, build container, determine-changes and integration tests jobs for the following conditions:
# - When the PR has the github label "run_integration_tests" AND commits during when pull request is open
# - When it's a push into main or develop branches
# - When it's a release event
#
# integration-tests
# - In addition, the integration-tests job only runs when determine-changes job determines that
# there are non-unit tests changes
#
# deploy
# - deploy job only runs when there is a release event
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: The instruction seems not aligned with the diagram: 1. I saw integration-tests is also the downstream of lint and test. 2. deploy is the following step of test and lint.

Copy link
Contributor Author

@rxu17 rxu17 Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes those two points are accurate. I think you just meant I need to elaborate more / include out the details of the upstream and downstream points? It's true that deploy job only runs when there is a release event. I think my goal with this section was keep it to the key points and not rewrite what the mermaid diagram is doing word for word.

I think I will just include the mermaid diagram in a README section instead because it's more accurate and easier than using words to fully describe out the process because as you can see, the github workflow is kind of complex and then keep a higher level overview like the docstring here.


name: build

on:
push:
branches: [main, develop, 'GEN*', 'gen*']
branches: [main, develop]
paths-ignore:
- '**.md' # All Markdown files
- '**/docs/**' # Documentation directory
# - '.github/workflows/**' # Ignore all github workflow file changes

pull_request:
types:
- opened
- reopened
types: [opened, reopened, labeled, synchronize]
paths-ignore:
- '**.md' # All Markdown files
- '**/docs/**' # Documentation directory
# - '.github/workflows/**' # Ignore all github workflow file changes

release:
types:
- created
types: [created]

workflow_dispatch:

Expand All @@ -35,6 +42,20 @@ env:
jobs:

determine-changes:
if: >-
(
(
contains(github.event.pull_request.labels.*.name, 'run_integration_tests') &&
github.event.pull_request.state == 'open'
) ||
(
github.event_name == 'push' &&
(github.ref_name == 'main' || github.ref_name == 'develop')
) ||
(
github.event_name == 'release'
)
)
runs-on: ubuntu-latest
outputs:
non-test-changes: ${{ steps.get-changes.outputs.non-test-changes }}
Expand Down Expand Up @@ -62,6 +83,20 @@ jobs:

test:
runs-on: ubuntu-latest
if: >-
(
(
contains(github.event.pull_request.labels.*.name, 'run_integration_tests') &&
github.event.pull_request.state == 'open'
) ||
(
github.event_name == 'push' &&
(github.ref_name == 'main' || github.ref_name == 'develop')
) ||
(
github.event_name == 'release'
)
)
strategy:
matrix:
python-version: ['3.10', 3.11]
Expand Down Expand Up @@ -93,6 +128,20 @@ jobs:

lint:
runs-on: ubuntu-latest
if: >-
(
(
contains(github.event.pull_request.labels.*.name, 'run_integration_tests') &&
github.event.pull_request.state == 'open'
) ||
(
github.event_name == 'push' &&
(github.ref_name == 'main' || github.ref_name == 'develop')
) ||
(
github.event_name == 'release'
)
)
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
Expand All @@ -101,6 +150,20 @@ jobs:

build-container:
needs: [test, lint]
if: >-
(
(
contains(github.event.pull_request.labels.*.name, 'run_integration_tests') &&
github.event.pull_request.state == 'open'
) ||
(
github.event_name == 'push' &&
(github.ref_name == 'main' || github.ref_name == 'develop')
) ||
(
github.event_name == 'release'
)
)
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -147,9 +210,26 @@ jobs:
cache-to: ${{ steps.registry_refs.outputs.tags }},mode=max

integration-tests:
# Only runs for the following conditions:
# - if github label "run_integration_tests"
# - for commits during when pull request is open OR when it's a push into main or develop branches
needs: [determine-changes, lint, test, build-container]
runs-on: ubuntu-latest
if: ${{ needs.determine-changes.outputs.non-test-changes }}
if: >-
needs.determine-changes.outputs.non-test-changes &&
(
(
contains(github.event.pull_request.labels.*.name, 'run_integration_tests') &&
github.event.pull_request.state == 'open'
) ||
(
github.event_name == 'push' &&
(github.ref_name == 'main' || github.ref_name == 'develop')
) ||
(
github.event_name == 'release'
)
)
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down