From 0f168871e20c83eca661241ff62b9f33e0657764 Mon Sep 17 00:00:00 2001 From: Andriy Kokhan Date: Mon, 17 Jul 2023 22:31:54 +0300 Subject: [PATCH] Do not build standalone Docker images if not changes (#170) Signed-off-by: Andriy Kokhan --- .github/workflows/sc-standalone-deb10.yml | 45 ++++++++++++++++++++++- .github/workflows/sc-standalone-deb11.yml | 45 ++++++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sc-standalone-deb10.yml b/.github/workflows/sc-standalone-deb10.yml index e76934d8..a82e7568 100644 --- a/.github/workflows/sc-standalone-deb10.yml +++ b/.github/workflows/sc-standalone-deb10.yml @@ -21,18 +21,54 @@ on: - '.dockerignore' - 'sai.env' +env: + DOCKER_BASE: 'dockerfiles/buster/Dockerfile' + DOCKER_REDIS: 'npu/broadcom/BCM56850/saivs/Dockerfile' + DOCKER_THRIFT: 'npu/broadcom/BCM56850/saivs/Dockerfile.saithrift' + REDIS_RPC: 0 + THRIFT_RPC: 0 + jobs: - build-sc-stadalone-thrift: + build-sc-stadalone: name: Build SAI Challenger standalone image runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 + with: + fetch-depth: 2 - name: Update submodules run: git submodule update --init + + - name: Check what files were updated + id: check_changes + run: | + echo 'changed_files<> $GITHUB_OUTPUT + echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + - name: Check what Docker images have to be rebuild + run: | + for file in "$DOCKER_BASE" "$DOCKER_REDIS"; do + if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then + echo "REDIS_RPC=1" >> $GITHUB_ENV + fi + done + for file in "$DOCKER_BASE" "$DOCKER_THRIFT"; do + if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then + echo "THRIFT_RPC=1" >> $GITHUB_ENV + fi + done + - name: Build standalone Docker image run: ./build.sh -i standalone -o deb10 + if: ${{ env.REDIS_RPC == '1' }} + - name: Start SAI-C in standalone mode run: ./run.sh -i standalone -o deb10 + - name: Update SAI-C package + run: ./exec.sh --no-tty pip3 install /sai-challenger/common /sai-challenger + if: ${{ env.REDIS_RPC == '0' }} + - name: Run tests run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic.py -v test_vrf.py -v test_dc_t1.py - name: Run sairedis tests @@ -42,10 +78,17 @@ jobs: "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" - name: Run data-driven tests run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic_dd.py + - name: Build standalone docker image with SAI thrift run: ./build.sh -i standalone -s thrift -o deb10 + if: ${{ env.THRIFT_RPC == '1' }} + - name: Start SAI-C in standalone mode with SAI thrift run: ./run.sh -i standalone -s thrift -o deb10 + - name: Update SAI-C package + run: ./exec.sh --no-tty -s thrift pip3 install /sai-challenger/common /sai-challenger + if: ${{ env.THRIFT_RPC == '0' }} + - name: Run thrift tests 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 - name: Run thift data-driven tests diff --git a/.github/workflows/sc-standalone-deb11.yml b/.github/workflows/sc-standalone-deb11.yml index c0db4b0b..5ded7862 100644 --- a/.github/workflows/sc-standalone-deb11.yml +++ b/.github/workflows/sc-standalone-deb11.yml @@ -21,18 +21,54 @@ on: - '.dockerignore' - 'sai.env' +env: + DOCKER_BASE: 'dockerfiles/bullseye/Dockerfile' + DOCKER_REDIS: 'npu/broadcom/BCM56850/saivs/Dockerfile' + DOCKER_THRIFT: 'npu/broadcom/BCM56850/saivs/Dockerfile.saithrift' + REDIS_RPC: 0 + THRIFT_RPC: 0 + jobs: - build-sc-stadalone-thrift: + build-sc-stadalone: name: Build SAI Challenger standalone image runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 + with: + fetch-depth: 2 - name: Update submodules run: git submodule update --init + + - name: Check what files were updated + id: check_changes + run: | + echo 'changed_files<> $GITHUB_OUTPUT + echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + - name: Check what Docker images have to be rebuild + run: | + for file in "$DOCKER_BASE" "$DOCKER_REDIS"; do + if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then + echo "REDIS_RPC=1" >> $GITHUB_ENV + fi + done + for file in "$DOCKER_BASE" "$DOCKER_THRIFT"; do + if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then + echo "THRIFT_RPC=1" >> $GITHUB_ENV + fi + done + - name: Build standalone Docker image run: ./build.sh -i standalone -o deb11 + if: ${{ env.REDIS_RPC == '1' }} + - name: Start SAI-C in standalone mode run: ./run.sh -i standalone -o deb11 + - name: Update SAI-C package + run: ./exec.sh --no-tty pip3 install /sai-challenger/common /sai-challenger + if: ${{ env.REDIS_RPC == '0' }} + - name: Run tests run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic.py -v test_vrf.py -v test_dc_t1.py - name: Run sairedis tests @@ -42,10 +78,17 @@ jobs: "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" - name: Run data-driven tests run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic_dd.py + - name: Build standalone docker image with SAI thrift run: ./build.sh -i standalone -s thrift -o deb11 + if: ${{ env.THRIFT_RPC == '1' }} + - name: Start SAI-C in standalone mode with SAI thrift run: ./run.sh -i standalone -s thrift -o deb11 + - name: Update SAI-C package + run: ./exec.sh --no-tty -s thrift pip3 install /sai-challenger/common /sai-challenger + if: ${{ env.THRIFT_RPC == '0' }} + - name: Run thrift tests 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 - name: Run thift data-driven tests