-
Notifications
You must be signed in to change notification settings - Fork 720
174 lines (159 loc) · 5.37 KB
/
ci_linting.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
name: Linters
on:
push:
branches: [main]
pull_request:
branches: [main]
merge_group:
types: [checks_requested]
branches: [main]
jobs:
cppcheck:
# ubuntu-latest introduced a newer gcc version that cannot compile cppcheck 2.3
# TODO: upgrade to latest cppcheck and revert to ubuntu-latest
# see https://github.com/aws/s2n-tls/issues/3656
runs-on: ubuntu-20.04
env:
CPPCHECK_INSTALL_DIR: test-deps/cppcheck
steps:
- uses: actions/checkout@v4
- name: Setup
run: source ./codebuild/bin/s2n_setup_env.sh
- name: Cache
id: cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ${{ env.CPPCHECK_INSTALL_DIR }}
key: cppcheck-2.3-${{ env.CPPCHECK_INSTALL_DIR }}
- name: Install
if: steps.cache.outputs.cache-hit != 'true'
run: ./codebuild/bin/install_cppcheck.sh "$CPPCHECK_INSTALL_DIR"
- name: Check
run: ./codebuild/bin/run_cppcheck.sh "$CPPCHECK_INSTALL_DIR"
headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup
run: source ./codebuild/bin/s2n_setup_env.sh
- name: Check
run: ./codebuild/bin/header_mistake_scanner.sh
simple-mistakes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup
run: source ./codebuild/bin/s2n_setup_env.sh
- name: Check
run: ./codebuild/bin/grep_simple_mistakes.sh
comments:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup
run: source ./codebuild/bin/s2n_setup_env.sh
- name: Install
run: sudo apt update && sudo apt install -y kwstyle
- name: Check
run: |
./codebuild/bin/run_kwstyle.sh
./codebuild/bin/cpp_style_comment_linter.sh
pepeight:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Run autopep8
id: autopep8
uses: peter-evans/autopep8@v2
with:
args: --diff --exit-code .
- name: Check exit code
if: steps.autopep8.outputs.exit-code != 0
run: |
echo "Run 'autopep8 --in-place .' to fix"
exit 1
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: clang-format check
uses: harrisonkaiser/clang-format-action@verbose
with:
clang-format-version: '15'
include-regex: '^(\.\/)?(api|bin|crypto|stuffer|error|tls|utils|tests\/unit|tests\/testlib|docs\/examples).*\.(c|h)$'
nixflake:
# The nix develop changes contain broken nixpkg dependenecies; the allow/impure flags workaround this.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v29
with:
nix_conf: experimental-features = nix-command flakes
- name: nix flake check
run: NIXPKGS_ALLOW_BROKEN=1 NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix flake check --impure
nixfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v29
with:
nix_conf: experimental-features = nix-command flakes
- name: nix fmt
run: nix fmt $(find . -name \*nix -type f -not -path "./.git/*")
- name: Changed files
id: dirty
run: |
echo "Checking nix files with: nix fmt ..."
git diff --exit-code
continue-on-error: true
- name: Failure case
if: steps.dirty.outcome != 'success'
run: |
echo "Please fix formatting with nix fmt (file)"
exit 1
- name: Success
run: echo "All nix files passed format check"
validate_start_codebuild_script:
name: validate start_codebuild.sh
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: pause
run: "sleep 120"
- name: retrieve statuses
id: get_statuses
uses: octokit/[email protected]
with:
route: GET /repos/{repo}/commits/{ref}/statuses?per_page=100
repo: ${{ github.repository }}
ref: ${{ github.event.merge_group.head_sha || github.event.pull_request.head.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: check start_codebuild.sh against statuses
id: github_builds
run: |
from_github=$(
jq '.[] | .description' <<< '${{ steps.get_statuses.outputs.data }}' \
| grep "for project" \
| sed -r "s/^.*?for project (.*?)\"$/\1/" \
| sort -u
)
if [ -z "$from_github" ]; then
echo "No codebuild job statuses!"
echo "You may need to kick off the codebuild jobs with" \
"./codebuild/bin/start_codebuild.sh and then retry."
exit 1
fi
echo builds from github statuses:
printf "$from_github\n\n"
from_file=$(
source codebuild/bin/start_codebuild.sh > /dev/null \
|| printf "%s\n" "${BUILDS[@]}" | cut -d" " -f1 | sort -u
)
echo builds from start_codebuild.sh:
printf "$from_file\n\n"
echo "diff output:"
diff <(echo "$from_github") <(echo "$from_file")