-
Notifications
You must be signed in to change notification settings - Fork 186
122 lines (102 loc) · 4.05 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Pull request checks
# Run on PRs and when manually run
on: [pull_request, workflow_dispatch]
jobs:
build-and-test:
runs-on: ubuntu-latest
container:
image: robojackets/robocup-software:foxy
defaults:
run:
shell: bash
steps:
- name: Config git
run: "git config --global --add safe.directory /__w/robocup-software/robocup-software"
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Run util/ubuntu-setup as sudo
run: "sudo ./util/ubuntu-setup --yes"
- name: Install git pre-commit hooks & update submodules
run: "./util/git-setup --yes"
- name: Make ${{ github.base_ref }} branch exist
run: |
git checkout -b ${{ github.base_ref }} --track origin/${{ github.base_ref }}
git checkout -
- name: Build
run: |
echo "::add-matcher::ci/clang.json"
source /opt/ros/foxy/setup.bash
source install/setup.bash
make all
echo "::remove-matcher owner=clang::"
- name: Test
run: |
echo "::add-matcher::ci/gtest.json"
source /opt/ros/foxy/setup.bash
source install/setup.bash
./install/lib/rj_robocup/test-soccer
echo "::remove-matcher owner=gtest::"
- name: Run clang-tidy
run: |
echo "::add-matcher::ci/clang-tidy.json"
source /opt/ros/foxy/setup.bash
source install/setup.bash
DIFFBASE=${{ github.base_ref }} make checktidy-lines
echo "::remove-matcher owner=clang-tidy::"
if: always()
fix-style:
# Check if the PR is not raised by this workflow
if: startsWith(github.head_ref, 'fix-code-style') == false
runs-on: ubuntu-latest
container:
image: ros:foxy
defaults:
run:
shell: bash
steps:
- name: Config git
run: "git config --global --add safe.directory /__w/robocup-software/robocup-software"
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Make ${{ github.base_ref }} branch exist
run: |
git checkout -b ${{ github.base_ref }} --track origin/${{ github.base_ref }}
git checkout -
- name: Install dependencies
run: |
apt-get update && apt-get -y install clang-format sudo git python3-pip
sudo pip3 install --upgrade flake8-diff flake8 pip
sudo pip3 install --upgrade black
- name: Make ${{ github.head_ref }} branch exist
run: |
git checkout -b ${{ github.head_ref }}
git checkout -
- name: Run style on all changed files
id: style-check
run: |
# check formatting style (C++)
git diff -U0 --no-color ${{ github.base_ref }} ${{ github.head_ref }} | python3 util/clang-format-diff.py -binary clang-format-10 -i -p1
if ! git diff-index --quiet HEAD; then
echo "::set-output name=changed::true"
else
echo "::set-output name=changed::false"
fi
- name: Create PR with style fixes
# Only make the PR if the original PR is within this repo (not from a fork)
if: steps.style-check.outputs.changed == 'true' && github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-pull-request@v3
with:
commit-message: "automated style fixes"
title: Fix Code Style On ${{ github.head_ref }}
body: This pull request contains automatic style formatting for PR \#${{ github.event.number }}. @${{ github.event.pull_request.user.login }}, please merge this branch into your own to pass style checks!
labels: style fixes, automated PR
branch: fix-code-style/${{ github.head_ref }}
base: ${{ github.head_ref }}
reviewers: ${{ github.event.pull_request.user.login }}
- name: Fail if style changes were made
if: steps.style-check.outputs.changed == 'true'
run: exit 1