Skip to content

Commit f0e1969

Browse files
authored
Merge branch 'main' into dependabot/pip/scripts/release/gitpython-3.1.37
2 parents bfab513 + 5e17d21 commit f0e1969

23 files changed

+244
-83
lines changed

.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

+3-4
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
@@ -54,13 +54,12 @@ jobs:
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:

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
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,8 @@
1+
* `A7-1-5` - exclude auto variables initialized with an expression of non-fundamental type. Typically this occurs when using range based for loops with arrays of non-fundamental types. For example:
2+
```
3+
void iterate(Foo values[]) {
4+
for (auto value : values) { // COMPLIANT (previously false positive)
5+
// ...
6+
}
7+
}
8+
```

change_notes/2023-10-25-a0-1-1.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* `A0-1-1` - address a number of false positive issues:
2+
* Exclude compiler-generated variables, such as those generated for range-based for loops.
3+
* Exclude variables in uninstantiated templates, for which we have no precise data on uses.
4+
* Deviations should now be applied to the useless assignment instead of the variable itself.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `A15-4-4`: remove false positives reported on uninsantiated templates.

cpp/autosar/src/rules/A0-1-1/UselessAssignment.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ import codingstandards.cpp.deadcode.UselessAssignments
2020

2121
from SsaDefinition ultimateDef, InterestingStackVariable v
2222
where
23-
not isExcluded(v, DeadCodePackage::uselessAssignmentQuery()) and
23+
not isExcluded(ultimateDef, DeadCodePackage::uselessAssignmentQuery()) and
2424
isUselessSsaDefinition(ultimateDef, v)
2525
select ultimateDef, "Definition of $@ is unused.", v, v.getName()

cpp/autosar/src/rules/A15-4-4/MissingNoExcept.ql

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ where
3333
// The function is defined in this database
3434
f.hasDefinition() and
3535
// This function is not an overriden call operator of a lambda expression
36-
not exists(LambdaExpression lambda | lambda.getLambdaFunction() = f)
37-
select f, "Function " + f.getName() + " could be declared noexcept(true)."
36+
not exists(LambdaExpression lambda | lambda.getLambdaFunction() = f) and
37+
// Exclude results from uinstantiated templates
38+
not f.isFromUninstantiatedTemplate(_)
39+
select f, "Function " + f.getQualifiedName() + " could be declared noexcept(true)."

cpp/autosar/src/rules/A7-1-5/AutoSpecifierNotUsedAppropriatelyInVariableDefinition.ql

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
import cpp
2020
import codingstandards.cpp.autosar
2121

22+
class FundamentalType extends BuiltInType {
23+
FundamentalType() { not this instanceof ErroneousType and not this instanceof UnknownType }
24+
}
25+
2226
from Variable v
2327
where
2428
not isExcluded(v,
@@ -28,12 +32,14 @@ where
2832
// exclude uninstantiated templates and rely on the instantiated templates, because an uninstantiated template may not contain the information required to determine if the usage is allowed.
2933
not v.isFromUninstantiatedTemplate(_) and
3034
not (
31-
// find ones where
35+
// Initialized by function call
3236
v.getInitializer().getExpr() instanceof FunctionCall
3337
or
38+
// Initialized by lambda expression
3439
v.getInitializer().getExpr() instanceof LambdaExpression
3540
or
36-
v.getInitializer().getExpr() instanceof ClassAggregateLiteral
41+
// Initialized by non-fundamental type
42+
not v.getInitializer().getExpr().getType() instanceof FundamentalType
3743
) and
3844
// Exclude compiler generated variables
3945
not v.isCompilerGenerated()

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,15 @@ int test_useless_assignment(int &x, int p) {
112112
return y;
113113
}
114114

115-
int main() { return 0; }
115+
int main() { return 0; }
116+
117+
#include <vector>
118+
template <typename T> void test_range_based_for_loop_template() {
119+
std::vector<A> values_;
120+
for (auto &elem : values_) { // COMPLIANT - should not report either elem or
121+
// the compiler generated (__range)
122+
// variable in the uninstantiated
123+
// template
124+
elem;
125+
}
126+
}

cpp/autosar/test/rules/A15-4-4/test.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,17 @@ class A {
3030
void lambda_example() noexcept {
3131
auto with_capture = [=]() {};
3232
auto empty_capture = []() {};
33+
}
34+
35+
#include <utility>
36+
template <typename TypeA, typename TypeB>
37+
void swap_wrapper(TypeA lhs,
38+
TypeB rhs) noexcept(noexcept(std::swap(*lhs, *rhs))) {
39+
std::swap(*lhs, *rhs);
40+
}
41+
42+
void test_swap_wrapper() noexcept {
43+
int a = 0;
44+
int b = 1;
45+
swap_wrapper(&a, &b);
3346
}

cpp/autosar/test/rules/A7-1-5/AutoSpecifierNotUsedAppropriatelyInVariableDefinition.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
| test.cpp:27:8:27:8 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
55
| test.cpp:28:8:28:8 | b | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
66
| test.cpp:81:10:81:10 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
7-
| test.cpp:111:19:111:19 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
7+
| test.cpp:111:13:111:13 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |

cpp/autosar/test/rules/A7-1-5/test.cpp

+24-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,30 @@ void instantiate() {
106106
t381.test_381_1();
107107
t381.test_381_2();
108108
}
109-
109+
class Foo {};
110110
void test_loop() {
111-
for (const auto a : {8, 9, 10}) {
111+
for (auto a : {8, 9, 10}) { // NON_COMPLIANT - a is initialized with a
112+
// non-constant initializer
113+
a;
114+
}
115+
116+
std::vector<int> v = {1, 2, 3};
117+
for (auto &a : v) { // COMPLIANT - a is intialized with a function call
118+
a;
119+
}
120+
121+
Foo f1;
122+
Foo f2;
123+
for (auto &a : {f1, f2}) { // COMPLIANT - initialized with a non-fundamental
124+
// type
112125
a;
113126
}
114-
}
127+
}
128+
129+
template <typename T> void test_template(std::vector<T> v2) {
130+
for (auto &a : v2) { // COMPLIANT - a is intialized with a function call
131+
a;
132+
}
133+
}
134+
135+
void test_template_instantiation() { test_template<int>({1, 2, 3}); }

cpp/common/src/codingstandards/cpp/deadcode/UselessAssignments.qll

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ class InterestingStackVariable extends StackVariable {
4343
// A reference parameter can have an affect outside the enclosing function
4444
not mayEscape(this) and
4545
// Not a loop control variable, explicitly excluded
46-
not this instanceof LoopControlVariable
46+
not this instanceof LoopControlVariable and
47+
// Ignore variables in uninstantiated templates
48+
not this.isFromUninstantiatedTemplate(_) and
49+
// Ignore compiler generated variables, such as those generated for range based for loops
50+
not this.isCompilerGenerated()
4751
}
4852
}
4953

scripts/release/release-layout.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ layout:
2020
- file: docs/user_manual.md
2121
checksums.txt:
2222
- shell: |
23-
sha256sum ./* > checksums.txt
23+
sha256sum ${{ layout.root }}/* > checksums.txt
24+
# Remove the layout root from the paths in checksums.txt
25+
sed -i -e "s|${{ layout.root }}/||g" checksums.txt

scripts/release/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
semantic-version==2.10.0
22
PyGithub==1.59.1
33
PyYAML==6.0.1
4-
GitPython==3.1.37
4+
GitPython==3.1.37
5+
pytest==7.4.3

0 commit comments

Comments
 (0)