Skip to content

Added github actions for build and clang-tidy/format. #10

Added github actions for build and clang-tidy/format.

Added github actions for build and clang-tidy/format. #10

Workflow file for this run

name: clang-tidy-review
# You can be more specific, but it currently only works on pull requests
on: [pull_request]
jobs:
clang-tidy:
runs-on: ubuntu-latest
container: ros:humble
outputs:
output1: ${{ steps.target-files.outputs.target_files }}
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Restore build cache
id: cache-build-restore
uses: actions/cache/restore@v4
with:
path: |
/github/home/atos_ws/build
/github/home/atos_ws/install
key: ${{ runner.os }}-build
- name: Install ATOS
run: |
./setup_atos.sh
shell: bash
- name: Save build cache
id: cache-build-save
uses: actions/cache/save@v4
with:
path: |
/github/home/atos_ws/build
/github/home/atos_ws/install
key: ${{ runner.os }}-build
- name: Install Clang-Tidy
run: |
sudo apt-get -yqq update
sudo apt-get -yqq install clang-tidy libomp-dev
shell: bash
- name: Get changed files
id: changed-files
uses: jitterbit/get-changed-files@v1
- name: Remove deleted files from changed files list
id: target-files
run: |
existing_files=()
for file in $(cat ${{ steps.changed-files.outputs.all }}); do
if [ -f $file ]; then
existing_files+=("$file")
fi
done
{
echo 'target_files<<EOF'
echo ${existing_files[@]}
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Analyze
if: ${{ steps.target-files.outputs.all != '' }}
env:
ALL_CHANGED_FILES: ${{ steps.target-files.outputs.target_files }}
run: |
mkdir /tmp/clang-tidy-result
clang-tidy -p $HOME/atos_ws/build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml ${ALL_CHANGED_FILES} || true
echo "${{ github.event.number }}" > /tmp/clang-tidy-result/pr-id.txt
echo "${{ github.event.pull_request.head.repo.full_name }}" > /tmp/clang-tidy-result/pr-head-repo.txt
echo "${{ github.event.pull_request.head.ref }}" > /tmp/clang-tidy-result/pr-head-ref.txt
shell: bash
- name: Check if the fixes.yaml file exists
id: check-fixes-yaml-existence
uses: autowarefoundation/autoware-github-actions/check-file-existence@v1
with:
files: /tmp/clang-tidy-result/fixes.yaml
- name: Upload artifacts
if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }}
uses: actions/upload-artifact@v4
with:
name: clang-tidy-result
path: /tmp/clang-tidy-result/
- name: Install clang-format
run: |
sudo apt-get -yqq update
sudo apt-get -yqq install clang-format
shell: bash
- name: Run clang-format style check.
id: clang-format
env:
ALL_CHANGED_FILES: ${{ steps.target-files.outputs.target_files }}
run: |
mkdir /tmp/clang-format-result
for file_path in ${ALL_CHANGED_FILES}; do
folder_name="${file_path%/*}/"
mkdir -p /tmp/clang-format-result/$folder_name
clang-format ${file_path} > /tmp/clang-format-result/${file_path} || true
done
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: clang-format-result
path: /tmp/clang-format-result/