Skip to content

Commit

Permalink
WIP ccache
Browse files Browse the repository at this point in the history
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
  • Loading branch information
mojomex committed Feb 19, 2025
1 parent b885b1c commit 01abd00
Showing 1 changed file with 104 additions and 32 deletions.
136 changes: 104 additions & 32 deletions .github/workflows/build-and-test-differential.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1

- name: Install ccache
run: sudo apt-get update && sudo apt-get install -y ccache
run: sudo apt-get -yqq update && sudo apt-get -yqq install ccache
shell: bash

- name: Create ccache directory
Expand Down Expand Up @@ -104,7 +104,16 @@ jobs:
- rosdistro: humble
container: ros:humble
build-depends-repos: build_depends.repos
env:
CCACHE_DIR: /root/.ccache
INFER_REPORT_PARENT_DIR: /tmp
CC: /usr/lib/ccache/clang-15
CXX: /usr/lib/ccache/clang++-15
steps:
########################################
# Feature branch analysis
########################################

- name: Check out repository
uses: actions/checkout@v3
with:
Expand All @@ -114,23 +123,36 @@ jobs:
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1

- name: Get modified packages
id: get-modified-packages
id: get-modified-packages-feature
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1

- name: Install Clang-15
- name: Install Clang-15 and ccache
run: |
sudo apt-get -yqq update
sudo apt-get -yqq install --install-recommends clang-15 clang-tidy-15 clangd-15
sudo apt-get -yqq install clang-15-doc wasi-libc llvm-15-doc

Check warning on line 133 in .github/workflows/build-and-test-differential.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (wasi)
sudo apt-get -yqq install libomp-15-dev libomp-15-doc # For OpenMP support in Clang
sudo apt-get -yqq install libstdc++-12-dev
echo "CC=/usr/bin/clang-15" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++-15" >> $GITHUB_ENV
sudo apt-get -yqq install ccache
- name: Create ccache directory
run: |
mkdir -p ${CCACHE_DIR}
du -sh ${CCACHE_DIR} && ccache -s
shell: bash

- name: Attempt to restore ccache
uses: actions/cache/restore@v4
with:
path: |
${CCACHE_DIR}
key: ccache-${{ runner.arch }}-${{ matrix.rosdistro }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
ccache-${{ runner.arch }}-${{ matrix.rosdistro }}-
- name: Install FB Infer
id: fb-infer-install
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
if: ${{ steps.get-modified-packages-feature.outputs.modified-packages != '' }}
env:
VERSION: 1.2.0
run: |
Expand All @@ -143,67 +165,117 @@ jobs:
sudo mv "$BASENAME" /usr/local/infer
echo "PATH=/usr/local/infer/bin:$PATH" >> $GITHUB_ENV
- name: Restore main branch infer cache
id: cache-infer-restore
uses: actions/cache/restore@v4
with:
path: infer-out-main
key: infer-main-${{ github.base_ref }}-${{ github.event.pull_request.base.sha }}
- name: Show ccache stats before build and reset stats
run: |
du -sh ${CCACHE_DIR} && ccache -s
ccache --zero-stats
shell: bash

- name: Build feature branch
id: build-feature
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
if: ${{ steps.get-modified-packages-feature.outputs.modified-packages != '' }}
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
with:
rosdistro: ${{ matrix.rosdistro }}
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
target-packages: ${{ steps.get-modified-packages-feature.outputs.modified-packages }}
build-depends-repos: ${{ matrix.build-depends-repos }}

- name: Show ccache stats after build
run: |
du -sh ${CCACHE_DIR} && ccache -s
shell: bash

- name: Analyze feature branch
id: analyze-feature
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
if: ${{ steps.get-modified-packages-feature.outputs.modified-packages != '' }}
run: |
# Run infer on feature branch
infer capture --compilation-database build/compile_commands.json
infer analyze
# Store feature branch report
mv infer-out infer-out-feature
mv infer-out ${INFER_REPORT_PARENT_DIR}/infer-out-feature
########################################
# Main branch analysis
########################################

- name: Restore main branch infer cache
id: cache-infer-restore
uses: actions/cache/restore@v4
with:
path: ${{ env.INFER_REPORT_PARENT_DIR }}/infer-out-main
key: infer-main-${{ github.base_ref }}-${{ github.event.pull_request.base.sha }}
restore-keys: |
infer-main-${{ github.base_ref }}-
- name: Checkout main branch
id: checkout-main
if: ${{ steps.cache-infer-restore.outputs.cache-hit != 'true' }}
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.base_ref }}

- name: Remove exec_depend
if: ${{ steps.cache-infer-restore.outputs.cache-hit != 'true' }}
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1

- name: Analyze main branch (if no cache)
if: ${{ steps.cache-infer-restore.outputs.cache-hit != 'true' && steps.feature-analysis.outcome == 'success' }}
- name: Show ccache stats before build and reset stats
run: |
# Checkout main
git checkout ${{ github.base_ref }}
du -sh ${CCACHE_DIR} && ccache -s
ccache --zero-stats
shell: bash

# Build main branch
rm -rf build/ install/ log/
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Build main branch
id: build-main
if: ${{ steps.cache-infer-restore.outputs.cache-hit != 'true' }}
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
with:
rosdistro: ${{ matrix.rosdistro }}
target-packages: ${{ steps.get-modified-packages-feature.outputs.modified-packages }}
build-depends-repos: ${{ matrix.build-depends-repos }}

# Run infer on main branch
- name: Show ccache stats after build
run: |
du -sh ${CCACHE_DIR} && ccache -s
shell: bash

- name: Analyze main branch
id: analyze-main
if: ${{ steps.cache-infer-restore.outputs.cache-hit != 'true' }}
run: |
# Run infer on feature branch
infer capture --compilation-database build/compile_commands.json
infer analyze
# Save main branch results for caching
mv infer-out infer-out-main
# Store main branch report
mv infer-out ${INFER_REPORT_PARENT_DIR}/infer-out-main
- name: Cache main branch infer results
if: ${{ steps.cache-infer-restore.outputs.cache-hit != 'true' && steps.feature-analysis.outcome == 'success' }}
if: ${{ steps.cache-infer-restore.outputs.cache-hit != 'true' && steps.analyze-main.outcome == 'success' }}
uses: actions/cache/save@v4
with:
path: infer-out-main
path: ${{ env.INFER_REPORT_PARENT_DIR }}/infer-out-main
key: infer-main-${{ github.base_ref }}-${{ github.event.pull_request.base.sha }}

########################################
# Differential analysis
########################################

- name: Compare reports
if: ${{ steps.feature-analysis.outcome == 'success' }}
if: ${{ steps.analyze-feature.outcome == 'success' }}
run: |
infer reportdiff --report-current infer-out-feature/report.json --report-previous infer-out-main/report.json
infer reportdiff \
--report-current ${INFER_REPORT_PARENT_DIR}/infer-out-feature/report.json \
--report-previous ${INFER_REPORT_PARENT_DIR}/infer-out-main/report.json
mv infer-out ${INFER_REPORT_PARENT_DIR}/infer-out-differential
- name: Upload FB Infer Reports
uses: actions/upload-artifact@v4
with:
name: infer-reports-${{ github.sha }}
path: |
infer-out-feature/report.json
infer-out/differential/*
${INFER_REPORT_PARENT_DIR}/infer-out-feature/report.json
${INFER_REPORT_PARENT_DIR}/infer-out-differential/*
if-no-files-found: error

0 comments on commit 01abd00

Please sign in to comment.