Skip to content

Commit

Permalink
Update GitHub actions + fix CodeQL alert (#8010)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Feb 23, 2024
1 parent a254e03 commit 7585440
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 24 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ jobs:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v3
Expand All @@ -48,32 +50,33 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

#- run: |
# make bootstrap
# make release
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
4 changes: 2 additions & 2 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ jobs:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
2 changes: 1 addition & 1 deletion .github/workflows/test-path-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ jobs:
name: "Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Check test paths
run: ./scripts/testcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ public MilestoneBasedEngineJsonRpcMethodsResolver(
case CAPELLA:
methodsByMilestone.put(milestone, capellaSupportedMethods());
break;
case DENEB, ELECTRA:
case DENEB:
methodsByMilestone.put(milestone, denebSupportedMethods());
break;
case ELECTRA:
methodsByMilestone.put(milestone, electraSupportedMethods());
break;
}
});
}
Expand Down Expand Up @@ -105,6 +108,16 @@ private Map<EngineApiMethod, EngineJsonRpcMethod<?>> denebSupportedMethods() {
return methods;
}

private Map<EngineApiMethod, EngineJsonRpcMethod<?>> electraSupportedMethods() {
final Map<EngineApiMethod, EngineJsonRpcMethod<?>> methods = new HashMap<>();

methods.put(ENGINE_NEW_PAYLOAD, new EngineNewPayloadV3(executionEngineClient));
methods.put(ENGINE_GET_PAYLOAD, new EngineGetPayloadV3(executionEngineClient, spec));
methods.put(ENGINE_FORK_CHOICE_UPDATED, new EngineForkChoiceUpdatedV3(executionEngineClient));

return methods;
}

@Override
@SuppressWarnings({"unchecked", "unused"})
public <T> EngineJsonRpcMethod<T> getMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,49 @@ void shouldProvideExpectedMethodsForDeneb(
assertThat(providedMethod).isExactlyInstanceOf(expectedMethodClass);
}

private static Stream<Arguments> denebMethods() {
return Stream.of(
arguments(ENGINE_NEW_PAYLOAD, EngineNewPayloadV3.class),
arguments(ENGINE_GET_PAYLOAD, EngineGetPayloadV3.class),
arguments(ENGINE_FORK_CHOICE_UPDATED, EngineForkChoiceUpdatedV3.class));
}

@Test
void electraMilestoneMethodIsNotSupportedInDeneb() {
final Spec capellaSpec = TestSpecFactory.createMinimalDeneb();

final MilestoneBasedEngineJsonRpcMethodsResolver engineMethodsResolver =
new MilestoneBasedEngineJsonRpcMethodsResolver(capellaSpec, executionEngineClient);

assertThatThrownBy(
() ->
engineMethodsResolver.getMethod(
ENGINE_GET_PAYLOAD, () -> SpecMilestone.ELECTRA, Object.class))
.hasMessage("Can't find method with name engine_getPayload for milestone ELECTRA");
}

@ParameterizedTest
@MethodSource("electraMethods")
void shouldProvideExpectedMethodsForElectra(
EngineApiMethod method, Class<EngineJsonRpcMethod<?>> expectedMethodClass) {
final Spec electraSpec = TestSpecFactory.createMinimalElectra();

final MilestoneBasedEngineJsonRpcMethodsResolver engineMethodsResolver =
new MilestoneBasedEngineJsonRpcMethodsResolver(electraSpec, executionEngineClient);

final EngineJsonRpcMethod<Object> providedMethod =
engineMethodsResolver.getMethod(method, () -> SpecMilestone.ELECTRA, Object.class);

assertThat(providedMethod).isExactlyInstanceOf(expectedMethodClass);
}

private static Stream<Arguments> electraMethods() {
return Stream.of(
arguments(ENGINE_NEW_PAYLOAD, EngineNewPayloadV3.class),
arguments(ENGINE_GET_PAYLOAD, EngineGetPayloadV3.class),
arguments(ENGINE_FORK_CHOICE_UPDATED, EngineForkChoiceUpdatedV3.class));
}

@Test
void getsCapabilities() {
final Spec spec =
Expand All @@ -177,11 +220,4 @@ void getsCapabilities() {
"engine_getPayloadV3",
"engine_forkchoiceUpdatedV3");
}

private static Stream<Arguments> denebMethods() {
return Stream.of(
arguments(ENGINE_NEW_PAYLOAD, EngineNewPayloadV3.class),
arguments(ENGINE_GET_PAYLOAD, EngineGetPayloadV3.class),
arguments(ENGINE_FORK_CHOICE_UPDATED, EngineForkChoiceUpdatedV3.class));
}
}

0 comments on commit 7585440

Please sign in to comment.