Skip to content

Commit

Permalink
Optimize use of actions (#101)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Bronek committed Oct 20, 2024
1 parent a1c06bd commit a080280
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 40 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: build

on:
pull_request:
branches:
- main
push:
branches:
- main
- 'feature/*'
- 'bugfix/*'
- 'release/*'
- '*'
paths:
- '.github/**'
- 'cmake/**'
- 'CMakeLists.txt'
- '*.cpp'
- '*.hpp'
- '*.ipp'

jobs:
build-linux:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07
# This is meant to run at 13:17 on 11th of every month
- cron: '17 13 11 * *'
push:
branches:
- main
paths:
- '.github/**'
- 'ci/**'
workflow_dispatch:

# Based on https://docs.docker.com/build/ci/github-actions/multi-platform/
Expand Down
56 changes: 35 additions & 21 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
name: clang-format

on: [push, pull_request]
on:
push:
branches:
- 'main'
paths:
- '.github/**'
- '*.cpp'
- '*.hpp'
- '*.ipp'
- '.clang-format'
pull_request:
branches:
- 'main'

jobs:
format-check:
runs-on: ubuntu-22.04
env:
CLANG_VERSION: 18
runs-on:
group: default
strategy:
fail-fast: false
matrix:
release:
- 18
container: libfn/ci-build-clang:${{ matrix.release }}
steps:
- uses: actions/checkout@v4

- name: Install clang-format
env:
DEBIAN_FRONTEND: noninteractive
- name: Prepare
run: |
CODENAME=$( . /etc/os-release && echo $VERSION_CODENAME )
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/llvm.gpg
printf "%s\n%s\n" \
"deb [signed-by=/etc/apt/keyrings/llvm.gpg] https://apt.llvm.org/$CODENAME/ llvm-toolchain-$CODENAME-${CLANG_VERSION} main" \
"deb-src [signed-by=/etc/apt/keyrings/llvm.gpg] https://apt.llvm.org/$CODENAME/ llvm-toolchain-$CODENAME-${CLANG_VERSION} main" \
| sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
sudo apt-get install -t llvm-toolchain-${CODENAME}-${CLANG_VERSION} -y --no-install-recommends clang-format-${CLANG_VERSION}
sudo apt-get clean
# Required because of https://github.com/actions/checkout/issues/766
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
CLANG_RELEASE=${{ matrix.release }}
clang-format --version | grep -F "clang-format version ${CLANG_RELEASE}"
- name: Format source files
run: find include tests -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i
run: |
find include tests -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.ipp' \) -print0 | xargs -0 clang-format -i
- name: Check for differences
id: assert
shell: bash
run: |
set -o pipefail
git diff --exit-code | tee "clang-format.patch"
Expand All @@ -51,16 +63,18 @@ jobs:
to the formatting specified in .clang-format. That may be because
you neglected to run 'git clang-format' or 'clang-format' before
committing, or perhaps your version of clang-format is not compatible
with the one on this machine, which is:
with the one used in this workflow, which is:
SUGGESTION: |
To fix it, you can do one of two things:
To fix it, you can do one of three things:
1. Download and apply the patch generated as an artifact of this
job to your repo, commit, and push.
2. Run 'git-clang-format --extensions cpp,hpp,ipp main'
in your repo, commit, and push.
3. Run 'find include tests -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.ipp' \) -print0 | xargs -0 clang-format -i'
in your repo, commit, and push.
run: |
echo "${PREAMBLE}"
clang-format-${CLANG_VERSION} --version
clang-format --version
echo
echo "${SUGGESTION}"
exit 1
17 changes: 9 additions & 8 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: coverage

on:
pull_request:
branches:
- main
push:
branches:
- main
- 'feature/*'
- 'bugfix/*'
- 'release/*'
workflow_dispatch:
- '*'
paths:
- '.github/**'
- 'cmake/**'
- 'CMakeLists.txt'
- '*.cpp'
- '*.hpp'
- '*.ipp'
- '.codecov.yml'

jobs:
coverage:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ on:
push:
branches:
- main
paths:
- '.github/**'
- 'cmake/**'
- 'CMakeLists.txt'
- '*.cpp'
- '*.hpp'
- '*.ipp'
- 'docs/**'
workflow_dispatch:

permissions:
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ name: license
on:
push:
branches:
- main
pull_request:
branches:
- main
- '*'
paths:
- '.github/**'
- 'cmake/**'
- 'CMakeLists.txt'
- '*.cpp'
- '*.hpp'
- '*.ipp'
- '.fossa.yml'
- 'LICENSE*'

jobs:
license-check:
Expand Down

0 comments on commit a080280

Please sign in to comment.