Skip to content

Do not build Docker image if not changes #71

Do not build Docker image if not changes

Do not build Docker image if not changes #71

name: sc-standalone-deb11
on:
pull_request:
types: [ opened, synchronize, reopened ]
branches: [ "**" ]
paths:
- '.github/workflows/sc-standalone-deb11.yml'
- 'dockerfiles/bullseye/Dockerfile'
- 'npu/broadcom/BCM56850/saivs/Dockerfile'
- 'npu/broadcom/BCM56850/saivs/Dockerfile.saithrift'
- 'common/**'
- 'cli/**'
- 'scripts/**'
- 'configs/**'
- 'tests/**'
- 'setup.py'
- 'build.sh'
- 'run.sh'
- 'exec.sh'
- '.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:
#check_changes:
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 2
# - name: Check what files were updated
# id: check_changes
# run: echo "::set-output name=changed_files::$(git diff --name-only HEAD~1)"
build-sc-stadalone:
name: Build SAI Challenger standalone image
runs-on: ubuntu-20.04
#needs: [check_changes]
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<<EOF' >> $GITHUB_OUTPUT
echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
#run: |
# CHANGED_FILES=$(git diff --name-only HEAD~1)
# MESSAGE=$(cat << EOF
# $CHANGED_FILES
# EOF
# )
# echo "changed_files=$MESSAGE" >> $GITHUB_OUTPUT
#echo "changed_files=$(git diff --name-only HEAD~1)" >> "$GITHUB_OUTPUT"
#run: echo "::set-output name=changed_files::$(git diff --name-only HEAD~1)"
- name: Setup upterm session
run: |
echo $REDIS_RPC
echo $THRIFT_RPC
for file in "$DOCKER_BASE" "$DOCKER_REDIS"; do
if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then
REDIS_RPC=1
fi
done
for file in "$DOCKER_BASE" "$DOCKER_THRIFT"; do
if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then
THRIFT_RPC=1
fi
done
echo $REDIS_RPC
echo $THRIFT_RPC
#for file in "${{ steps.check_changes.outputs.changed_files }}"; do
# REDIS_RPC=1
# echo $REDIS_RPC
# echo $DOCKER_BASE
# echo $DOCKER_REDIS
# echo $file
# if [[ "$file" == $DOCKER_BASE || "$file" == $DOCKER_REDIS ]]; then
# env.REDIS_RPC=1
# fi
# if [[ "$file" == $DOCKER_BASE || "$file" == $DOCKER_THRIFT ]]; then
# env.THRIFT_RPC=1
# fi
done
- name: Conditional Step
#if: ${{ $REDIS_RPC == '1' }}
run: |
echo "REDIS_RPC is equal to 1"
#- name: Build standalone Docker image
# run: ./build.sh -i standalone -o deb11
# if: ${{ contains(steps.check_changes.outputs.changed_files, '^($DOCKER_BASE|$DOCKER_REDIS)($|\\s)') }}
- 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: ${{ !contains(steps.check_changes.outputs.changed_files, '^($DOCKER_BASE|$DOCKER_REDIS)($|\\s)') }}
- 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
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v -k "test_sairec"
- name: Run unit tests
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v -k \
"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: ${{ contains(steps.check_changes.outputs.changed_files, '^($DOCKER_BASE|$DOCKER_THRIFT)($|\\s)') }}
- 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: ${{ !contains(steps.check_changes.outputs.changed_files, '^($DOCKER_BASE|$DOCKER_THRIFT)($|\\s)') }}
- 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
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v test_l2_basic_dd.py
- name: Run thrift unit tests
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v ut/test_vrf_ut.py ut/test_bridge_ut.py ut/test_acl_ut.py
- name: Run thrift sairedis tests
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v -k "test_sairec"