Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
try signing archives in build (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Jun 26, 2020
1 parent 359eed1 commit acfa5f4
Show file tree
Hide file tree
Showing 32 changed files with 442 additions and 125 deletions.
67 changes: 63 additions & 4 deletions .github/workflows/master-pr-build.yml
Expand Up @@ -27,7 +27,7 @@ jobs:
checks:
runs-on: ubuntu-latest
container:
image: tmio/tuweni-build:1.0
image: tmio/tuweni-build:1.1
steps:
- uses: actions/checkout@v1
with:
Expand All @@ -43,7 +43,7 @@ jobs:
assemble:
runs-on: ubuntu-latest
container:
image: tmio/tuweni-build:1.0
image: tmio/tuweni-build:1.1
steps:
- uses: actions/checkout@v1
with:
Expand All @@ -70,10 +70,37 @@ jobs:
with:
name: Libs
path: build/libs
package-checks:
runs-on: ubuntu-latest
container:
image: tmio/tuweni-build:1.1
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Set up GPG key
run: gpg --import gradle/tuweni-test.asc
- name: Cache Maven Repository
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/dependency-versions.gradle') }}
restore-keys: ${{ runner.os }}-m2
- name: gradle assemble
uses: eskatos/gradle-command-action@v1
env:
ENABLE_SIGNING: true
with:
gradle-version: 6.3
arguments: assemble -x test -Psignatory.keyId=38F6C7215DD49C32 -Psigning.gnupg.keyName=38F6C7215DD49C32 -Psigning.gnupg.executable=gpg
- name: Unzip source
run: unzip -o dist/build/distributions/tuweni-src-*.zip -d distsrc
- name: Build from source
run: cd distsrc/$(ls distsrc) && gradle setup && ./gradlew assemble
test:
runs-on: ubuntu-latest
container:
image: tmio/tuweni-build:1.0
image: tmio/tuweni-build:1.1
steps:
- uses: actions/checkout@v1
with:
Expand All @@ -94,7 +121,39 @@ jobs:
uses: eskatos/gradle-command-action@v1
with:
gradle-version: 6.3
arguments: test
arguments: test jacocoTestReport
- name: Upload test reports
uses: actions/upload-artifact@v2
with:
name: Reports
path: "**/build/reports"
- name: Upload to Codecov
uses: codecov/codecov-action@v1
integration-tests:
runs-on: ubuntu-latest
container:
image: tmio/tuweni-build:1.1
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Cache Maven Repository
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/dependency-versions.gradle') }}
restore-keys: ${{ runner.os }}-m2
- name: gradle integrationTest
uses: eskatos/gradle-command-action@v1
with:
gradle-version: 6.3
arguments: integrationTest
- name: Upload test reports
uses: actions/upload-artifact@v2
with:
Expand Down
25 changes: 3 additions & 22 deletions Jenkinsfile
Expand Up @@ -10,6 +10,9 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

// This pipeline runs on master and pushes builds to repository.apache.org.

pipeline {
agent { label 'ubuntu' }

Expand All @@ -33,34 +36,12 @@ pipeline {
}
}
}
stage('Integration tests') {
steps {
timeout(time: 60, unit: 'MINUTES') {
sh "./gradlew clean integrationTest sourcesDistZip distZip"
}
}
}
stage('Check source build') {
steps {
timeout(time: 60, unit: 'MINUTES') {
sh "unzip dist/build/distributions/tuweni-src-*.zip -d distsrc"
sh "cd distsrc/$(ls distsrc) && ./build.sh"
}
}
}
if(env.BRANCH_NAME == 'master'){
stage('Publish') {
steps {
timeout(time: 30, unit: 'MINUTES') {
sh "./gradlew publish"
}
}
}
}
}
post {
always {
junit '**/build/test-results/test/*.xml'
}
}
}
21 changes: 19 additions & 2 deletions build.gradle
Expand Up @@ -94,6 +94,7 @@ if (file('.git').exists()) {
// And some of the files that we have checked in should also be excluded from this check
list.addAll([
'.*\\.asc',
'gradle/tuweni-test.asc',
'\\w+/out/.*',
'eth-reference-tests/**',
'build',
Expand Down Expand Up @@ -240,8 +241,6 @@ allprojects {
sourceCompatibility = '1.11'
targetCompatibility = '1.11'

jacoco { toolVersion = '0.8.5' }

dependencies {
errorprone 'com.google.errorprone:error_prone_core'
if (JavaVersion.current().isJava8()) {
Expand Down Expand Up @@ -283,6 +282,13 @@ allprojects {

disableWarningsInGeneratedCode = true
}

jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
Expand All @@ -295,6 +301,13 @@ allprojects {
'-Xuse-experimental=kotlin.Experimental'
]
}

jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
}
}


Expand Down Expand Up @@ -565,6 +578,10 @@ allprojects {
}
}

tasks.withType(GenerateModuleMetadata) {
enabled = false
}

model {
tasks.generatePomFileForMavenDeploymentPublication {
destination = file("$buildDir/generated-pom.xml")
Expand Down
3 changes: 1 addition & 2 deletions build.sh
Expand Up @@ -13,5 +13,4 @@
pushd gradle/docker
docker build -t tuweni_test -f test.Dockerfile ../..
popd
docker run tuweni_test bash -c 'gradle --version >> /dev/null && gradle -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=512m" test'
docker run -v `pwd`/build/libs:/home/gradle/build/libs tuweni_test bash -c 'gradle --version >> /dev/null && gradle -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxMetcaspaceSize=512m" assemble integrationTest -x test'
docker run -v `pwd`/build/libs:/home/gradle/build/libs tuweni_test bash -c 'gradle -Dorg.gradle.jvmargs="-Xmx2g -XX:MaxMetaspaceSize=512m" assemble'
Expand Up @@ -33,7 +33,7 @@ class DiscoveryServiceJavaTest {

@Test
void setUpAndShutDownAsync() throws Exception {
DiscoveryService service = DiscoveryService.Companion.open(SECP256K1.KeyPair.random());
DiscoveryService service = DiscoveryService.Companion.open(SECP256K1.KeyPair.random(), 0, "127.0.0.1");
service.shutdown();
AsyncCompletion completion = service.awaitTerminationAsync();
completion.join();
Expand All @@ -42,7 +42,7 @@ void setUpAndShutDownAsync() throws Exception {

@Test
void lookupAsync() throws Exception {
DiscoveryService service = DiscoveryService.Companion.open(SECP256K1.KeyPair.random());
DiscoveryService service = DiscoveryService.Companion.open(SECP256K1.KeyPair.random(), 0, "127.0.0.1");
AsyncResult<List<Peer>> result = service.lookupAsync(SECP256K1.KeyPair.random().publicKey());
List<Peer> peers = result.get();
service.shutdown();
Expand Down
Expand Up @@ -15,6 +15,8 @@
import org.apache.tuweni.crypto.SECP256K1;
import org.apache.tuweni.junit.BouncyCastleExtension;

import java.net.InetSocketAddress;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -23,7 +25,8 @@ public class NodeDiscoveryServiceTest {

@Test
void testStartAndStop() throws InterruptedException {
NodeDiscoveryService service = DefaultNodeDiscoveryService.open(SECP256K1.KeyPair.random(), 10000);
NodeDiscoveryService service =
DefaultNodeDiscoveryService.open(SECP256K1.KeyPair.random(), 10000, new InetSocketAddress("localhost", 10000));
service.startAsync().join();
service.terminateAsync().join();
}
Expand Down
Expand Up @@ -53,7 +53,9 @@ internal class DiscoveryServiceTest {

@Test
fun shouldStartAndShutdownService() {
val discoveryService = DiscoveryService.open(SECP256K1.KeyPair.random())
val discoveryService = DiscoveryService.open(
host = "127.0.0.1",
keyPair = SECP256K1.KeyPair.random())
assertFalse(discoveryService.isShutdown)
assertFalse(discoveryService.isTerminated)
discoveryService.shutdown()
Expand All @@ -69,10 +71,11 @@ internal class DiscoveryServiceTest {
fun shouldRespondToPingAndRecordEndpoint() = runBlocking {
val peerRepository = EphemeralPeerRepository()
val discoveryService = DiscoveryService.open(
host = "127.0.0.1",
keyPair = SECP256K1.KeyPair.random(),
peerRepository = peerRepository
)
val address = InetSocketAddress(InetAddress.getLocalHost(), discoveryService.localPort)
val address = InetSocketAddress(InetAddress.getLoopbackAddress(), discoveryService.localPort)

val clientKeyPair = SECP256K1.KeyPair.random()
val client = CoroutineDatagramChannel.open()
Expand All @@ -94,20 +97,21 @@ internal class DiscoveryServiceTest {
@Test
fun shouldPingBootstrapNodeAndValidate() = runBlocking {
val bootstrapKeyPair = SECP256K1.KeyPair.random()
val bootstrapClient = CoroutineDatagramChannel.open().bind(InetSocketAddress(0))
val bootstrapClient = CoroutineDatagramChannel.open().bind(InetSocketAddress("127.0.0.1", 0))

val serviceKeyPair = SECP256K1.KeyPair.random()
val peerRepository = EphemeralPeerRepository()
val routingTable = DevP2PPeerRoutingTable(serviceKeyPair.publicKey())
val discoveryService = DiscoveryService.open(
host = "127.0.0.1",
keyPair = serviceKeyPair,
bootstrapURIs = listOf(
URI("enode://" + bootstrapKeyPair.publicKey().toHexString() + "@127.0.0.1:" + bootstrapClient.localPort)
),
peerRepository = peerRepository,
routingTable = routingTable
)
val address = InetSocketAddress(InetAddress.getLocalHost(), discoveryService.localPort)
val address = InetSocketAddress(InetAddress.getLoopbackAddress(), discoveryService.localPort)

val ping = bootstrapClient.receivePacket() as PingPacket
assertEquals(discoveryService.nodeId, ping.nodeId)
Expand Down Expand Up @@ -135,20 +139,21 @@ internal class DiscoveryServiceTest {
@Test
fun shouldIgnoreBootstrapNodeRespondingWithDifferentNodeId() = runBlocking {
val bootstrapKeyPair = SECP256K1.KeyPair.random()
val bootstrapClient = CoroutineDatagramChannel.open().bind(InetSocketAddress(0))
val bootstrapClient = CoroutineDatagramChannel.open().bind(InetSocketAddress("127.0.0.1", 0))

val serviceKeyPair = SECP256K1.KeyPair.random()
val peerRepository = EphemeralPeerRepository()
val routingTable = DevP2PPeerRoutingTable(serviceKeyPair.publicKey())
val discoveryService = DiscoveryService.open(
host = "127.0.0.1",
keyPair = serviceKeyPair,
bootstrapURIs = listOf(
URI("enode://" + bootstrapKeyPair.publicKey().toHexString() + "@127.0.0.1:" + bootstrapClient.localPort)
),
peerRepository = peerRepository,
routingTable = routingTable
)
val address = InetSocketAddress(InetAddress.getLocalHost(), discoveryService.localPort)
val address = InetSocketAddress(InetAddress.getLoopbackAddress(), discoveryService.localPort)

val ping = bootstrapClient.receivePacket() as PingPacket
assertEquals(discoveryService.nodeId, ping.nodeId)
Expand All @@ -170,9 +175,10 @@ internal class DiscoveryServiceTest {
@Test
fun shouldPingBootstrapNodeWithAdvertisedAddress() = runBlocking {
val bootstrapKeyPair = SECP256K1.KeyPair.random()
val boostrapClient = CoroutineDatagramChannel.open().bind(InetSocketAddress(0))
val boostrapClient = CoroutineDatagramChannel.open().bind(InetSocketAddress("localhost", 0))

val discoveryService = DiscoveryService.open(
host = "127.0.0.1",
keyPair = SECP256K1.KeyPair.random(),
bootstrapURIs = listOf(
URI("enode://" + bootstrapKeyPair.publicKey().bytes().toHexString() + "@127.0.0.1:" + boostrapClient.localPort)
Expand All @@ -193,9 +199,10 @@ internal class DiscoveryServiceTest {
@Test
fun shouldRetryPingsToBootstrapNodes() = runBlocking {
val bootstrapKeyPair = SECP256K1.KeyPair.random()
val boostrapClient = CoroutineDatagramChannel.open().bind(InetSocketAddress(0))
val boostrapClient = CoroutineDatagramChannel.open().bind(InetSocketAddress("localhost", 0))

val discoveryService = DiscoveryService.open(
host = "127.0.0.1",
keyPair = SECP256K1.KeyPair.random(),
bootstrapURIs = listOf(
URI("enode://" + bootstrapKeyPair.publicKey().bytes().toHexString() + "@127.0.0.1:" + boostrapClient.localPort)
Expand All @@ -221,10 +228,11 @@ internal class DiscoveryServiceTest {
fun shouldRequirePingPongBeforeRespondingToFindNodesFromUnverifiedPeer() = runBlocking {
val peerRepository = EphemeralPeerRepository()
val discoveryService = DiscoveryService.open(
host = "127.0.0.1",
keyPair = SECP256K1.KeyPair.random(),
peerRepository = peerRepository
)
val address = InetSocketAddress(InetAddress.getLocalHost(), discoveryService.localPort)
val address = InetSocketAddress(InetAddress.getLoopbackAddress(), discoveryService.localPort)

val clientKeyPair = SECP256K1.KeyPair.random()
val client = CoroutineDatagramChannel.open()
Expand Down Expand Up @@ -262,7 +270,8 @@ internal class DiscoveryServiceTest {
).map { s -> URI.create(s) }
/* ktlint-enable */
val discoveryService = DiscoveryService.open(
SECP256K1.KeyPair.random(),
host = "127.0.0.1",
keyPair = SECP256K1.KeyPair.random(),
bootstrapURIs = boostrapNodes
)

Expand Down
Expand Up @@ -48,9 +48,9 @@ abstract class AbstractIntegrationTest {
bootList: List<String> = emptyList(),
enrStorage: ENRStorage = DefaultENRStorage(),
keyPair: SECP256K1.KeyPair = SECP256K1.KeyPair.random(),
enr: Bytes = EthereumNodeRecord.toRLP(keyPair, ip = InetAddress.getLocalHost(), udp = port),
enr: Bytes = EthereumNodeRecord.toRLP(keyPair, ip = InetAddress.getLoopbackAddress(), udp = port),
routingTable: RoutingTable = RoutingTable(enr),
address: InetSocketAddress = InetSocketAddress(InetAddress.getLocalHost(), port),
address: InetSocketAddress = InetSocketAddress(InetAddress.getLoopbackAddress(), port),
authenticationProvider: AuthenticationProvider = DefaultAuthenticationProvider(keyPair, routingTable),
topicTable: TopicTable = TopicTable(),
ticketHolder: TicketHolder = TicketHolder(),
Expand Down
Expand Up @@ -39,11 +39,11 @@ class DefaultNodeDiscoveryServiceTest {

private val recipientKeyPair: SECP256K1.KeyPair = SECP256K1.KeyPair.random()
private val recipientEnr: Bytes =
EthereumNodeRecord.toRLP(recipientKeyPair, ip = InetAddress.getLocalHost(), udp = 9001)
EthereumNodeRecord.toRLP(recipientKeyPair, ip = InetAddress.getLoopbackAddress(), udp = 9001)
private val encodedEnr: String = "enr:${Base64URLSafe.encode(recipientEnr)}"
private val keyPair: SECP256K1.KeyPair = SECP256K1.KeyPair.random()
private val localPort: Int = 9000
private val bindAddress: InetSocketAddress = InetSocketAddress(localPort)
private val bindAddress: InetSocketAddress = InetSocketAddress("localhost", localPort)
private val bootstrapENRList: List<String> = listOf(encodedEnr)
private val enrSeq: Long = Instant.now().toEpochMilli()
private val selfENR: Bytes = EthereumNodeRecord.toRLP(
Expand All @@ -66,7 +66,7 @@ class DefaultNodeDiscoveryServiceTest {
@Test
fun startInitializesConnectorAndBootstraps() = runBlocking {
val recipientSocket = CoroutineDatagramChannel.open()
recipientSocket.bind(InetSocketAddress(9001))
recipientSocket.bind(InetSocketAddress("localhost", 9001))

nodeDiscoveryService.start()

Expand Down

0 comments on commit acfa5f4

Please sign in to comment.