Added github actions for build and clang-tidy/format. #4
Workflow file for this run
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: 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.all }} | |
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: | | |
$HOME/atos_ws/build | |
$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: | | |
$HOME/atos_ws/build | |
$HOME/atos_ws/install | |
key: ${{ steps.cache-build-restore.outputs.cache-primary-key }} | |
- 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: target-files | |
uses: jitterbit/get-changed-files@v1 | |
- run: | | |
echo ${{ steps.target-files.outputs.all }} | |
shell: bash | |
- name: Analyze | |
if: ${{ steps.target-files.outputs.all != '' }} | |
run: | | |
mkdir /tmp/clang-tidy-result | |
clang-tidy -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml ${{ steps.target-files.outputs.all }} || 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 | |
run: | | |
mkdir /tmp/clang-format-result | |
for changed_file in ${{ steps.target-files.outputs.all }}; do | |
clang-format ${changed_file} > /tmp/clang-format-result/${changed_file} || true | |
done | |
- name: Check if the clang-format-result.txt file exists | |
id: check-clang-format-result-existence | |
uses: autowarefoundation/autoware-github-actions/check-file-existence@v1 | |
with: | |
files: | | |
/tmp/clang-format-result/*.cpp | |
/tmp/clang-format-result/*.hpp | |
/tmp/clang-format-result/*.c | |
/tmp/clang-format-result/*.h | |
condition: or | |
- name: Upload artifacts | |
if: ${{ steps.check-clang-format-result-existence.outputs.exists == 'true' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: clang-format-result | |
path: /tmp/clang-format-result/ |