Skip to content

Commit a080280

Browse files
committed
Optimize use of actions (#101)
Also squashed * Fix actions (#102) * Fix clang-format (#103) * Pass CLANG_RELEASE explicitly (#104) * Fix clang-format (#105) * Fix clang-format (#106) * Fix clang-format (#107) * Fix clang-format (#108) * Fix clang-format (#109) * Fix clang-format (#110) * Fix clang-format (#111) * Fix clang-format (#112) * Fix clang-format (#113) * Fix clang-format (#114) * Fix clang-format (#115) * Fix clang-format (#116) Persistent workflow errors were caused by actions/checkout#766 and badly configured `on:` workflow trigger
1 parent a1c06bd commit a080280

File tree

6 files changed

+76
-40
lines changed

6 files changed

+76
-40
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: build
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
74
push:
85
branches:
9-
- main
10-
- 'feature/*'
11-
- 'bugfix/*'
12-
- 'release/*'
6+
- '*'
7+
paths:
8+
- '.github/**'
9+
- 'cmake/**'
10+
- 'CMakeLists.txt'
11+
- '*.cpp'
12+
- '*.hpp'
13+
- '*.ipp'
1314

1415
jobs:
1516
build-linux:

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ on:
55
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07
66
# This is meant to run at 13:17 on 11th of every month
77
- cron: '17 13 11 * *'
8+
push:
9+
branches:
10+
- main
11+
paths:
12+
- '.github/**'
13+
- 'ci/**'
814
workflow_dispatch:
915

1016
# Based on https://docs.docker.com/build/ci/github-actions/multi-platform/

.github/workflows/clang-format.yml

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,46 @@
11
name: clang-format
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- '.github/**'
9+
- '*.cpp'
10+
- '*.hpp'
11+
- '*.ipp'
12+
- '.clang-format'
13+
pull_request:
14+
branches:
15+
- 'main'
416

517
jobs:
618
format-check:
7-
runs-on: ubuntu-22.04
8-
env:
9-
CLANG_VERSION: 18
19+
runs-on:
20+
group: default
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
release:
25+
- 18
26+
container: libfn/ci-build-clang:${{ matrix.release }}
1027
steps:
1128
- uses: actions/checkout@v4
1229

13-
- name: Install clang-format
14-
env:
15-
DEBIAN_FRONTEND: noninteractive
30+
- name: Prepare
1631
run: |
17-
CODENAME=$( . /etc/os-release && echo $VERSION_CODENAME )
18-
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/llvm.gpg
19-
printf "%s\n%s\n" \
20-
"deb [signed-by=/etc/apt/keyrings/llvm.gpg] https://apt.llvm.org/$CODENAME/ llvm-toolchain-$CODENAME-${CLANG_VERSION} main" \
21-
"deb-src [signed-by=/etc/apt/keyrings/llvm.gpg] https://apt.llvm.org/$CODENAME/ llvm-toolchain-$CODENAME-${CLANG_VERSION} main" \
22-
| sudo tee /etc/apt/sources.list.d/llvm.list
23-
sudo apt-get update
24-
sudo apt-get install -t llvm-toolchain-${CODENAME}-${CLANG_VERSION} -y --no-install-recommends clang-format-${CLANG_VERSION}
25-
sudo apt-get clean
32+
# Required because of https://github.com/actions/checkout/issues/766
33+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
34+
CLANG_RELEASE=${{ matrix.release }}
35+
clang-format --version | grep -F "clang-format version ${CLANG_RELEASE}"
2636
2737
- name: Format source files
28-
run: find include tests -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i
38+
run: |
39+
find include tests -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.ipp' \) -print0 | xargs -0 clang-format -i
2940
3041
- name: Check for differences
3142
id: assert
43+
shell: bash
3244
run: |
3345
set -o pipefail
3446
git diff --exit-code | tee "clang-format.patch"
@@ -51,16 +63,18 @@ jobs:
5163
to the formatting specified in .clang-format. That may be because
5264
you neglected to run 'git clang-format' or 'clang-format' before
5365
committing, or perhaps your version of clang-format is not compatible
54-
with the one on this machine, which is:
66+
with the one used in this workflow, which is:
5567
SUGGESTION: |
56-
57-
To fix it, you can do one of two things:
68+
To fix it, you can do one of three things:
5869
1. Download and apply the patch generated as an artifact of this
5970
job to your repo, commit, and push.
6071
2. Run 'git-clang-format --extensions cpp,hpp,ipp main'
6172
in your repo, commit, and push.
73+
3. Run 'find include tests -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.ipp' \) -print0 | xargs -0 clang-format -i'
74+
in your repo, commit, and push.
6275
run: |
6376
echo "${PREAMBLE}"
64-
clang-format-${CLANG_VERSION} --version
77+
clang-format --version
78+
echo
6579
echo "${SUGGESTION}"
6680
exit 1

.github/workflows/coverage.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
name: coverage
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
74
push:
85
branches:
9-
- main
10-
- 'feature/*'
11-
- 'bugfix/*'
12-
- 'release/*'
13-
workflow_dispatch:
6+
- '*'
7+
paths:
8+
- '.github/**'
9+
- 'cmake/**'
10+
- 'CMakeLists.txt'
11+
- '*.cpp'
12+
- '*.hpp'
13+
- '*.ipp'
14+
- '.codecov.yml'
1415

1516
jobs:
1617
coverage:

.github/workflows/docs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ on:
44
push:
55
branches:
66
- main
7+
paths:
8+
- '.github/**'
9+
- 'cmake/**'
10+
- 'CMakeLists.txt'
11+
- '*.cpp'
12+
- '*.hpp'
13+
- '*.ipp'
14+
- 'docs/**'
715
workflow_dispatch:
816

917
permissions:

.github/workflows/license.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ name: license
33
on:
44
push:
55
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
6+
- '*'
7+
paths:
8+
- '.github/**'
9+
- 'cmake/**'
10+
- 'CMakeLists.txt'
11+
- '*.cpp'
12+
- '*.hpp'
13+
- '*.ipp'
14+
- '.fossa.yml'
15+
- 'LICENSE*'
1016

1117
jobs:
1218
license-check:

0 commit comments

Comments
 (0)