Skip to content

Commit 2fc8f1d

Browse files
authored
Merge branch 'main' into lcartey/a0-1-1-ignore-incomplete-or-compiler-generated-vars
2 parents 53c248d + d74222a commit 2fc8f1d

25 files changed

+246
-109
lines changed

.github/workflows/prepare-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
app-id: ${{ vars.AUTOMATION_APP_ID }}
149149
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
150150
owner: ${{ github.repository_owner }}
151-
repository: "codeql-coding-standards"
151+
repositories: "codeql-coding-standards"
152152

153153
- name: Create release PR
154154
env:

.github/workflows/tooling-unit-tests.yml

+19
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,22 @@ jobs:
9696
- name: Run PyTest
9797
run: |
9898
pytest scripts/guideline_recategorization/recategorize_test.py
99+
100+
release-tests:
101+
name: Run release tests
102+
runs-on: ubuntu-22.04
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v2
106+
107+
- name: Install Python
108+
uses: actions/setup-python@v4
109+
with:
110+
python-version: "3.9"
111+
112+
- name: Install Python dependencies
113+
run: pip install -r scripts/release/requirements.txt
114+
115+
- name: Run PyTest
116+
run: |
117+
pytest scripts/release/update_release_assets_test.py
+26-32
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
name: "Update Release Status"
22
on:
3-
check_run:
4-
types:
5-
- completed
6-
- rerequested
7-
branches:
8-
- "rc/**"
9-
103
workflow_dispatch:
114
inputs:
125
head-sha:
@@ -20,40 +13,36 @@ permissions:
2013
checks: write
2114
contents: write
2215

16+
env:
17+
HEAD_SHA: ${{ inputs.head-sha }}
18+
2319
jobs:
2420
validate-check-runs:
2521
runs-on: ubuntu-22.04
2622
outputs:
2723
status: ${{ steps.set-output.outputs.status }}
28-
check-run-head-sha: ${{ steps.set-output.outputs.check-run-head-sha }}
24+
conclusion: ${{ steps.set-output.outputs.conclusion }}
2925
steps:
30-
- name: Determine check run head SHA
31-
env:
32-
HEAD_SHA_FROM_EVENT: ${{ github.event.check_run.head_sha }}
33-
HEAD_SHA_FROM_INPUTS: ${{ inputs.head-sha }}
34-
run: |
35-
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
36-
echo "CHECK_RUN_HEAD_SHA=$HEAD_SHA_FROM_INPUTS" >> "$GITHUB_ENV"
37-
else
38-
echo "CHECK_RUN_HEAD_SHA=$HEAD_SHA_FROM_EVENT" >> "$GITHUB_ENV"
39-
fi
40-
4126
- name: Checkout
4227
uses: actions/checkout@v4
4328
with:
44-
ref: ${{ env.CHECK_RUN_HEAD_SHA }}
29+
ref: ${{ inputs.head-sha }}
4530

4631
- name: Get release status check run
4732
id: get-check-run
48-
if: (github.event_name == 'check_run' && github.event.check_run.conclusion == 'success' && github.event.check_run.name != github.workflow) || github.event_name == 'workflow_dispatch'
4933
env:
5034
GITHUB_TOKEN: ${{ github.token }}
5135
run: |
5236
check_run_info=$(gh api \
5337
--header "Accept: application/vnd.github+json" \
5438
--header "X-GitHub-Api-Version: 2022-11-28" \
5539
--jq '.check_runs[] | select(.name == "release-status") | {id: .id, status: .status, conclusion: .conclusion}' \
56-
/repos/$GITHUB_REPOSITORY/commits/$CHECK_RUN_HEAD_SHA/check-runs)
40+
/repos/$GITHUB_REPOSITORY/commits/$HEAD_SHA/check-runs)
41+
42+
if [[ -z "$check_run_info" ]]; then
43+
echo "No release status check run found"
44+
exit 1
45+
fi
5746
5847
check_run_id=$(echo "$check_run_info" | jq -r '.id')
5948
check_run_status=$(echo "$check_run_info" | jq -r '.status')
@@ -64,19 +53,22 @@ jobs:
6453
echo "CHECK_RUN_CONCLUSION=$check_run_conclusion" >> "$GITHUB_ENV"
6554
6655
- name: Reset release status
67-
if: env.CHECK_RUN_STATUS == 'completed' && ((github.event_name == 'check_run' && github.event.action == 'rerequested') || github.event_name == 'workflow_dispatch')
56+
if: env.CHECK_RUN_STATUS == 'completed'
6857
env:
6958
GITHUB_TOKEN: ${{ github.token }}
7059
run: |
71-
CHECK_RUN_ID=$(gh api \
60+
check_run_id=$(gh api \
7261
--header "Accept: application/vnd.github+json" \
7362
--header "X-GitHub-Api-Version: 2022-11-28" \
7463
--field name="release-status" \
75-
--field head_sha="$CHECK_RUN_HEAD_SHA" \
64+
--field head_sha="$HEAD_SHA" \
7665
--jq ".id" \
7766
/repos/$GITHUB_REPOSITORY/check-runs)
7867
79-
echo "Created release status check run with id $CHECK_RUN_ID"
68+
echo "Created release status check run with id $check_run_id"
69+
# Reset the status to in progress.
70+
echo "CHECK_RUN_STATUS=in_progress" >> "$GITHUB_ENV"
71+
echo "CHECK_RUN_ID=$check_run_id" >> "$GITHUB_ENV"
8072
8173
- name: Check all runs completed
8274
if: env.CHECK_RUN_STATUS != 'completed'
@@ -87,10 +79,12 @@ jobs:
8779
--header "Accept: application/vnd.github+json" \
8880
--header "X-GitHub-Api-Version: 2022-11-28" \
8981
--jq '.check_runs | map(select(.name != "release-status"))' \
90-
/repos/$GITHUB_REPOSITORY/commits/$CHECK_RUN_HEAD_SHA/check-runs)
82+
/repos/$GITHUB_REPOSITORY/commits/$HEAD_SHA/check-runs)
9183
9284
status_stats=$(echo "$check_runs" | jq -r '. | {failed: (map(select(.conclusion == "failure")) | length), pending: (map(select(.status != "completed")) | length) }')
9385
86+
echo "status_stats=$status_stats"
87+
9488
failed=$(echo "$status_stats" | jq -r '.failed')
9589
pending=$(echo "$status_stats" | jq -r '.pending')
9690
@@ -101,7 +95,6 @@ jobs:
10195
if: env.CHECK_RUNS_PENDING == '0' && env.CHECK_RUN_STATUS != 'completed'
10296
env:
10397
GITHUB_TOKEN: ${{ github.token }}
104-
CHECK_RUNS_FAILED: ${{ env.check-runs-failed }}
10598
run: |
10699
if [[ "$CHECK_RUNS_FAILED" == "0" ]]; then
107100
echo "All check runs succeeded"
@@ -123,22 +116,23 @@ jobs:
123116
--input - \
124117
/repos/$GITHUB_REPOSITORY/check-runs/$CHECK_RUN_ID
125118
119+
echo "RELEASE_STATUS_CONCLUSION=$conclusion" >> "$GITHUB_ENV"
120+
126121
- name: Set output
127122
id: set-output
128123
run: |
124+
echo "conclusion=$RELEASE_STATUS_CONCLUSION" >> "$GITHUB_OUTPUT"
129125
if [[ "$CHECK_RUNS_PENDING" == "0" ]]; then
130126
echo "status=completed" >> "$GITHUB_OUTPUT"
131127
else
132128
echo "status=in_progress" >> "$GITHUB_OUTPUT"
133129
fi
134130
135-
echo "check-run-head-sha=$CHECK_RUN_HEAD_SHA" >> "$GITHUB_OUTPUT"
136-
137131
update-release:
138132
needs: validate-check-runs
139-
if: needs.validate-check-runs.outputs.status == 'completed'
133+
if: needs.validate-check-runs.outputs.status == 'completed' && needs.validate-check-runs.outputs.conclusion == 'success'
140134
uses: ./.github/workflows/update-release.yml
141135
with:
142-
head-sha: ${{ needs.validate-check-runs.outputs.check-run-head-sha }}
136+
head-sha: ${{ inputs.head-sha }}
143137
secrets:
144138
AUTOMATION_PRIVATE_KEY: ${{ secrets.AUTOMATION_PRIVATE_KEY }}

.github/workflows/update-release.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Checkout
3131
uses: actions/checkout@v4
3232
with:
33-
ref: ${{ inputs.head-sha }}
33+
fetch-depth: 0 # We need the full history to compute the changelog
3434

3535
- name: Install Python
3636
uses: actions/setup-python@v4
@@ -47,20 +47,19 @@ jobs:
4747
app-id: ${{ vars.AUTOMATION_APP_ID }}
4848
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
4949
owner: ${{ github.repository_owner }}
50-
repository: "codeql-coding-standards-release-engineering"
50+
repositories: "codeql-coding-standards-release-engineering"
5151

5252
- name: Update release assets
5353
env:
5454
GITHUB_TOKEN: ${{ github.token }}
5555
RELEASE_ENGINEERING_TOKEN: ${{ steps.generate-token.outputs.token }}
5656
run: |
57-
python scripts/release/update-release-assets.py \
57+
python scripts/release/update_release_assets.py \
5858
--head-sha $HEAD_SHA \
5959
--layout scripts/release/release-layout.yml \
6060
--repo "$GITHUB_REPOSITORY" \
6161
--github-token "$GITHUB_REPOSITORY:$GITHUB_TOKEN" "github/codeql-coding-standards-release-engineering:$RELEASE_ENGINEERING_TOKEN" \
62-
--skip-checkrun "release-status" \
63-
--skip-checks
62+
--skip-checkrun "release-status"
6463
6564
- name: Update release notes
6665
env:

.github/workflows/validate-release.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
app-id: ${{ vars.AUTOMATION_APP_ID }}
4646
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
4747
owner: ${{ github.repository_owner }}
48-
repository: "codeql-coding-standards-release-engineering"
48+
repositories: "codeql-coding-standards-release-engineering"
4949
- name: Invoke performance test
5050
env:
5151
CHECK_RUN_ID: ${{ needs.pre-validate-performance.outputs.check-run-id }}
@@ -58,8 +58,7 @@ jobs:
5858
| \
5959
gh workflow run release-performance-testing.yml \
6060
--json \
61-
-R github/codeql-coding-standards-release-engineering \
62-
--ref rvermeulen/release-process
61+
-R github/codeql-coding-standards-release-engineering
6362
6463
on-failure-validate-performance-dispatch:
6564
needs: [pre-validate-performance, validate-performance]
@@ -114,7 +113,7 @@ jobs:
114113
app-id: ${{ vars.AUTOMATION_APP_ID }}
115114
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
116115
owner: ${{ github.repository_owner }}
117-
repository: "codeql-coding-standards-release-engineering"
116+
repositories: "codeql-coding-standards-release-engineering"
118117
- name: Invoke compiler compatibility test
119118
env:
120119
CHECK_RUN_ID: ${{ needs.pre-validate-compiler-compatibility.outputs.check-run-id }}
@@ -127,8 +126,7 @@ jobs:
127126
| \
128127
gh workflow run release-compiler-validation.yml \
129128
--json \
130-
-R github/codeql-coding-standards-release-engineering \
131-
--ref rvermeulen/release-process
129+
-R github/codeql-coding-standards-release-engineering
132130
133131
on-failure-validate-compiler-compatibility-dispatch:
134132
needs:

c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import cpp
1515
import codingstandards.c.misra
1616
import codingstandards.c.misra.EssentialTypes
17+
import codingstandards.cpp.Bitwise
1718

1819
/**
1920
* Holds if the operator `operator` has an operand `child` that is of an inappropriate essential type
@@ -177,7 +178,7 @@ predicate isInappropriateEssentialType(
177178
child =
178179
[
179180
operator.(BinaryBitwiseOperation).getAnOperand(),
180-
operator.(AssignBitwiseOperation).getAnOperand()
181+
operator.(Bitwise::AssignBitwiseOperation).getAnOperand()
181182
] and
182183
not operator instanceof LShiftExpr and
183184
not operator instanceof RShiftExpr and

c/misra/src/rules/RULE-8-2/FunctionTypesNotInPrototypeForm.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ where
4545
msg = "Function " + f + " declares parameter that is unnamed."
4646
or
4747
hasZeroParamDecl(f) and
48-
msg = "Function " + f + " does not specifiy void for no parameters present."
48+
msg = "Function " + f + " does not specify void for no parameters present."
4949
or
5050
//parameters declared in declaration list (not in function signature)
5151
//have placeholder file location associated only

c/misra/test/rules/RULE-10-1/test.c

+2
Original file line numberDiff line numberDiff line change
@@ -492,4 +492,6 @@ void pointerType() {
492492
b || b; // COMPLIANT
493493
p || b; // NON_COMPLIANT
494494
b || p; // NON_COMPLIANT
495+
p += 1; // COMPLIANT
496+
p -= 1; // COMPLIANT
495497
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
| test.c:3:6:3:7 | f1 | Function f1 declares parameter that is unnamed. |
2-
| test.c:4:6:4:7 | f2 | Function f2 does not specifiy void for no parameters present. |
3-
| test.c:5:6:5:7 | f3 | Function f3 does not specifiy void for no parameters present. |
2+
| test.c:4:6:4:7 | f2 | Function f2 does not specify void for no parameters present. |
3+
| test.c:5:6:5:7 | f3 | Function f3 does not specify void for no parameters present. |
44
| test.c:7:5:7:6 | f5 | Function f5 declares parameter in unsupported declaration list. |
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
| test.c:3:6:3:7 | f1 | Function f1 declares parameter that is unnamed. |
2-
| test.c:4:6:4:7 | f2 | Function f2 does not specifiy void for no parameters present. |
2+
| test.c:4:6:4:7 | f2 | Function f2 does not specify void for no parameters present. |
33
| test.c:7:5:7:6 | f5 | Function f5 declares parameter in unsupported declaration list. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `M5-0-20`, `M5-0-21`, `RULE-10-1` - exclude pointer assignment operators as bitwise operators.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `M5-0-20` - `BitwiseOperatorOperandsHaveDifferentUnderlyingType.ql`:
2+
- Use the Misra definition of underlying type.

cpp/autosar/src/rules/M5-0-20/BitwiseOperatorOperandsHaveDifferentUnderlyingType.ql

+16-5
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,30 @@
1616

1717
import cpp
1818
import codingstandards.cpp.autosar
19+
import codingstandards.cpp.Bitwise
20+
import codingstandards.cpp.Conversion
1921

2022
predicate isBinaryBitwiseOperation(Operation o, VariableAccess l, VariableAccess r) {
2123
exists(BinaryBitwiseOperation bbo | bbo = o |
2224
l = bbo.getLeftOperand() and r = bbo.getRightOperand()
2325
)
2426
or
25-
exists(AssignBitwiseOperation abo | abo = o | l = abo.getLValue() and r = abo.getRValue())
27+
exists(Bitwise::AssignBitwiseOperation abo | abo = o |
28+
l = abo.getLValue() and
29+
r = abo.getRValue()
30+
)
2631
}
2732

28-
from Operation o, Variable left, Variable right
33+
from
34+
Operation o, VariableAccess left, VariableAccess right, Type leftUnderlyingType,
35+
Type rightUnderlyingType
2936
where
3037
not isExcluded(o, ExpressionsPackage::bitwiseOperatorOperandsHaveDifferentUnderlyingTypeQuery()) and
3138
not o.isFromUninstantiatedTemplate(_) and
32-
isBinaryBitwiseOperation(o, left.getAnAccess(), right.getAnAccess()) and
33-
left.getUnderlyingType() != right.getUnderlyingType()
34-
select o, "Operands of the '" + o.getOperator() + "' operation have different underlying types."
39+
isBinaryBitwiseOperation(o, left, right) and
40+
leftUnderlyingType = MisraConversion::getUnderlyingType(left) and
41+
rightUnderlyingType = MisraConversion::getUnderlyingType(right) and
42+
leftUnderlyingType != rightUnderlyingType
43+
select o,
44+
"Operands of the '" + o.getOperator() + "' operation have different underlying types '" +
45+
leftUnderlyingType.getName() + "' and '" + rightUnderlyingType.getName() + "'."

cpp/autosar/src/rules/M5-0-21/BitwiseOperatorAppliedToSignedTypes.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
import cpp
1919
import codingstandards.cpp.autosar
20+
import codingstandards.cpp.Bitwise
2021

2122
from Operation o, VariableAccess va
2223
where
2324
not isExcluded(o, ExpressionsPackage::bitwiseOperatorAppliedToSignedTypesQuery()) and
2425
(
2526
o instanceof UnaryBitwiseOperation or
2627
o instanceof BinaryBitwiseOperation or
27-
o instanceof AssignBitwiseOperation
28+
o instanceof Bitwise::AssignBitwiseOperation
2829
) and
2930
o.getAnOperand() = va and
3031
va.getTarget().getUnderlyingType().(IntegralType).isSigned()

cpp/autosar/src/rules/M5-8-1/RightBitShiftOperandIsNegativeOrTooWide.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import cpp
1919
import codingstandards.cpp.autosar
20+
import codingstandards.cpp.Bitwise
2021

2122
class ShiftOperation extends Operation {
2223
Expr leftOperand;
@@ -33,7 +34,7 @@ class ShiftOperation extends Operation {
3334
rightOperand = o.getRightOperand()
3435
)
3536
or
36-
exists(AssignBitwiseOperation o | this = o |
37+
exists(Bitwise::AssignBitwiseOperation o | this = o |
3738
(
3839
o instanceof AssignLShiftExpr
3940
or

0 commit comments

Comments
 (0)