forked from mockingbirdnest/Principia
-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (126 loc) · 4.85 KB
/
lint.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
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
name: Lint
on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
jobs:
check-remove-before-flight:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Check source tree
shell: pwsh
run: |
$tag = [System.Text.ASCIIEncoding]::new().GetString(
[System.Text.Encoding]::GetEncoding(20866).GetBytes(
"реможе бефоре флигхт").ForEach({$_ -band 0x7F}))
$results = (ls -Recurse | sls -CaseSensitive $tag)
foreach ($result in $results) {
# https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
echo "::error file=$($result.Path),line=$($result.LineNumber)::$tag"
}
$results | Should -Be @()
check-cpp:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Download cpplint
shell: pwsh
run: |
Invoke-WebRequest https://raw.githubusercontent.com/mockingbirdnest/styleguide/casanova-2023-04-25/cpplint/cpplint.py -OutFile cpplint.py
- name: Run cpplint
shell: pwsh
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
$filenames = @()
if ($env:GITHUB_EVENT_NAME -eq "pull_request") {
$event = (Get-Content -Raw $env:GITHUB_EVENT_PATH | ConvertFrom-Json)
$owner_repo = $event.repository.full_name
$pr_number = $event.number
# Get the list of files changed by the PR.
# https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests-files
$files = (gh api -H "Accept: application/vnd.github+json" `
-H "X-GitHub-Api-Version: 2022-11-28" `
/repos/$owner_repo/pulls/$pr_number/files |
ConvertFrom-Json)
foreach ($file in $files) {
if ($file.filename.EndsWith(".cpp") -or
$file.filename.EndsWith(".hpp")) {
$filenames += $file.filename
}
}
}
$filters = @(
"-legal/copyright",
"-build/c++11",
"-runtime/references",
"-runtime/arrays",
"-build/include_order",
"-readability/braces",
"-build/namespaces")
$errors = @()
$ErrorActionPreference = "Continue"
if ($env:GITHUB_EVENT_NAME -eq "pull_request") {
$files = $filenames
} else {
$files = ls "*\*.[ch]pp"
}
foreach ($file in $files) {
$output = $(
python .\cpplint.py `
--extensions=hpp,cpp `
--output=vs7 `
--filter=$([string]::join(",", $filters)) `
$file 2>&1 `
).Exception.Message
if ($LastExitCode -ne 0) {
# Drop the the line that says “Done processing” and the one that
# gives the total number of errors.
$file_errors = $output[0..($output.Length-3)]
$errors += $file_errors
foreach ($e in $file_errors) {
$e -match '^(.*)\((\d+)\):\s*(.*)\s*\[([^\]]+)\]\s*\[\d+\]$'
$file = $Matches[1]
$line = $Matches[2]
$message = $Matches[3]
$title = $Matches[4]
# See https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message.
echo "::warning file=$file,line=$line,title=$title::$message"
}
$output | write-error
} else {
echo $output
}
}
$errors | write-error
exit $errors.Length
check-iwyu:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Restore Release
uses: mockingbirdnest/actions/windows/restore@main
with:
configuration: Release
solution_directory: .
- name: Build sourcerer
shell: pwsh
env:
PRINCIPIA_MSBUILD_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe
run: |
&"${{ env.PRINCIPIA_MSBUILD_PATH }}" `
.\sourcerer\sourcerer.csproj `
/t:"Clean;Build" `
/property:Configuration=Release
- name: Include what you using
shell: pwsh
run: |
&.\include_what_you_using_all_the_things.ps1
$files = (git diff --name-only)
foreach ($file in $files) {
$diff = (git diff $file)
echo "::warning file=$file,line=1,title=Include what you using::include_what_you_using_all_the_things.ps1 modifies this file as follows:%0A$([string]::join('%0A', (git diff $file)))"
}
exit $files.Length