ci: introduce Facebook Infer job #1296
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-test-differential | |
on: | |
pull_request: | |
jobs: | |
build-and-test-differential: | |
runs-on: ubuntu-latest | |
container: ${{ matrix.container }} | |
strategy: | |
fail-fast: false | |
matrix: | |
rosdistro: | |
- humble | |
include: | |
- rosdistro: humble | |
container: ros:humble | |
build-depends-repos: build_depends.repos | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Remove exec_depend | |
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 | |
- name: Get modified packages | |
id: get-modified-packages | |
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1 | |
- name: Build | |
id: build | |
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} | |
uses: autowarefoundation/autoware-github-actions/colcon-build@v1 | |
with: | |
rosdistro: ${{ matrix.rosdistro }} | |
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} | |
build-depends-repos: ${{ matrix.build-depends-repos }} | |
- name: Upload compilation database | |
if: ${{ steps.build.outcome == 'success' }} | |
id: upload-compile-db | |
uses: actions/upload-artifact@v4 | |
with: | |
name: compilation-database-diff-${{ github.sha }} | |
path: build/compile_commands.json | |
if-no-files-found: error | |
- name: Test | |
id: test | |
if: ${{ steps.build.outcome == 'success' }} | |
uses: autowarefoundation/autoware-github-actions/colcon-test@v1 | |
with: | |
rosdistro: ${{ matrix.rosdistro }} | |
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} | |
build-depends-repos: ${{ matrix.build-depends-repos }} | |
- name: Upload coverage to CodeCov | |
if: ${{ steps.test.outputs.coverage-report-files != '' }} | |
uses: codecov/codecov-action@v4 | |
with: | |
files: ${{ steps.test.outputs.coverage-report-files }} | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: false | |
verbose: true | |
flags: differential | |
fb-infer-differential: | |
runs-on: ubuntu-latest | |
needs: [build-and-test-differential] | |
if: ${{ needs.build-and-test-differential.result }} | |
steps: | |
- name: Download compilation database | |
id: download-compile-db | |
uses: actions/download-artifact@v4 | |
with: | |
name: compilation-database-diff-${{ github.sha }} | |
continue-on-error: true | |
- name: Install FB Infer | |
id: fb-infer-install | |
if: ${{ steps.download-compile-db.outcome == 'success' }} | |
env: | |
VERSION: 1.2.0 | |
run: | | |
curl -sSL "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux-x86_64-v$VERSION.tar.xz" \ | |
sudo ln -s "infer-linux-x86_64-v$VERSION/bin/infer" ./infer | |
- name: Run FB Infer | |
id: fb-infer-run | |
if: ${{ steps.fb-infer-install.outcome == 'success' }} | |
run: | | |
git diff --name-only ${{ github.head_ref }}..${{ github.base_ref }} > changed-files.txt | |
infer run --changed-files-index changed-files.txt --compilation-database ./compile_commands.json | |
- name: Upload FB Infer Report | |
id: fb-infer-upload | |
if: ${{ steps.fb-infer-run.outcome == 'success' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: infer-report-diff-${{ github.head_ref }} | |
path: infer-out/report.* | |
if-no-files-found: error |