-
Notifications
You must be signed in to change notification settings - Fork 1
123 lines (111 loc) · 3.91 KB
/
clang_format.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
121
122
123
name: Lint
on:
pull_request_target:
env:
TZ: Europe/Berlin
defaults:
run:
shell: bash -exo pipefail {0}
jobs:
# Cancel other workflows that are dependent on this workflow by adding jobs that have the same concurrency group.
cancel_linux:
name: Cancel Linux
concurrency:
group: linux-${{ github.event.pull_request.number }}
cancel-in-progress: true
runs-on: ubuntu-22.04
steps:
- name: "Cancel Linux"
run: echo "Cancelling Linux"
cancel_macos:
name: Cancel macOS
concurrency:
group: macos-${{ github.event.pull_request.number }}
cancel-in-progress: true
runs-on: ubuntu-22.04
steps:
- name: "Cancel macOS"
run: echo "Cancelling macOS"
cancel_misc:
name: Cancel Misc
concurrency:
group: misc-${{ github.event.pull_request.number }}
cancel-in-progress: true
runs-on: ubuntu-22.04
steps:
- name: "Cancel Misc"
run: echo "Cancelling Misc"
cancel_coverage:
name: Cancel Coverage
concurrency:
group: coverage-${{ github.event.pull_request.number }}
cancel-in-progress: true
runs-on: ubuntu-22.04
steps:
- name: "Cancel Coverage"
run: echo "Cancelling Coverage"
lint:
name: clang-format
concurrency:
group: clang-format-${{ github.event.pull_request.number }}
cancel-in-progress: true
needs: [cancel_linux, cancel_macos, cancel_misc, cancel_coverage]
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Add label
env:
GITHUB_TOKEN: ${{ secrets.SEQAN_ACTIONS_PAT }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: gh pr edit $PR_URL --add-label "clang-format"
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: "refs/pull/${{ github.event.number }}/merge"
submodules: false
token: ${{ secrets.SEQAN_ACTIONS_PAT }}
- name: Get changed files
id: changed_files
run: |
LIST=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} | \
{ grep -v -E "(submodules/)" || test $? = 1; } | \
{ grep -E "\.[hc]pp$" || test $? = 1; } | xargs)
echo "list=$LIST" >> $GITHUB_OUTPUT
- name: Switch to fork
run: |
git remote add fork ${{ github.event.pull_request.head.repo.html_url }}
git fetch fork ${{ github.event.pull_request.head.ref }}
git checkout --force --track fork/${{ github.event.pull_request.head.ref }}
- name: Run clang-format
if: ${{ steps.changed_files.outputs.list }}
uses: DoozyX/[email protected]
with:
source: ${{ steps.changed_files.outputs.list }}
clangFormatVersion: 15
inplace: True
- name: Import GPG key
if: ${{ steps.changed_files.outputs.list }}
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.SEQAN_ACTIONS_GPG_KEY }}
passphrase: ${{ secrets.SEQAN_ACTIONS_GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit changes
if: ${{ steps.changed_files.outputs.list }}
run: |
git config user.name "seqan-actions[bot]"
git config user.email "[email protected]"
git add .
git commit -m '[MISC] clang-format' || true
git push fork ${{ github.event.pull_request.head.ref }}
# Wait for 5 seconds such that workflows triggered by adding the label run on the newest commit.
- name: Defer workflow
if: ${{ steps.changed_files.outputs.list }}
run: sleep 5
- name: Remove label
env:
GITHUB_TOKEN: ${{ secrets.SEQAN_ACTIONS_PAT }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: gh pr edit $PR_URL --remove-label "clang-format"