From 446cf46b7da4c233ba9abebecc8e6e88849a8816 Mon Sep 17 00:00:00 2001 From: Tanguy Date: Tue, 8 Nov 2022 14:28:51 +0100 Subject: [PATCH] Add CI --- .github/workflows/ping-interop-all.yml | 45 +++++ ping/_compositions/all-interop-latest.toml | 2 +- ping/_compositions/all-interop.toml | 186 +++++++++++++++++++++ 3 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ping-interop-all.yml create mode 100644 ping/_compositions/all-interop.toml diff --git a/.github/workflows/ping-interop-all.yml b/.github/workflows/ping-interop-all.yml new file mode 100644 index 0000000..afd3f91 --- /dev/null +++ b/.github/workflows/ping-interop-all.yml @@ -0,0 +1,45 @@ +on: + 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 - go and rust test (all) 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 }} diff --git a/ping/_compositions/all-interop-latest.toml b/ping/_compositions/all-interop-latest.toml index 22852df..c0f4051 100644 --- a/ping/_compositions/all-interop-latest.toml +++ b/ping/_compositions/all-interop-latest.toml @@ -1,5 +1,5 @@ [metadata] - name = "go-rust-cross-version-{{ or $.Env.InteropTarget "-" }}-{{ or $.Env.GitReference "" }}" + name = "all-latest-{{ or $.Env.InteropTarget "-" }}-{{ or $.Env.GitReference "" }}" [global] plan = "libp2p/ping" diff --git a/ping/_compositions/all-interop.toml b/ping/_compositions/all-interop.toml new file mode 100644 index 0000000..f57ef2c --- /dev/null +++ b/ping/_compositions/all-interop.toml @@ -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 }}