Skip to content

Commit b4c1020

Browse files
Ci: Ensure required tasks always run (#1314)
Instead of skipping jobs, we exit immediately when they're not needed. This prevents PRs from being blocked by required jobs that don't run.
1 parent 60243be commit b4c1020

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

.github/path_filters.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ ubuntu_build: &ubuntu_build
5353
- *docker
5454
- *ecosystem
5555

56-
linux_gtest: &linux_gtest
56+
linux_tests: &linux_tests
57+
- .github/scripts/gtest.sh
5758
- .github/workflows/gtest-bare-metal.yml
59+
- .github/workflows/smoke-tests.yml
5860
- '.github/workflows/upl*'
5961
- 'tests/unittest/*'
6062
- *ice_build

.github/workflows/base_build.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ jobs:
5050
id: filter
5151
with:
5252
filters: .github/path_filters.yml
53-
53+
5454
ubuntu-build:
5555
needs: changes
56-
if: ${{ github.repository == 'OpenVisualCloud/Media-Transport-Library' && needs.changes.outputs.ubuntu_build == 'true' }}
56+
if: ${{ github.repository == 'OpenVisualCloud/Media-Transport-Library' }}
5757
runs-on: ubuntu-22.04
5858
timeout-minutes: 60
5959
steps:
@@ -65,17 +65,19 @@ jobs:
6565
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6666

6767
- name: Build Release
68+
if: ${{ needs.changes.outputs.ubuntu_build == 'true' }}
6869
run: sudo -E .github/scripts/setup_environment.sh
6970

7071
- name: 'upload release build artifacts'
72+
if: ${{ needs.changes.outputs.ubuntu_build == 'true' }}
7173
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
7274
with:
7375
name: mtl-release-bin
7476
path: '${{ github.workspace }}/build/'
7577

7678
ubuntu-ebpf-xdp-build:
7779
needs: changes
78-
if: ${{ github.repository == 'OpenVisualCloud/Media-Transport-Library' && needs.changes.outputs.ubuntu_build == 'true' }}
80+
if: ${{ github.repository == 'OpenVisualCloud/Media-Transport-Library' }}
7981
runs-on: ubuntu-22.04
8082
timeout-minutes: 60
8183
steps:
@@ -87,6 +89,7 @@ jobs:
8789
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8890

8991
- name: ebpf-xdp build
92+
if: ${{ needs.changes.outputs.ubuntu_build == 'true' }}
9093
run: sudo -E .github/scripts/setup_environment.sh
9194
env:
9295
SETUP_BUILD_AND_INSTALL_EBPF_XDP: 1

.github/workflows/docker_build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939

4040
ubuntu-docker-build:
4141
needs: changes
42-
if: ${{ needs.changes.outputs.ubuntu_build == 'true' }}
4342
runs-on: ubuntu-22.04
4443
timeout-minutes: 120
4544
permissions:
@@ -71,6 +70,7 @@ jobs:
7170
password: "${{ secrets.GITHUB_TOKEN }}"
7271

7372
- name: Build image
73+
if: ${{ needs.changes.outputs.ubuntu_build == 'true' }}
7474
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
7575
with:
7676
push: "${{ env.DOCKER_REGISTRY_LOGIN == 'true' && steps.dockerLoginStep.outcome == 'SUCCESS' && github.ref == 'refs/heads/main' }}"
@@ -122,6 +122,7 @@ jobs:
122122
password: "${{ secrets.GITHUB_TOKEN }}"
123123

124124
- name: Build manager image
125+
if: ${{ needs.changes.outputs.ubuntu_build == 'true' }}
125126
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
126127
with:
127128
push: "${{ env.DOCKER_REGISTRY_LOGIN == 'true' && steps.dockerLoginStep.outcome == 'SUCCESS' && github.ref == 'refs/heads/main' }}"

.github/workflows/gtest-bare-metal.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
permissions:
3232
pull-requests: read
3333
outputs:
34-
changed: ${{ steps.filter.outputs.linux_gtest == 'true' }}
34+
changed: ${{ steps.filter.outputs.linux_tests == 'true' }}
3535
steps:
3636
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3737

@@ -42,7 +42,7 @@ jobs:
4242

4343
run-gtest-tests:
4444
needs: gtest-check-for-changes
45-
if: github.repository == 'OpenVisualCloud/Media-Transport-Library' && (needs.gtest-check-for-changes.outputs.changed == 'true' || github.event_name == 'workflow_dispatch')
45+
if: ${{ github.repository == 'OpenVisualCloud/Media-Transport-Library' }}
4646
strategy:
4747
matrix:
4848
nic:
@@ -53,16 +53,19 @@ jobs:
5353
runs-on: ${{ matrix.nic }}
5454
steps:
5555
- name: Harden Runner
56+
if: ${{ needs.gtest-check-for-changes.outputs.changed == 'true' && github.event_name != 'workflow_dispatch' }}
5657
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
5758
with:
5859
egress-policy: audit
5960

6061
- name: Checkout MTL
62+
if: ${{ needs.gtest-check-for-changes.outputs.changed == 'true' && github.event_name != 'workflow_dispatch' }}
6163
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6264
with:
6365
ref: '${{ inputs.branch-to-checkout || github.sha || github.ref }}'
6466

6567
- name: Install the build dependency
68+
if: ${{ needs.gtest-check-for-changes.outputs.changed == 'true' && github.event_name != 'workflow_dispatch' }}
6669
run: |
6770
sudo apt-get update -y && \
6871
sudo apt-get install -y \
@@ -76,6 +79,7 @@ jobs:
7679
sudo apt-get autoremove -y
7780
7881
- name: Build
82+
if: ${{ needs.gtest-check-for-changes.outputs.changed == 'true' && github.event_name != 'workflow_dispatch' }}
7983
run: |
8084
sudo su && ./build.sh
8185
sudo ldconfig
@@ -85,6 +89,7 @@ jobs:
8589
sudo dmesg | grep "Intel(R) Ethernet Connection .* version Kahawai.*"
8690
8791
- name: run gtest bare metal
92+
if: ${{ needs.gtest-check-for-changes.outputs.changed == 'true' && github.event_name != 'workflow_dispatch' }}
8893
env:
8994
NIGHTLY: 0
9095
run: sudo -E "${{ github.workspace }}/.github/scripts/gtest.sh"

.github/workflows/smoke-tests.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,23 @@ on:
1212
permissions:
1313
contents: read
1414
jobs:
15+
smoke-check-for-changes:
16+
runs-on: ubuntu-22.04
17+
permissions:
18+
pull-requests: read
19+
outputs:
20+
changed: ${{ steps.filter.outputs.linux_tests == 'true' }}
21+
steps:
22+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
24+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v2
25+
id: filter
26+
with:
27+
filters: .github/path_filters.yml
28+
1529
run-smoke-tests:
30+
needs: smoke-check-for-changes
31+
if: ${{ github.repository == 'OpenVisualCloud/Media-Transport-Library' }}
1632
strategy:
1733
matrix:
1834
nic:
@@ -24,26 +40,31 @@ jobs:
2440
timeout-minutes: 720
2541
steps:
2642
- name: 'preparation: Harden Runner'
43+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
2744
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
2845
with:
2946
egress-policy: audit
3047
- name: 'preparation: Checkout MTL'
48+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
3149
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3250
with:
3351
ref: '${{ github.ref }}'
3452
- uses: ./.github/actions/build
3553
- name: 'installation: Install pipenv environment'
54+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
3655
working-directory: tests/validation
3756
id: pipenv-install
3857
run: |
3958
python3 -m venv .venv
4059
source .venv/bin/activate
4160
pip install -r requirements.txt
4261
- name: Create session ID
62+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
4363
run: |
4464
runner_name=${{ runner.name }}
4565
echo "SESSION_ID=${runner_name##*-}" >> "$GITHUB_ENV"
4666
- name: Set PCI device env variable
67+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
4768
run: |
4869
if [ "${{ matrix.nic }}" = "e810" ]; then
4970
echo "PCI_DEVICE=8086:1592" >> "$GITHUB_ENV"
@@ -53,6 +74,7 @@ jobs:
5374
echo "PCI_DEVICE=8086:12d2" >> "$GITHUB_ENV"
5475
fi
5576
- name: Generate test framework config files
77+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
5678
working-directory: tests/validation/configs
5779
run: |
5880
python3 gen_config.py \
@@ -64,6 +86,7 @@ jobs:
6486
--username ${{ secrets.RUNNER_USERNAME }} \
6587
--key_path ${{ secrets.RUNNER_KEY_PATH }}
6688
- name: 'preparation: Evaluate choosen validation-test-port-p and validation-test-port-r'
89+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
6790
run: |
6891
eval "export TEST_PORT_P=TEST_VF_PORT_P_0"
6992
eval "export TEST_PORT_R=TEST_VF_PORT_P_1"
@@ -72,30 +95,35 @@ jobs:
7295
echo "TEST_PORT_P=${TEST_PORT_P}"
7396
echo "TEST_PORT_R=${TEST_PORT_R}"
7497
- name: 'preparation: Kill MtlManager and pytest routines'
98+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
7599
run: |
76100
sudo killall -SIGINT pipenv || true
77101
sudo killall -SIGINT pytest || true
78102
sudo killall -SIGINT MtlManager || true
79103
- name: 'preparation: Create VFs'
104+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
80105
run: |
81106
sudo rmmod irdma || true
82107
sudo ./script/nicctl.sh create_vf "${TEST_PF_PORT_P}" || true
83108
sudo ./script/nicctl.sh create_vf "${TEST_PF_PORT_R}" || true
84109
- name: 'preparation: Start MtlManager at background'
110+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
85111
run: |
86112
sudo MtlManager &
87113
- name: 'execution: Run validation-bare-metal tests in virtual environment'
114+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
88115
run: |
89116
tests/validation/.venv/bin/python3 -m pytest --topology_config=tests/validation/configs/topology_config.yaml --test_config=tests/validation/configs/test_config.yaml -m smoke --template=html/index.html --report=report.html
90117
- name: "upload report"
118+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
91119
id: upload-report
92120
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
93121
with:
94122
name: smoke-test-report-${{ matrix.nic }}
95123
path: |
96124
report.html
97125
- name: "Add report to summary"
98-
if: always()
126+
if: ${{ needs.smoke-check-for-changes.outputs.changed == 'true' }}
99127
run: |
100128
{
101129
echo "## Smoke Tests Report"

0 commit comments

Comments
 (0)