From 150fafbee86437d3ef5286f52b949948efe9fb96 Mon Sep 17 00:00:00 2001 From: Tanguy Date: Fri, 1 Jul 2022 20:20:42 +0200 Subject: [PATCH] Faster CI (#724) * Only compile once in CI * Fix codecov fetch --- .github/workflows/codecov.yml | 6 ++++++ libp2p.nimble | 8 +++----- tests/pubsub/testgossipinternal.nim | 1 + tests/pubsub/testpubsub.nim | 2 ++ tests/stublogger.nim | 10 ++++++++++ tests/testdaemon.nim | 2 +- tests/testinterop.nim | 2 +- tests/testnative.nim | 2 ++ tests/testpkifilter.nim | 1 + 9 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 tests/stublogger.nim diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index f826460..860ab78 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -25,6 +25,8 @@ jobs: ] steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Run run: | sudo apt-get update @@ -63,6 +65,8 @@ jobs: ] steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Run run: | sudo apt-get update @@ -104,6 +108,8 @@ jobs: ] steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Run run: | sudo apt-get update diff --git a/libp2p.nimble b/libp2p.nimble index 514f15c..cbd512a 100644 --- a/libp2p.nimble +++ b/libp2p.nimble @@ -28,16 +28,14 @@ const nimflags = proc runTest(filename: string, verify: bool = true, sign: bool = true, moreoptions: string = "") = var excstr = "nim c --opt:speed -d:debug -d:libp2p_agents_metrics -d:libp2p_protobuf_metrics -d:libp2p_network_protocols_metrics -d:libp2p_mplex_metrics " + excstr.add(" -d:chronicles_sinks=textlines[stdout],json[dynamic] -d:chronicles_log_level=TRACE ") + excstr.add(" -d:chronicles_runtime_filtering=TRUE ") excstr.add(" " & getEnv("NIMFLAGS") & " ") excstr.add(" " & nimflags & " ") excstr.add(" -d:libp2p_pubsub_sign=" & $sign) excstr.add(" -d:libp2p_pubsub_verify=" & $verify) excstr.add(" " & moreoptions & " ") - if verify and sign: - # build it with TRACE and JSON logs - exec excstr & " -d:chronicles_log_level=TRACE -d:chronicles_sinks:json" & " tests/" & filename - # build it again, to run it with less verbose logs - exec excstr & " -d:chronicles_log_level=INFO -r" & " tests/" & filename + exec excstr & " -r " & " tests/" & filename rmFile "tests/" & filename.toExe proc buildSample(filename: string, run = false) = diff --git a/tests/pubsub/testgossipinternal.nim b/tests/pubsub/testgossipinternal.nim index 3e03040..7e87f6c 100644 --- a/tests/pubsub/testgossipinternal.nim +++ b/tests/pubsub/testgossipinternal.nim @@ -3,6 +3,7 @@ include ../../libp2p/protocols/pubsub/gossipsub {.used.} import options +import ../stublogger import stew/byteutils import ../../libp2p/builders import ../../libp2p/errors diff --git a/tests/pubsub/testpubsub.nim b/tests/pubsub/testpubsub.nim index c33e6e7..08b9aba 100644 --- a/tests/pubsub/testpubsub.nim +++ b/tests/pubsub/testpubsub.nim @@ -1,5 +1,7 @@ {.used.} +import ../stublogger + import testfloodsub, testgossipsub, testgossipsub2, diff --git a/tests/stublogger.nim b/tests/stublogger.nim new file mode 100644 index 0000000..ef796c3 --- /dev/null +++ b/tests/stublogger.nim @@ -0,0 +1,10 @@ +import std/typetraits +import chronicles + +when defined(chronicles_runtime_filtering): + setLogLevel(INFO) + +when defaultChroniclesStream.outputs.type.arity == 1: + # Hide the json logs, they're just here to check if we compile + proc noOutput(logLevel: LogLevel, msg: LogOutputStr) = discard + defaultChroniclesStream.outputs[0].writer = noOutput \ No newline at end of file diff --git a/tests/testdaemon.nim b/tests/testdaemon.nim index 5c1da3d..10b80a2 100644 --- a/tests/testdaemon.nim +++ b/tests/testdaemon.nim @@ -1,4 +1,4 @@ -import chronos, unittest2, helpers +import chronos, unittest2, helpers, stublogger import ../libp2p/daemon/daemonapi, ../libp2p/multiaddress, ../libp2p/multicodec, ../libp2p/cid, ../libp2p/multihash, ../libp2p/peerid diff --git a/tests/testinterop.nim b/tests/testinterop.nim index ce05efc..9903650 100644 --- a/tests/testinterop.nim +++ b/tests/testinterop.nim @@ -1,4 +1,4 @@ -import options, tables +import options, tables, stublogger import chronos, chronicles, stew/byteutils import helpers import ../libp2p diff --git a/tests/testnative.nim b/tests/testnative.nim index 998f104..c08783a 100644 --- a/tests/testnative.nim +++ b/tests/testnative.nim @@ -1,3 +1,5 @@ +import stublogger + import testvarint, testconnection, testminprotobuf, diff --git a/tests/testpkifilter.nim b/tests/testpkifilter.nim index 4f5562e..fcb9b1f 100644 --- a/tests/testpkifilter.nim +++ b/tests/testpkifilter.nim @@ -9,6 +9,7 @@ when defined(nimHasUsed): {.used.} import unittest2 +import stublogger import ../libp2p/crypto/crypto import nimcrypto/utils