-
Notifications
You must be signed in to change notification settings - Fork 3
89 lines (72 loc) · 2.63 KB
/
cicd.yaml
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
name: Run Tests
on: [pull_request]
env:
POETRY_VERSION: "1.6.1"
permissions:
contents: write
pull-requests: write
jobs:
test-clang-format:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install clang-format and make
run: |
set -ex
sudo apt-get update
sudo apt-get install -y clang-format make
clang-format --version
- name: Run clang-format
run: |
make format-cpp
# Check if there are any changes after formatting
if ! git diff --quiet; then
echo "Formatting changes detected. Committing and pushing the changes."
# Set up git user for commit
git config user.name "GitHub Action Bot"
git config user.email "[email protected]"
# Add and commit the changes
git add .
git commit -m "chore: auto-format C++ code via clang-format"
# Fetch the latest changes from the remote
git fetch origin
# Merge the latest changes from the remote branch
if ! git merge origin/${{ github.head_ref || github.ref_name }} --no-edit; then
echo "Merge conflict detected. Please resolve conflicts manually."
# TODO: Figure out how to auto-resolve merge conflicts and then set the exit code to 1.
# For now we will just let it pass as success.
exit 0
fi
# Push the changes (force-with-lease to avoid overwriting unrelated changes)
git push --force-with-lease origin HEAD:${{ github.head_ref || github.ref_name }}
else
echo "No formatting changes needed."
fi
run-cpp-unit-tests:
needs: test-clang-format
strategy:
# Ensure that failure for one test does not cancel other actions
fail-fast: false
matrix:
# TODO: Add macos-latest here.
# Currently it's failing as can be seen here:
# Ref: https://github.com/BlaiseMuhirwa/flatnav/actions/runs/12161129183/job/33915004519?pr=72
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install dependencies
run: |
# Install CMake, Clang and LibOMP
make setup-clang-cmake-libomp
- name: Build and Run C++ Unit Tests
run: |
set -ex
make run-cpp-unit-tests