Skip to content

Improved detection of broken mods #1501

Improved detection of broken mods

Improved detection of broken mods #1501

Workflow file for this run

name: Lint
on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
jobs:
check-remove-before-flight:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- 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@v4
- name: Download cpplint
shell: pwsh
run: |
Invoke-WebRequest https://raw.githubusercontent.com/mockingbirdnest/styleguide/mockingbirdnest-2023-10-02/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) {
$errors += $output
foreach ($e in (@() + $output)) {
$e -match '^(.*)\((\d+)\):.*\[([^\]]+)\]\s*(.*)\s*\[\d+\]'
$file = $Matches[1]
$line = $Matches[2]
$title = $Matches[3]
$message = $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@v4
- 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