Skip to content

Commit dc2046a

Browse files
committed
chore(satp-hermes): run SATP tests conditionally
Runs SATP-Hermes tests only when there are changes in the SATP codebase Signed-off-by: Rafael Belchior <[email protected]>
1 parent 1c2d609 commit dc2046a

File tree

1 file changed

+55
-14
lines changed

1 file changed

+55
-14
lines changed

.github/workflows/satp-hermes-main.yaml

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,38 +99,79 @@ on:
9999
type: boolean
100100

101101
jobs:
102+
check_satp_code_changed:
103+
outputs:
104+
status: ${{ steps.changes_satp.outputs.satp_code_changed}}
105+
runs-on: ubuntu-22.04
106+
steps:
107+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
108+
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 #v2.11.1
109+
id: changes_satp
110+
with:
111+
filters: |
112+
satp_code_changed:
113+
- './packages/cactus-plugin-satp-hermes/**'
114+
- '.github/workflows/satp-hermes-build.yaml'
115+
- '.github/workflows/satp-hermes-codegen.yaml'
116+
- '.github/workflows/satp-hermes-docker.yaml'
117+
- '.github/workflows/satp-hermes-lint.yaml'
118+
- '.github/workflows/satp-hermes-main.yaml'
119+
- '.github/workflows/satp-hermes-test.yaml'
120+
should_run_satp_pipelines:
121+
needs: [check_satp_code_changed]
122+
runs-on: ubuntu-22.04
123+
outputs:
124+
run: ${{ steps.set_satp_run.outputs.run }}
125+
steps:
126+
- name: Set run output
127+
id: set_satp_run
128+
run: |
129+
if [[ "${{ needs.check_satp_code_changed.outputs.status }}" == "true" || "${{ env.RUN_SATP_HERMES_PIPELINE }}" == "true" ]]; then
130+
echo "run=true" >> "$GITHUB_OUTPUT"
131+
elif [[ "${{ needs.check_satp_code_changed.outputs.status }}" == "false" && "${{ env.RUN_SATP_HERMES_PIPELINE }}" == "false" ]]; then
132+
echo "run=false" >> "$GITHUB_OUTPUT"
133+
fi
134+
env:
135+
RUN_SATP_HERMES_PIPELINE: ${{ env.RUN_SATP_HERMES_PIPELINE }}
136+
102137
# Stage 1: Build and Dependencies
103138
build-stage:
139+
needs: [should_run_satp_pipelines]
140+
if: needs.should_run_satp_pipelines.outputs.run == 'true'
104141
uses: ./.github/workflows/satp-hermes-build.yaml
105142

106143
# Stage 2: Code Quality Validation
107144
lint-stage:
108-
needs: [build-stage]
145+
needs: [build-stage, should_run_satp_pipelines]
146+
if: needs.should_run_satp_pipelines.outputs.run == 'true'
109147
uses: ./.github/workflows/satp-hermes-lint.yaml
110148

111149
# Stage 3: Code Generation
112150
codegen-stage:
113-
needs: [build-stage, lint-stage]
151+
needs: [build-stage, lint-stage, should_run_satp_pipelines]
152+
if: needs.should_run_satp_pipelines.outputs.run == 'true'
114153
uses: ./.github/workflows/satp-hermes-codegen.yaml
115154

116155
# Stage 4: Test Execution
117156
test-stage:
118-
needs: [build-stage, codegen-stage]
157+
needs: [build-stage, codegen-stage, should_run_satp_pipelines]
158+
if: needs.should_run_satp_pipelines.outputs.run == 'true'
119159
uses: ./.github/workflows/satp-hermes-test.yaml
120160
with:
121161
skip_tests: ${{ github.event.inputs.skip_tests == 'true' }}
122162

123163
# Stage 5: Docker Build and Publishing
124164
docker-stage:
125-
needs: [build-stage, test-stage]
126-
if: |
127-
always() && (
128-
(github.event.inputs.skip_tests == 'true' && github.event.inputs.is_release == 'true') ||
129-
(needs.test-stage.result == 'success') ||
130-
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/satp-dev' || github.ref == 'refs/heads/satp-stg')) ||
131-
(github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'satp-dev' || github.base_ref == 'satp-stg')) ||
132-
github.event_name == 'workflow_dispatch'
133-
)
165+
needs: [build-stage, test-stage, should_run_satp_pipelines]
166+
if: needs.should_run_satp_pipelines.outputs.run == 'true' &&
167+
((github.event.inputs.skip_tests == 'true' &&
168+
github.event.inputs.is_release == 'true') ||
169+
(needs.test-stage.result == 'success') ||
170+
(github.event_name == 'push' && (github.ref == 'refs/heads/main' ||
171+
github.ref == 'refs/heads/satp-dev' || github.ref == 'refs/heads/satp-stg')) ||
172+
(github.event_name == 'pull_request' && (github.base_ref == 'main' ||
173+
github.base_ref == 'satp-dev' || github.base_ref == 'satp-stg')) ||
174+
github.event_name == 'workflow_dispatch')
134175
uses: ./.github/workflows/satp-hermes-docker.yaml
135176
with:
136177
skip_tests: ${{ github.event.inputs.skip_tests == 'true' }}
@@ -140,8 +181,8 @@ jobs:
140181

141182
# Stage 6: Release Creation (Release Mode Only)
142183
release-stage:
143-
needs: [docker-stage]
144-
if: github.event_name == 'workflow_dispatch' && github.event.inputs.is_release == 'true'
184+
needs: [docker-stage, should_run_satp_pipelines]
185+
if: needs.should_run_satp_pipelines.outputs.run == 'true' && github.event_name == 'workflow_dispatch' && github.event.inputs.is_release == 'true'
145186
uses: ./.github/workflows/satp-hermes-release.yaml
146187
with:
147188
is_release: ${{ github.event.inputs.is_release == 'true' }}

0 commit comments

Comments
 (0)