From bc7c012ce41796ff861c1b166b37956dc93f4182 Mon Sep 17 00:00:00 2001 From: trajan0x <83933037+trajan0x@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:51:39 -0400 Subject: [PATCH] use nsc for coverage (#2893) Co-authored-by: Trajan0x --- .github/workflows/go.yml | 36 +++++++++++++++++++------------ core/README.md | 1 + core/processlog/options.go | 3 ++- docker/goreleaser/Dockerfile | 5 +++++ ethergo/backends/anvil/options.go | 2 +- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index de5090c565..02130eabfb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -77,17 +77,14 @@ jobs: test: name: Go Coverage - runs-on: ${{ matrix.platform }} + runs-on: ${{ (matrix.package == 'agents' || matrix.package == 'core' || matrix.package == 'tools' || contains(matrix.package, 'contrib')) && 'ubuntu-latest' || 'namespace-profile-default-coverage-runner' }} if: ${{ needs.changes.outputs.package_count_deps > 0 && (github.event_name != 'push' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) }} needs: changes strategy: fail-fast: false - max-parallel: 8 matrix: go-version: - 1.22.x - platform: - - ubuntu-latest # only do on agents for now. Anything that relies on solidity in a package should do this package: ${{ fromJSON(needs.changes.outputs.packages_deps) }} services: @@ -112,6 +109,7 @@ jobs: - name: Go modules cache uses: actions/cache@v4 + if: ${{ !contains(runner.name, 'nsc') }} with: # see https://github.com/mvdan/github-actions-golang # also: https://glebbahmutov.com/blog/do-not-let-npm-cache-snowball/ w/ go build (workaround now is having a cache that just gets expired at night) @@ -128,6 +126,14 @@ jobs: uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} + cache: ${{ contains(runner.name, 'nsc') && 'false' || 'true' }} + + # TODO: consider setting up cache key, see: https://discord.com/channels/975088590705012777/1263347501721714793/1263534719954452560 + - name: Setup Go cache + uses: namespacelabs/nscloud-cache-action@v1 + if: ${{ contains(runner.name, 'nsc') }} + with: + cache: go - name: Verify MariaDB connection env: @@ -201,7 +207,7 @@ jobs: MYSQL_DATABASE: test MYSQL_ROOT_PASSWORD: password MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }} - GOMEMLIMIT: 3GiB + GOMEMLIMIT: 8GiB GOGC: -1 ETHEREUM_RPC_URI: ${{ secrets.ETHEREUM_RPC_URI }} GOPROXY: https://proxy.golang.org @@ -220,15 +226,19 @@ jobs: uses: jwalton/gh-docker-logs@v2 with: dest: '/tmp/logs' - - name: Tar logs - if: failure() - run: tar cvzf ./logs.tgz /tmp/logs + + - name: Replace forward slashes with dashes + id: replace + run: echo "::set-output name=package_name::$(echo ${{ matrix.package }} | sed 's/\//-/g')" + shell: bash + + - name: Upload logs to GitHub - if: failure() +# if: failure() uses: actions/upload-artifact@v4 with: - name: ${{matrix.package}}-logs.tgz - path: ./logs.tgz + name: ${{ steps.replace.outputs.package_name }} + path: /tmp/logs/** - name: Send Coverage (Codecov) uses: Wandalen/wretry.action@v1.0.36 @@ -254,8 +264,6 @@ jobs: matrix: go-version: - 1.22.x - platform: - - ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -489,7 +497,7 @@ jobs: if: ${{ github.event_name != 'push' && needs.changes.outputs.package_count_deps > 0 }} strategy: fail-fast: false - max-parallel: 8 + max-parallel: 12 matrix: # only do on agents for now. Anything that relies on solidity in a package should do this package: ${{ fromJSON(needs.changes.outputs.packages_deps) }} diff --git a/core/README.md b/core/README.md index 646b106eea..e307596658 100644 --- a/core/README.md +++ b/core/README.md @@ -27,3 +27,4 @@ root ├── testsuite: Provides a wrapper around testify/suite. ├── threaditer: Provides a thread-safe generic iterator for a slice. + diff --git a/core/processlog/options.go b/core/processlog/options.go index d22910e591..0a7b706381 100644 --- a/core/processlog/options.go +++ b/core/processlog/options.go @@ -180,7 +180,8 @@ func makeRawArgs(opts []StdStreamLogArgsOption) *stdStreamLogArgs { args.LogFileName = "test" args.LogFrequency = time.Second // not a problem unless it's missing from user too, we'll validate at the end - args.LogDir, _ = os.MkdirTemp("", "") + args.LogDir, _ = os.MkdirTemp("/tmp/logs", "") + _ = os.MkdirAll("/tmp/logs", os.ModePerm) args.LogFileName = "log" args.PrintFunc = func(s []byte) { diff --git a/docker/goreleaser/Dockerfile b/docker/goreleaser/Dockerfile index 37c9dafc6d..d325f2b92a 100644 --- a/docker/goreleaser/Dockerfile +++ b/docker/goreleaser/Dockerfile @@ -120,3 +120,8 @@ RUN apt-get update && apt-get install -y nodejs RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin RUN rm -rf /var/lib/apt/lists/* /var/log/apt/* /tmp/* /var/tmp/* + + +RUN curl -fsSL https://get.namespace.so/cloud/install.sh | NS_ROOT=/usr/local sh && exit 0 +ENV NS_ROOT=/usr/local/bin +ENV PATH=${PATH}:/usr/local/bin diff --git a/ethergo/backends/anvil/options.go b/ethergo/backends/anvil/options.go index e500bd6c19..7c7998d354 100644 --- a/ethergo/backends/anvil/options.go +++ b/ethergo/backends/anvil/options.go @@ -29,7 +29,7 @@ func NewAnvilOptionBuilder() *OptionBuilder { // set default non-anvil values optionsBuilder.SetMaxWaitTime(time.Minute * 2) optionsBuilder.SetRestartPolicy(Autoremove) - optionsBuilder.SetExpirySeconds(600) + optionsBuilder.SetExpirySeconds(900) optionsBuilder.SetAccounts(10) optionsBuilder.SetBlockTime(0)