Skip to content

Commit 0f16887

Browse files
Do not build standalone Docker images if not changes (#170)
Signed-off-by: Andriy Kokhan <[email protected]>
1 parent 9ee7ec8 commit 0f16887

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-2
lines changed

.github/workflows/sc-standalone-deb10.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,54 @@ on:
2121
- '.dockerignore'
2222
- 'sai.env'
2323

24+
env:
25+
DOCKER_BASE: 'dockerfiles/buster/Dockerfile'
26+
DOCKER_REDIS: 'npu/broadcom/BCM56850/saivs/Dockerfile'
27+
DOCKER_THRIFT: 'npu/broadcom/BCM56850/saivs/Dockerfile.saithrift'
28+
REDIS_RPC: 0
29+
THRIFT_RPC: 0
30+
2431
jobs:
25-
build-sc-stadalone-thrift:
32+
build-sc-stadalone:
2633
name: Build SAI Challenger standalone image
2734
runs-on: ubuntu-20.04
2835
steps:
2936
- uses: actions/checkout@v3
37+
with:
38+
fetch-depth: 2
3039
- name: Update submodules
3140
run: git submodule update --init
41+
42+
- name: Check what files were updated
43+
id: check_changes
44+
run: |
45+
echo 'changed_files<<EOF' >> $GITHUB_OUTPUT
46+
echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT
47+
echo 'EOF' >> $GITHUB_OUTPUT
48+
49+
- name: Check what Docker images have to be rebuild
50+
run: |
51+
for file in "$DOCKER_BASE" "$DOCKER_REDIS"; do
52+
if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then
53+
echo "REDIS_RPC=1" >> $GITHUB_ENV
54+
fi
55+
done
56+
for file in "$DOCKER_BASE" "$DOCKER_THRIFT"; do
57+
if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then
58+
echo "THRIFT_RPC=1" >> $GITHUB_ENV
59+
fi
60+
done
61+
3262
- name: Build standalone Docker image
3363
run: ./build.sh -i standalone -o deb10
64+
if: ${{ env.REDIS_RPC == '1' }}
65+
3466
- name: Start SAI-C in standalone mode
3567
run: ./run.sh -i standalone -o deb10
68+
- name: Update SAI-C package
69+
run: ./exec.sh --no-tty pip3 install /sai-challenger/common /sai-challenger
70+
if: ${{ env.REDIS_RPC == '0' }}
71+
3672
- name: Run tests
3773
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic.py -v test_vrf.py -v test_dc_t1.py
3874
- name: Run sairedis tests
@@ -42,10 +78,17 @@ jobs:
4278
"test_acl_ut or test_bridge_ut or (test_switch_ut and not sai_map_list_t) or test_vrf_ut or test_port_ut.py"
4379
- name: Run data-driven tests
4480
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic_dd.py
81+
4582
- name: Build standalone docker image with SAI thrift
4683
run: ./build.sh -i standalone -s thrift -o deb10
84+
if: ${{ env.THRIFT_RPC == '1' }}
85+
4786
- name: Start SAI-C in standalone mode with SAI thrift
4887
run: ./run.sh -i standalone -s thrift -o deb10
88+
- name: Update SAI-C package
89+
run: ./exec.sh --no-tty -s thrift pip3 install /sai-challenger/common /sai-challenger
90+
if: ${{ env.THRIFT_RPC == '0' }}
91+
4992
- name: Run thrift tests
5093
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v test_l2_basic.py -v test_vrf.py -v test_dc_t1.py
5194
- name: Run thift data-driven tests

.github/workflows/sc-standalone-deb11.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,54 @@ on:
2121
- '.dockerignore'
2222
- 'sai.env'
2323

24+
env:
25+
DOCKER_BASE: 'dockerfiles/bullseye/Dockerfile'
26+
DOCKER_REDIS: 'npu/broadcom/BCM56850/saivs/Dockerfile'
27+
DOCKER_THRIFT: 'npu/broadcom/BCM56850/saivs/Dockerfile.saithrift'
28+
REDIS_RPC: 0
29+
THRIFT_RPC: 0
30+
2431
jobs:
25-
build-sc-stadalone-thrift:
32+
build-sc-stadalone:
2633
name: Build SAI Challenger standalone image
2734
runs-on: ubuntu-20.04
2835
steps:
2936
- uses: actions/checkout@v3
37+
with:
38+
fetch-depth: 2
3039
- name: Update submodules
3140
run: git submodule update --init
41+
42+
- name: Check what files were updated
43+
id: check_changes
44+
run: |
45+
echo 'changed_files<<EOF' >> $GITHUB_OUTPUT
46+
echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT
47+
echo 'EOF' >> $GITHUB_OUTPUT
48+
49+
- name: Check what Docker images have to be rebuild
50+
run: |
51+
for file in "$DOCKER_BASE" "$DOCKER_REDIS"; do
52+
if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then
53+
echo "REDIS_RPC=1" >> $GITHUB_ENV
54+
fi
55+
done
56+
for file in "$DOCKER_BASE" "$DOCKER_THRIFT"; do
57+
if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then
58+
echo "THRIFT_RPC=1" >> $GITHUB_ENV
59+
fi
60+
done
61+
3262
- name: Build standalone Docker image
3363
run: ./build.sh -i standalone -o deb11
64+
if: ${{ env.REDIS_RPC == '1' }}
65+
3466
- name: Start SAI-C in standalone mode
3567
run: ./run.sh -i standalone -o deb11
68+
- name: Update SAI-C package
69+
run: ./exec.sh --no-tty pip3 install /sai-challenger/common /sai-challenger
70+
if: ${{ env.REDIS_RPC == '0' }}
71+
3672
- name: Run tests
3773
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic.py -v test_vrf.py -v test_dc_t1.py
3874
- name: Run sairedis tests
@@ -42,10 +78,17 @@ jobs:
4278
"test_acl_ut or test_bridge_ut or (test_switch_ut and not sai_map_list_t) or test_vrf_ut or test_port_ut.py"
4379
- name: Run data-driven tests
4480
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic_dd.py
81+
4582
- name: Build standalone docker image with SAI thrift
4683
run: ./build.sh -i standalone -s thrift -o deb11
84+
if: ${{ env.THRIFT_RPC == '1' }}
85+
4786
- name: Start SAI-C in standalone mode with SAI thrift
4887
run: ./run.sh -i standalone -s thrift -o deb11
88+
- name: Update SAI-C package
89+
run: ./exec.sh --no-tty -s thrift pip3 install /sai-challenger/common /sai-challenger
90+
if: ${{ env.THRIFT_RPC == '0' }}
91+
4992
- name: Run thrift tests
5093
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v test_l2_basic.py -v test_vrf.py -v test_dc_t1.py
5194
- name: Run thift data-driven tests

0 commit comments

Comments
 (0)