Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nim ping test #70

Merged
merged 11 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/ping-interop-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of introducing a new workflow file, how about including nim in ping-interop.yml. I don't see a reason why we should treat Go or Rust special.

Maybe @MarcoPolo has opinions here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping-interop.yml will call the go-rust-interop.toml composition
So it could just call the all-interop.toml instead, but then the go-rust-interop.toml will never be called, and maybe it should be removed?
We would just have:

  • [language].toml: list of versions of that implem
  • [language]-cross-versions.toml: test every version of that implem
  • all-interop-latest.toml: test last version of every implem
  • all-interop.toml: test every version of every implem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this in my latest commit, we can revert if not happy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would just have:

* `[language].toml`: list of versions of that implem

* `[language]-cross-versions.toml`: test every version of that implem

* `all-interop-latest.toml`: test last version of every implem

* `all-interop.toml`: test every version of every implem

On a high level I am in favor of this. I will take a detailed look now.

workflow_dispatch:
inputs:
testground_endpoint:
type: string
required: false
description: testground endpoint
custom_git_reference:
description: the git commit or branch we're going to use for the custom target
required: false
type: string
custom_git_target:
description: the custom git fork url we're going to use for the custom target (github.com/some-fork/rust-libp2p)
required: false
type: string
custom_interop_target:
description: in the case of cross-implementation testing, the implementation target (go | rust | nim)
required: false
type: string
push:
pull_request:

name: libp2p ping - all tests with testground.

jobs:
run-all-ping-latest:
uses: "./.github/workflows/run-composition.yml"
with:
composition_file: "ping/_compositions/all-interop-latest.toml"
custom_git_target: ${{ github.event.inputs.custom_git_target }} # nothing or "some-fork/go-libp2p"
custom_git_reference: ${{ github.event.inputs.custom_git_reference }} # a git reference
custom_interop_target: ${{ github.event.inputs.custom_interop_target }} # go | rust
testground_endpoint: ${{ github.event.inputs.testground_endpoint }}
test_repository: ${{ (github.event.inputs && '') || github.repository }}
test_ref: ${{ (github.event.inputs && '') || github.event.pull_request.head.sha || github.sha }}
run-all-ping-all:
uses: "./.github/workflows/run-composition.yml"
with:
composition_file: "ping/_compositions/all-interop.toml"
custom_git_target: ${{ github.event.inputs.custom_git_target }} # nothing or "some-fork/go-libp2p"
custom_git_reference: ${{ github.event.inputs.custom_git_reference }} # a git reference
custom_interop_target: ${{ github.event.inputs.custom_interop_target }} # go | rust
testground_endpoint: ${{ github.event.inputs.testground_endpoint }}
test_repository: ${{ (github.event.inputs && '') || github.repository }}
test_ref: ${{ (github.event.inputs && '') || github.event.pull_request.head.sha || github.sha }}
133 changes: 133 additions & 0 deletions ping/_compositions/all-interop-latest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
[metadata]
name = "all-latest-{{ or $.Env.InteropTarget "-" }}-{{ or $.Env.GitReference "" }}"

[global]
plan = "libp2p/ping"
case = "ping"
runner = "local:docker"
concurrent_builds = 1

[global.build_config]
enable_go_build_cache = false # see https://github.com/testground/testground/issues/1361
# disable testground's goproxy which hangs on github runners.
go_proxy_mode = "remote"
go_proxy_url = "https://proxy.golang.org"

{{ with (load_resource "./go.toml") }}
{{ with (index .groups 0) }}
[[groups]]
id = "go-latest-{{ .Id }}"
instances = { count = 1 }
builder = "docker:go"

[groups.build]
selectors = ['{{ .Selector }}']

[groups.build_config]
path = "./go/"
build_base_image = 'golang:{{ .GoVersion }}-buster'
modfile = "{{ .Modfile }}"
{{ end }}

{{ if eq $.Env.InteropTarget "go" }}
{{ if $.Env.GitReference }}
{{ with .custom }}
[[groups]]
id = "go-custom-{{ $.Env.GitReference }}"
instances = { count = 1 }
builder = "docker:go"

[groups.build]
selectors = ['{{ .Selector }}']

[[groups.build.dependencies]]
module = "github.com/libp2p/go-libp2p"
version = "{{ $.Env.GitReference }}"
{{ if $.Env.GitTarget }}
target = "{{ $.Env.GitTarget }}"
{{ end }}

[groups.build_config]
path = "./go/"
build_base_image = 'golang:{{ .GoVersion }}-buster'
modfile = "{{ .Modfile }}"

[groups.build_config.dockerfile_extensions]
# deal with dependency changes in master until we create the new vx.y.z instance
pre_build = """
RUN cd ${PLAN_DIR} && \
go mod download github.com/libp2p/go-libp2p && \
go mod tidy -compat={{ .GoVersion }}
"""
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{ with (load_resource "./rust.toml") }}
{{ with (index .groups 0) }}
[[groups]]
id = "rust-latest-{{ .Id }}"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./rust/"

[groups.build_config.build_args]
CARGO_FEATURES = '{{ .CargoFeatures }}'
{{ end }}

{{ if eq $.Env.InteropTarget "rust" }}
{{ if $.Env.GitReference }}
{{ with .custom }}
[[groups]]
id = "rust-custom-{{ $.Env.GitReference }}"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./rust/"

[groups.build_config.build_args]
CARGO_FEATURES = '{{ .CargoFeatures }}'
CARGO_REMOVE = '{{ .CargoFeatures }}'
CARGO_PATCH = """
{{ .CargoFeatures }} = {package = "libp2p", git = "https://{{ or $.Env.GitTarget "github.com/libp2p/rust-libp2p" }}", rev = "{{ $.Env.GitReference }}", default_features = false, features = [ "websocket", "mplex", "yamux", "tcp", "ping", "noise", "dns", "async-std", "rsa" ], optional = true}
"""
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{ with (load_resource "./nim.toml") }}
{{ with (index .groups 0) }}
[[groups]]
id = "nim-latest-{{ .Id }}"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./nim/"
[groups.build_config.build_args]
Libp2pVersion = '{{ .Id }}'
NimVersion = '{{ .NimVersion }}'
{{ end }}

{{ if eq $.Env.InteropTarget "nim" }}
{{ if $.Env.GitReference }}
{{ with .custom }}
[[groups]]
id = "nim-custom-{{ $.Env.GitReference }}"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./nim/"
[groups.build_config.build_args]
Libp2pVersion = '#{{ $.Env.GitReference }}'
NimVersion = '{{ .NimVersion }}'
{{ end }}
{{ end }}
{{ end }}
{{ end }}
186 changes: 186 additions & 0 deletions ping/_compositions/all-interop.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
[metadata]
name = "all-cross-version"

[global]
plan = "libp2p/ping"
case = "ping"
runner = "local:docker"
concurrent_builds = 1

[global.build_config]
enable_go_build_cache = false # see https://github.com/testground/testground/issues/1361
# disable testground's goproxy which hangs on github runners.
go_proxy_mode = "remote"
go_proxy_url = "https://proxy.golang.org"

{{ with (load_resource "./go.toml") }}
{{ range .groups }}
[[groups]]
id = "{{ .Id }}"
instances = { count = 1 }
builder = "docker:go"

[groups.build]
selectors = ['{{ .Selector }}']

[groups.build_config]
path = "./go/"
build_base_image = 'golang:{{ .GoVersion }}-buster'
modfile = "{{ .Modfile }}"
{{ end }}

{{ with .master }}
[[groups]]
id = "master"
instances = { count = 1 }
builder = "docker:go"

[groups.build]
selectors = ['{{ .Selector }}']

[[groups.build.dependencies]]
module = "github.com/libp2p/go-libp2p"
version = "master"

[groups.build_config]
path = "./go/"
build_base_image = 'golang:{{ .GoVersion }}-buster'
modfile = "{{ .Modfile }}"

[groups.build_config.dockerfile_extensions]
# deal with dependency changes in master until we create the new vx.y.z instance
pre_build = """
RUN cd ${PLAN_DIR} && \
go mod download github.com/libp2p/go-libp2p && \
go mod tidy -compat={{ .GoVersion }}
"""
{{ end }}

{{ if eq $.Env.InteropTarget "go" }}
{{ if $.Env.GitReference }}
{{ with .custom }}
[[groups]]
id = "custom-go"
instances = { count = 1 }
builder = "docker:go"

[groups.build]
selectors = ['{{ .Selector }}']

[[groups.build.dependencies]]
module = "github.com/libp2p/go-libp2p"
version = "{{ $.Env.GitReference }}"
{{ if $.Env.GitTarget }}
target = "{{ $.Env.GitTarget }}"
{{ end }}

[groups.build_config]
path = "./go/"
build_base_image = 'golang:{{ .GoVersion }}-buster'
modfile = "{{ .Modfile }}"

[groups.build_config.dockerfile_extensions]
# deal with dependency changes in master until we create the new vx.y.z instance
pre_build = """
RUN cd ${PLAN_DIR} && \
go mod download github.com/libp2p/go-libp2p && \
go mod tidy -compat={{ .GoVersion }}
"""
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{ with (load_resource "./rust.toml") }}
{{ range .groups }}
[[groups]]
id = "rust-{{ .Id }}"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./rust/"

[groups.build_config.build_args]
CARGO_FEATURES = '{{ .CargoFeatures }}'
{{ end }}

{{ with .master }}
[[groups]]
id = "rust-master"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./rust/"

[groups.build_config.build_args]
CARGO_FEATURES = '{{ .CargoFeatures }}'
{{ end }}

{{ if eq $.Env.InteropTarget "rust" }}
{{ if $.Env.GitReference }}
{{ with .custom }}
[[groups]]
id = "custom-rust"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./rust/"

[groups.build_config.build_args]
CARGO_FEATURES = '{{ .CargoFeatures }}'
CARGO_REMOVE = '{{ .CargoFeatures }}'
CARGO_PATCH = """
{{ .CargoFeatures }} = {package = "libp2p", git = "https://{{ or $.Env.GitTarget "github.com/libp2p/rust-libp2p" }}", rev = "{{ $.Env.GitReference }}", default_features = false, features = [ "websocket", "mplex", "yamux", "tcp", "ping", "noise", "dns", "async-std", "rsa" ], optional = true}
"""
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{ with (load_resource "./nim.toml") }}
{{ range .groups }}
[[groups]]
id = "nim-latest-{{ .Id }}"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./nim/"
[groups.build_config.build_args]
Libp2pVersion = '{{ .Id }}'
NimVersion = '{{ .NimVersion }}'
{{ end }}

{{ with .custom }}
[[groups]]
id = "nim-unstable"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./nim/"
[groups.build_config.build_args]
Libp2pVersion = '#unstable'
NimVersion = '{{ .NimVersion }}'
{{ end }}

{{ if eq $.Env.InteropTarget "nim" }}
{{ if $.Env.GitReference }}
{{ with .custom }}
[[groups]]
id = "nim-custom-{{ $.Env.GitReference }}"
instances = { count = 1 }
builder = "docker:generic"

[groups.build_config]
path = "./nim/"
[groups.build_config.build_args]
Libp2pVersion = '#{{ $.Env.GitReference }}'
NimVersion = '{{ .NimVersion }}'
{{ end }}
{{ end }}
{{ end }}
{{ end }}
6 changes: 6 additions & 0 deletions ping/_compositions/nim.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[custom]
NimVersion = "1.6.8"

[[groups]]
Id = "1.0.0"
NimVersion = "1.6.8"
14 changes: 14 additions & 0 deletions ping/nim/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG NimVersion="latest"
FROM nimlang/nim:${NimVersion}-alpine as builder

RUN nimble install -y "https://github.com/status-im/testground-nim-sdk@#c282ff68c08ef85a7ca011e077e3e69eb1a6edec"

ARG Libp2pVersion="#unstable"
RUN nimble install -y "libp2p@${Libp2pVersion}"
FROM builder

ARG PLAN_PATH="./"
COPY ./plan/${PLAN_PATH} ./plan
RUN cd plan && nimble install -dy && nim c -d:chronicles_log_level=NOTICE main.nim

ENTRYPOINT ["plan/main"]
Loading