Skip to content

Commit a1f760f

Browse files
authored
Merge pull request #171 from github/jsinglet/slash-fixes
Cross Platform Automation Fixes + Additional Matrix Features + Additional Automation
2 parents 1821034 + 86322b8 commit a1f760f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+524
-139
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 🤖 Run Matrix Check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "**"
7+
workflow_dispatch:
8+
9+
jobs:
10+
dispatch-matrix-check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: Dispatch Matrix Testing Job
15+
uses: peter-evans/repository-dispatch@v2
16+
with:
17+
token: ${{ secrets.RELEASE_ENGINEERING_TOKEN }}
18+
repository: github/codeql-coding-standards-release-engineering
19+
event-type: matrix-test
20+
client-payload: '{"pr": "${{ github.event.number }}"}'
21+
22+
23+
- uses: actions/github-script@v6
24+
with:
25+
script: |
26+
github.rest.issues.createComment({
27+
issue_number: context.issue.number,
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
body: '🤖 Beep Boop! Matrix Testing for this PR has been initiated. Please check back later for results. <br><br> :bulb: If you do not hear back from me please check my status! **I will report even if this PR does not contain files eligible for matrix testing.**'
31+
})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 🏁 Run Release Performance Check
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
branches:
7+
- main
8+
- "rc/**"
9+
- next
10+
11+
jobs:
12+
dispatch-matrix-check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- name: Dispatch Performance Testing Job
17+
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') }}
18+
uses: peter-evans/repository-dispatch@v2
19+
with:
20+
token: ${{ secrets.RELEASE_ENGINEERING_TOKEN }}
21+
repository: github/codeql-coding-standards-release-engineering
22+
event-type: performance-test
23+
client-payload: '{"pr": "${{ github.event.number }}"}'
24+
25+
26+
- uses: actions/github-script@v6
27+
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') }}
28+
with:
29+
script: |
30+
github.rest.issues.createComment({
31+
issue_number: context.issue.number,
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
body: '🏁 Beep Boop! Performance testing for this PR has been initiated. Please check back later for results. Note that the query package generation step must complete before testing will start so it might be a minute. <br><br> :bulb: If you do not hear back from me please check my status! **I will report even if I fail!**'
35+
})
Lines changed: 2 additions & 0 deletions

cpp/autosar/src/rules/A1-1-3/UncompliantOptimizationOptionMustBeDisabledInCompiler.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where
2626
c.getAnArgument() = flag and
2727
flag =
2828
[
29-
"-Ofast", "-ffast-math", "-fgnu-keywords", "-fno-signed-zeroes", "-menable-unsafe-fp-math",
29+
"-Ofast", "-ffast-math", "-fgnu-keywords", "-fno-signed-zeroes", "-fno-signed-zeros", "-menable-unsafe-fp-math",
3030
"-menable-no-nans", "-menable-no-infs", "-menable-unsafe-fp-math", "-ffinite-math-only",
3131
"-ffloat-store"
3232
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Wall

cpp/autosar/test/rules/A0-1-1/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
21
// A POD class
32
struct A {
43
int f;
54
int f2;
65
};
6+
77
// A non-POD class, with a trivial compiler generated constructor
88
struct B {
99
int f;

cpp/autosar/test/rules/A1-1-2.1/CompilerWarningLevelNotInCompliance.expected

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/A1-1-2/CompilerWarningLevelNotInCompliance.ql
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@foo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@foo

cpp/autosar/test/rules/A1-1-2.2/CompilerWarningLevelNotInCompliance.expected

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/A1-1-2/CompilerWarningLevelNotInCompliance.ql
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Wcast-function-type
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Wcast-function-type
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.cpp:0:0:0:0 | test.cpp | No warning-level options were used in the compilation of 'test.cpp'. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/A1-1-2/CompilerWarningLevelNotInCompliance.ql

cpp/autosar/test/rules/A1-1-2.3/options.clang

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-w
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| test.cpp:0:0:0:0 | test.cpp | No warning-level options were used in the compilation of 'test.cpp'. |

cpp/autosar/test/rules/A1-1-2/Wextra.cpp

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Wall
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Wall
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-Ofast'. |
2+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-ffast-math'. |
3+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-ffinite-math-only'. |
4+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-ffloat-store'. |
5+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-fgnu-keywords'. |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-Ofast'. |
2+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-ffast-math'. |
3+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-ffinite-math-only'. |
4+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-ffloat-store'. |
5+
| test.cpp:0:0:0:0 | test.cpp | File compiled with uncompliant optimization flag '-fgnu-keywords'. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Ofast -ffast-math -fgnu-keywords -fno-signed-zeros -ffinite-math-only -ffloat-store
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Ofast -ffast-math -fgnu-keywords -fno-signed-zeros -ffinite-math-only -ffloat-store

docs/user_manual.md

Lines changed: 3 additions & 4 deletions

scripts/PSCodingStandards/CodingStandards.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$Functions = @( Get-ChildItem -Path $PSScriptRoot\*.ps1 -ErrorAction SilentlyContinue )
1+
$Functions = @( Get-ChildItem -Path $PSScriptRoot/*.ps1 -ErrorAction SilentlyContinue )
22

33
foreach($i in $Functions){
44
. $i.FullName
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function Get-ATestDirectory {
2+
param(
3+
[Parameter(Mandatory)]
4+
[object]
5+
$RuleObject,
6+
[Parameter(Mandatory)]
7+
[ValidateSet('c', 'cpp')]
8+
[string]
9+
$Language
10+
)
11+
12+
$ruleDir = Get-TestDirectory -RuleObject $RuleObject -Language $Language
13+
14+
# return value MUST include the explicit test directory
15+
$dirs = @($ruleDir)
16+
17+
$dirs += (Get-Item "$($ruleDir).*" | ForEach-Object { $_.FullName })
18+
19+
$dirs
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function Get-LanguageForPath {
2+
param([Parameter(Mandatory)]
3+
[string]
4+
$Path)
5+
6+
$parts = $Path -split '/'
7+
8+
$Language = $parts[0]
9+
10+
foreach($L in $AVAILABLE_LANGUAGES){
11+
if($Language -eq $L){
12+
return $L
13+
}
14+
}
15+
16+
throw "Unsupported Language: $Language"
17+
}

scripts/PSCodingStandards/Get-Packages.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ function Get-Packages {
44
[string]
55
$Language)
66

7-
return Get-ChildItem (Join-Path (Get-RepositoryRoot) "\rule_packages\$Language\*.json")
7+
return Get-ChildItem (Join-Path (Get-RepositoryRoot) "/rule_packages/$Language/*.json")
88
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# takes paths like this:
2+
# c/cert/src/rules/DCL39-C/InformationLeakageAcrossTrustBoundariesC.ql
3+
# c/common/test/rules/informationleakageacrossboundaries/InformationLeakageAcrossBoundaries.expected
4+
# c/common/test/rules/informationleakageacrossboundaries/InformationLeakageAcrossBoundaries.ql
5+
# c/common/test/rules/informationleakageacrossboundaries/arrays.c
6+
# c/common/test/rules/informationleakageacrossboundaries/interprocedural.c
7+
# c/common/test/rules/informationleakageacrossboundaries/multilayer.c
8+
# c/common/test/rules/informationleakageacrossboundaries/test.c
9+
# c/misra/src/rules/RULE-18-8/VariableLengthArrayTypesUsed.ql
10+
# c/misra/src/rules/RULE-8-12/ValueImplicitEnumerationConstantNotUnique.ql
11+
# c/misra/test/rules/RULE-18-8/VariableLengthArrayTypesUsed.expected
12+
# c/misra/test/rules/RULE-18-8/test.c
13+
# c/misra/test/rules/RULE-8-12/ValueImplicitEnumerationConstantNotUnique.expected
14+
# c/misra/test/rules/RULE-8-12/test.c
15+
# cpp/cert/src/rules/DCL55-CPP/InformationLeakageAcrossTrustBoundaries.ql
16+
# cpp/common/test/rules/informationleakageacrossboundaries/InformationLeakageAcrossBoundaries.expected
17+
# cpp/common/test/rules/informationleakageacrossboundaries/InformationLeakageAcrossBoundaries.ql
18+
# cpp/common/test/rules/informationleakageacrossboundaries/InformationLeakageAcrossTrustBoundaries.expected
19+
# cpp/common/test/rules/informationleakageacrossboundaries/arrays.cpp
20+
# cpp/common/test/rules/informationleakageacrossboundaries/inheritance.cpp
21+
# cpp/common/test/rules/informationleakageacrossboundaries/interprocedural.cpp
22+
# cpp/common/test/rules/informationleakageacrossboundaries/multilayer.cpp
23+
# cpp/common/test/rules/informationleakageacrossboundaries/test.cpp
24+
25+
# And produces one or more rules for it. It does this by loading every rule
26+
# and computing the test directory for it. This test directory is then
27+
# used to see if a) it is a substring of the supplied path or if b) it
28+
# is a substring of the path once the substitution `/src/` -> `/test/` is
29+
# applied
30+
31+
function Get-RuleForPath {
32+
param([Parameter(Mandatory)]
33+
[string]
34+
$Path,
35+
[ValidateSet('c', 'cpp')]
36+
[string]
37+
$Language
38+
)
39+
40+
# load all the queries for all languages
41+
$allQueries = @()
42+
$queriesToCheck = @()
43+
44+
# load all the queries
45+
foreach ($s in $AVAILABLE_SUITES) {
46+
$allQueries += Get-RulesInSuite -Suite $s -Language $Language
47+
}
48+
49+
$modifiedPathWithReplacement = Join-Path (Resolve-Path . -Relative) $Path
50+
# replace "src" with "test" to make it match up
51+
$sep = [IO.Path]::DirectorySeparatorChar
52+
$modifiedPathWithReplacement = $modifiedPathWithReplacement.Replace( ($sep + "src" + $sep + "rules"), ($sep + "test" + $sep + "rules"))
53+
$modifiedPath = Join-Path (Resolve-Path . -Relative) $Path
54+
55+
56+
$matchingRules = @()
57+
58+
# for each query, create the test directory
59+
foreach($q in $allQueries){
60+
61+
# get test directory
62+
$testDirs = (Get-ATestDirectory -RuleObject $q -Language $Language)
63+
foreach($testDirectory in $testDirs){
64+
# resolve path to be compatible
65+
$testPath = Join-Path (Resolve-Path . -Relative) $testDirectory
66+
67+
# see if the TEST directory is a substring of the full path
68+
if($modifiedPath.StartsWith($testPath)){
69+
$matchingRules += $q
70+
continue
71+
}
72+
73+
if($modifiedPathWithReplacement.StartsWith($testPath)){
74+
$matchingRules += $q
75+
continue
76+
}
77+
}
78+
}
79+
80+
if($matchingRules.Count -gt 0){
81+
return $matchingRules
82+
}
83+
84+
throw "Path does not appear to be part of a rule."
85+
}

scripts/PSCodingStandards/Get-RulesInPackageAndSuite.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ function Get-RulesInPackageAndSuite {
66
$Package,
77
[Parameter(Mandatory)]
88
[string]
9-
$Suite
10-
)
9+
$Suite,
10+
[Parameter(Mandatory)]
11+
[ValidateSet('c', 'cpp')]
12+
[string]
13+
$Language
14+
)
1115

1216
$rulesInPackage = @()
1317

@@ -30,6 +34,7 @@ function Get-RulesInPackageAndSuite {
3034
$queries | Add-Member -NotePropertyName __memberof_suite -NotePropertyValue $Suite
3135
$queries | Add-Member -NotePropertyName __memberof_package -NotePropertyValue $Package.BaseName
3236
$queries | Add-Member -NotePropertyName __memberof_rule -NotePropertyValue $n.Name
37+
$queries | Add-Member -NotePropertyName __memberof_language -NotePropertyValue $Language
3338

3439
$rulesInPackage += $queries
3540
}

scripts/PSCodingStandards/Get-RulesInSuite.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Get-RulesInSuite {
1313

1414
foreach ($p in Get-Packages -Language $Language) {
1515
Write-Host "Reading package: [$Language/$Suite/$($p.BaseName)]"
16-
$tmpQueries += Get-RulesInPackageAndSuite -Package $p -Suite $Suite
16+
$tmpQueries += Get-RulesInPackageAndSuite -Package $p -Suite $Suite -Language $Language
1717
}
1818

1919
return $tmpQueries

scripts/PSCodingStandards/README.md

Lines changed: 2 additions & 2 deletions

scripts/bump_version.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ fi
99

1010
echo "Setting Local Branch Version to $1."
1111

12+
# update the qlpacks
1213
find . -name 'qlpack.yml' | grep -v './codeql_modules' | grep -v './scripts' | xargs sed -i "s/^version.*$/version: ${1}/"
1314

15+
# update the documentation.
16+
17+
find docs -name 'user_manual.md' | xargs sed -i "s/code-scanning-cpp-query-pack-anon-.*\.zip\`/code-scanning-cpp-query-pack-anon-${1}.zip\`/"
18+
find docs -name 'user_manual.md' | xargs sed -i "s/supported_rules_list_.*\.csv\`/supported_rules_list_${1}.csv\`/"
19+
find docs -name 'user_manual.md' | xargs sed -i "s/supported_rules_list_.*\.md\`/upported_rules_list_${1}.md\`/"
20+
find docs -name 'user_manual.md' | xargs sed -i "s/user_manual_.*\.md\`/user_manual_${1}.md\`/"
21+
1422
echo "Done."

scripts/matrix_testing/CompileFixTool.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ param(
1616

1717
# The compiler to use. Valid values are 'clang' and 'arm-clang'.
1818
[Parameter(Mandatory)]
19-
[ValidateSet('clang', 'armclang', 'tiarmclang')]
19+
[ValidateSet('clang', 'armclang', 'tiarmclang', 'gcc')]
2020
[string]
2121
$Configuration
2222
)
2323

24-
Import-Module -Name "$PSScriptRoot\..\PSCodingStandards\CodingStandards"
24+
Import-Module -Name "$PSScriptRoot/../PSCodingStandards/CodingStandards"
2525

26-
. "$PSScriptRoot\NewDatabaseForRule.ps1"
27-
. "$PSScriptRoot\Config.ps1"
28-
. "$PSScriptRoot\Get-CompilerExecutable.ps1"
26+
. "$PSScriptRoot/NewDatabaseForRule.ps1"
27+
. "$PSScriptRoot/Config.ps1"
28+
. "$PSScriptRoot/Get-CompilerExecutable.ps1"
2929

3030
#
3131
# Verify All the Required CLI Tools are Installed

0 commit comments

Comments
 (0)