Skip to content

Commit

Permalink
github: Skip clang-analyze when reference generation fails.
Browse files Browse the repository at this point in the history
Compiling the OVS reference is supposed to succeed unless some external
change breaks this compilation.

One example is when DPDK API changes and breaks OVS compilation.
This case is hit in the dpdk-latest branch, but also when bumping DPDK
version in the main branch.

On the other hand, the clang-analyze check goal is to validate OVS
changes, not external changes.

Fixes: d662eee ("ci: Add clang-analyze to GitHub actions.")
Signed-off-by: David Marchand <[email protected]>
  • Loading branch information
david-marchand committed Nov 22, 2024
1 parent 33fa349 commit 07c8185
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 19 deletions.
12 changes: 2 additions & 10 deletions .ci/linux-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,19 @@ function build_ovs()

function clang_analyze()
{
[ -d "./base-clang-analyzer-results" ] && cache_build=false \
|| cache_build=true
if [ "$cache_build" = true ]; then
# If this is a cache build, proceed to the base branch's directory.
pushd base_ovs_main
fi;

configure_ovs $OPTS

make clean
scan-build -o ./clang-analyzer-results -sarif --use-cc=${CC} make ${JOBS}

if [ "$cache_build" = true ]; then
if [ ! -d "./base-clang-analyzer-results" ]; then
# Move results, so it will be picked up by the cache.
mv ./clang-analyzer-results ../base-clang-analyzer-results
popd
else
# Only do the compare on the none cache builds.
sarif --check note diff ./base-clang-analyzer-results \
./clang-analyzer-results
fi;
fi
}

if [ "$DEB_PACKAGE" ]; then
Expand Down
74 changes: 65 additions & 9 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ jobs:
name: logs-linux-${{ join(matrix.*, '-') }}
path: logs.tgz

build-clang-analyze:
build-clang-reference:
needs: build-dpdk
env:
dependencies: |
Expand All @@ -345,7 +345,10 @@ jobs:
CC: clang
DPDK: dpdk
CLANG_ANALYZE: true
name: clang-analyze
name: clang-reference
outputs:
clang_cache_key: ${{ steps.clang_cache_key.outputs.key }}
clang_cache_outcome: ${{ steps.build_base.outcome }}
runs-on: ubuntu-24.04
timeout-minutes: 30

Expand Down Expand Up @@ -401,7 +404,7 @@ jobs:
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: generate cache key
id: cache_key
id: clang_cache_key
run: |
ver=$(${CC} -v 2>&1 | grep ' version ' | \
sed 's/.*version \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/g')
Expand All @@ -413,38 +416,91 @@ jobs:
uses: actions/cache@v4
with:
path: base-clang-analyzer-results
key: ${{ steps.cache_key.outputs.key }}
key: ${{ steps.clang_cache_key.outputs.key }}

- name: set up python
if: steps.clang_cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_default }}

- name: get cached dpdk-dir
uses: actions/cache/restore@v4
if: steps.clang_cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: dpdk-dir
key: ${{ needs.build-dpdk.outputs.dpdk_key }}

- name: update APT cache
if: steps.clang_cache.outputs.cache-hit != 'true'
run: sudo apt update || true

- name: install common dependencies
if: steps.clang_cache.outputs.cache-hit != 'true'
run: sudo apt install -y ${{ env.dependencies }}

- name: prepare
if: steps.clang_cache.outputs.cache-hit != 'true'
run: ./.ci/linux-prepare.sh

- name: build base reference
id: build_base
if: steps.clang_cache.outputs.cache-hit != 'true'
continue-on-error: true
run: ./.ci/linux-build.sh

- name: save cache
uses: actions/cache/save@v4
if: steps.clang_cache.outputs.cache-hit != 'true'
build-clang-analyze:
needs: [build-dpdk, build-clang-reference]
if: >
needs.build-clang-reference.outputs.clang_cache_outcome == 'success' ||
needs.build-clang-reference.outputs.clang_cache_outcome == 'skipped'
env:
dependencies: |
automake bc clang-tools libnuma-dev libunbound-dev libunwind-dev \
libssl-dev libtool libxdp-dev llvm-dev
CC: clang
DPDK: dpdk
CLANG_ANALYZE: true
name: clang-analyze
runs-on: ubuntu-24.04
timeout-minutes: 30

steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: update PATH
run: |
echo "$HOME/bin" >> $GITHUB_PATH
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: check for analyzer result cache
uses: actions/cache@v4
with:
path: base-clang-analyzer-results
key: ${{ steps.cache_key.outputs.key }}
key: ${{ needs.build-clang-analyze-reference.outputs.clang_cache_key }}

- name: set up python
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_default }}

- name: get cached dpdk-dir
uses: actions/cache@v4
with:
path: dpdk-dir
key: ${{ needs.build-dpdk.outputs.dpdk_key }}

- name: update APT cache
run: sudo apt update || true

- name: install common dependencies
run: sudo apt install -y ${{ env.dependencies }}

- name: prepare
run: ./.ci/linux-prepare.sh

- name: build
run: ./.ci/linux-build.sh
Expand Down

0 comments on commit 07c8185

Please sign in to comment.