-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
staterecovery: fix cli options regression (#567)
* staterecovery: fix cli options regression & add CI jobs
- Loading branch information
Showing
61 changed files
with
430 additions
and
505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: staterecovery-testing | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
commit_tag: | ||
required: true | ||
type: string | ||
secrets: | ||
DOCKERHUB_USERNAME: | ||
required: false | ||
DOCKERHUB_TOKEN: | ||
required: false | ||
|
||
concurrency: | ||
group: staterecovery-testing-${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
jobs: | ||
cache-docker-images: | ||
uses: ./.github/workflows/cache-docker-images.yml | ||
secrets: inherit | ||
run-tests: | ||
env: | ||
COMMIT_TAG: ${{ inputs.commit_tag }} | ||
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN_RELEASE_ACCESS }} | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-large | ||
name: Staterecovery tests | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b #v4.5.0 | ||
with: | ||
distribution: temurin | ||
java-version: 21 | ||
- name: Setup Gradle | ||
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | ||
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 #v4.2.1 | ||
- name: Restore cached images | ||
id: restore-cached-images | ||
uses: actions/cache/restore@v4.0.2 | ||
with: | ||
path: ~/docker-images | ||
key: cached-images | ||
restore-keys: | | ||
cached-images | ||
- name: Staterecovery - Build and Unit tests | ||
run: | | ||
./gradlew state-recovery:besu-plugin:buildNeeded | ||
# Install pnpm to deploy smart contracts | ||
# FIXME: use web3j to deploy contracts and remove this. | ||
- name: Setup nodejs environment | ||
uses: ./.github/actions/setup-nodejs | ||
with: | ||
pnpm-install-options: '--frozen-lockfile --prefer-offline --filter contracts --ignore-scripts' | ||
- name: Staterecovery - Build plugin shadowJar | ||
run: | | ||
./gradlew state-recovery:besu-plugin:shadowJar | ||
- name: Run integration tests | ||
timeout-minutes: 15 | ||
run: | | ||
./gradlew state-recovery:test-cases:integrationTest | ||
- name: Run Jacoco | ||
run: | | ||
./gradlew jacocoRootReport | ||
- name: Upload Jacoco test coverage report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: jacocoRootReport-${{ env.COMMIT_TAG }}.xml | ||
if-no-files-found: error | ||
path: | | ||
${{ github.workspace }}/build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml | ||
- name: Upload coverage to Codecov | ||
if: ${{ env.CODECOV_TOKEN != '' }} | ||
uses: codecov/codecov-action@v5 | ||
with: | ||
fail_ci_if_error: true | ||
files: ${{ github.workspace }}/build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml | ||
flags: kotlin | ||
os: linux | ||
name: codecov-staterecovery | ||
verbose: true | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
coordinator/ethereum/test-utils/src/main/kotlin/linea/testing/CommandRunner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package linea.testing | ||
|
||
import net.consensys.linea.async.toSafeFuture | ||
import net.consensys.linea.testing.filesystem.getPathTo | ||
import org.apache.logging.log4j.LogManager | ||
import tech.pegasys.teku.infrastructure.async.SafeFuture | ||
import java.io.BufferedReader | ||
import java.io.File | ||
import java.io.InputStreamReader | ||
import kotlin.time.Duration | ||
import kotlin.time.Duration.Companion.minutes | ||
|
||
data class CommandResult( | ||
val exitCode: Int, | ||
val stdOut: List<String>, | ||
val stdErr: List<String> | ||
) | ||
|
||
object Runner { | ||
|
||
fun executeCommand( | ||
command: String, | ||
envVars: Map<String, String> = emptyMap(), | ||
executionDir: File = getPathTo("Makefile").parent.toFile(), | ||
timeout: Duration = 1.minutes | ||
): SafeFuture<CommandResult> { | ||
val log = LogManager.getLogger("net.consensys.zkevm.ethereum.CommandExecutor") | ||
val processBuilder = ProcessBuilder("/bin/sh", "-c", command) | ||
processBuilder.directory(executionDir) | ||
|
||
// Set environment variables | ||
val env = processBuilder.environment() | ||
for ((key, value) in envVars) { | ||
env[key] = value | ||
} | ||
|
||
val process = processBuilder.start() | ||
val stdOutReader = BufferedReader(InputStreamReader(process.inputStream)) | ||
val stdErrorReader = BufferedReader(InputStreamReader(process.errorStream)) | ||
|
||
// Read the standard output | ||
log.debug( | ||
"going to execute command: dir='{}', command='{}', envVars={} commandProcessId={} processInfo={}", | ||
executionDir, | ||
command, | ||
envVars, | ||
process.pid(), | ||
process.info() | ||
) | ||
process.waitFor(timeout.inWholeMilliseconds, java.util.concurrent.TimeUnit.MILLISECONDS) | ||
val futureResult = process | ||
.onExit() | ||
.thenApply { processResult -> | ||
val stdOutLines = stdOutReader.lines().toList() | ||
val stdErrLines = stdErrorReader.lines().toList() | ||
log.debug( | ||
"command finished: dir='{}', command='{}', exitCode={} envVars={} processId={} threadId={}", | ||
executionDir, | ||
command, | ||
processResult.exitValue(), | ||
envVars, | ||
ProcessHandle.current().pid(), | ||
Thread.currentThread().threadId() | ||
) | ||
log.debug( | ||
"stdout: {}", | ||
stdOutLines.joinToString("\n") | ||
) | ||
log.debug( | ||
"stderr: {}", | ||
stdErrLines.joinToString("\n") | ||
) | ||
CommandResult(processResult.exitValue(), stdOutLines, stdErrLines) | ||
} | ||
|
||
return futureResult.toSafeFuture() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.