Skip to content

Commit

Permalink
feat: add new implementation versions (go)
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Mar 22, 2024
1 parent 9fd3f85 commit 35eb9d5
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 185 deletions.
102 changes: 80 additions & 22 deletions .github/workflows/add-new-impl-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,114 @@ permissions:
actions: write

jobs:
go:
add:
name: Add (${{ matrix.branch }})
runs-on: ubuntu-latest
strategy:
matrix:
include:
- branch: perf/go-libp2p
workflow: perf.yml
directory: perf/impl/go-libp2p
script: |
pushd $DIRECTORY
cp -r $LOCAL_MAJOR_MINOR_VERSION $REMOTE_MAJOR_MINOR_VERSION
pushd $REMOTE_MAJOR_MINOR_VERSION
sed -i "1s/$LOCAL_MAJOR_MINOR_VERSION/$REMOTE_MAJOR_MINOR_VERSION/g" go.mod
go mod tidy -go=$GO_MAJOR_MINOR_VERSION
go mod tidy
go get github.com/libp2p/go-libp2p@$REMOTE_VERSION
popd
git add .
git commit -m "chore: add go-libp2p@$REMOTE_VERSION to $DIRECTORY"
popd
pushd perf/runner
versions="$(jq '. + map(select(.implementation == "go-libp2p" and .id == env.LOCAL_MAJOR_MINOR_VERSION) | .id = env.REMOTE_MAJOR_MINOR_VERSION)' versionsInput.json)"
echo "$versions" > versionsInput.json
git add versionsInput.json
git commit -m "chore: add go-libp2p@$REMOTE_VERSION to versionsInput.json"
popd
- branch: transport-interop/go-libp2p
workflow: transport-interop.yml
directory: transport-interop/impl/go
script: |
pushd $DIRECTORY
cp -r $LOCAL_MAJOR_MINOR_VERSION $REMOTE_MAJOR_MINOR_VERSION
pushd $REMOTE_MAJOR_MINOR_VERSION
sed -i "s/image_name := go-${LOCAL_MAJOR_MINOR_VERSION}/image_name := go-${REMOTE_MAJOR_MINOR_VERSION}/g" Makefile
sed -i "s/version := ${LOCAL_MAJOR_MINOR_VERSION#v}\..*/version := ${REMOTE_VERSION#v}/g" Makefile
make version.lock
popd
git add .
git commit -m "chore: add go-libp2p@$REMOTE_VERSION to $DIRECTORY"
popd
pushd transport-interop
versions="$(jq '. + map(select(.id == "go-\(env.LOCAL_MAJOR_MINOR_VERSION)") | .id = "go-\(env.REMOTE_MAJOR_MINOR_VERSION)")' versionsInput.json)"
echo "$versions" > versionsInput.json
git add versionsInput.json
git commit -m "chore: add go-libp2p@$REMOTE_VERSION to versionsInput.json"
popd
env:
DIR: perf/impl/go-libp2p
REPO: libp2p/go-libp2p
BRANCH: perf/go-libp2p
BRANCH: ${{ matrix.branch }}
WORKFLOW: ${{ matrix.workflow }}
DIRECTORY: ${{ matrix.directory }}
steps:
- name: Checkout test-plans
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Configure git
run: |
git fetch origin $BRANCH && git checkout $BRANCH || git checkout -b $BRANCH
git rebase $GITHUB_REF -X theirs || git rebase --abort
git config --global user.email $GITHUB_ACTOR@users.noreply.github.com
git config --global user.name $GITHUB_ACTOR
- id: go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: stable
- name: Get the latest version (local)
id: local
run: ls -d v* | sort -V | tail -n-1 | xargs -I{} echo "version={}" | tee -a $GITHUB_OUTPUT
working-directory: ${{ env.DIR }}
working-directory: ${{ env.DIRECTORY }}
- name: Get the latest version (remote)
id: remote
env:
GITHUB_TOKEN: ${{ github.token }}
run: gh api repos/$REPO/releases/latest --jq '.tag_name' | xargs -I{} echo "version={}" | tee -a $GITHUB_OUTPUT
run: gh api repos/libp2p/go-libp2p/releases/latest --jq '.tag_name' | xargs -I{} echo "version={}" | tee -a $GITHUB_OUTPUT
- id: mm
env:
REMOTE_VERSION: ${{ steps.remote.outputs.version }}
GO_VERSION: ${{ steps.go.outputs.go-version }}
run: |
echo $REMOTE_VERSION | sed 's/\.[0-9]*$//' | xargs -I{} echo "remote={}" | tee -a $GITHUB_OUTPUT
echo $GO_VERSION | sed 's/\.[0-9]*$//' | xargs -I{} echo "go={}" | tee -a $GITHUB_OUTPUT
- name: Add the latest version
if: ${{ !startsWith(steps.remote.outputs.version, steps.local.outputs.version) }}
env:
LOCAL_VERSION: ${{ steps.local.outputs.version }}
LOCAL_MAJOR_MINOR_VERSION: ${{ steps.local.outputs.version }}
REMOTE_VERSION: ${{ steps.remote.outputs.version }}
REMOTE_MAJOR_MINOR_VERSION: ${{ steps.mm.outputs.remote }}
GO_VERSION: ${{ steps.go.outputs.go-version }}
GO_MAJOR_MINOR_VERSION: ${{ steps.mm.outputs.go }}
run: ${{ matrix.script }}
- if: ${{ !startsWith(steps.remote.outputs.version, steps.local.outputs.version) }}
env:
REMOTE_VERSION: ${{ steps.remote.outputs.version }}
GITHUB_TOKEN: ${{ github.token }}
run: |
majorMinorRemoteVersion=$(echo $REMOTE_VERSION | sed 's/\.[0-9]*$//')
majorMinorGoVersion=$(echo $GO_VERSION | sed 's/\.[0-9]*$//')
cp -r $LOCAL_VERSION $majorMinorRemoteVersion
cd $majorMinorRemoteVersion
sed -i "1s/$LOCAL_VERSION/$majorMinorRemoteVersion/g" go.mod
go mod tidy -go=$majorMinorGoVersion
go mod tidy
go get github.com/libp2p/go-libp2p@$REMOTE_VERSION
git add .
git commit -m "chore: add go-libp2p@$REMOTE_VERSION to $DIR"
# push the changes
git push origin $BRANCH --force
# create a PR if an open one doesn't exist yet
if [[ $(gh pr list --state open --base $GITHUB_REF --head $BRANCH | wc -l) -eq 0 ]]; then
gh pr create --title "chore: add go-libp2p@$REMOTE_VERSION to $DIR" --body "This PR adds go-libp2p@$REMOTE_VERSION to $DIR" --head $BRANCH --base $GITHUB_REF
gh pr create --title "chore: add go-libp2p@$REMOTE_VERSION for $WORKFLOW" --body "This PR adds go-libp2p@$REMOTE_VERSION for $WORKFLOW" --head $BRANCH --base $GITHUB_REF
fi
gh workflow run perf.yml --ref $BRANCH
working-directory: ${{ env.DIR }}
gh workflow run $WORKFLOW --ref $BRANCH
51 changes: 4 additions & 47 deletions perf/runner/src/versions.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,10 @@
import fs from 'fs';
import path from 'path';

export type Version = {
id: string,
implementation: "go-libp2p" | "js-libp2p" | "nim-libp2p" | "rust-libp2p" | "zig-libp2p" | "https" | "quic-go",
transportStacks: string[],
}

export const versions: Array<Version> = [
{
id: "v0.34",
implementation: "quic-go",
transportStacks: ["quic-v1"]
},
{
id: "v0.53",
implementation: "rust-libp2p",
transportStacks: ["tcp", "quic-v1"]
},
{
id: "v0.1",
implementation: "https",
transportStacks: ["tcp"]
},
{
id: "v0.27",
implementation: "go-libp2p",
transportStacks: ["tcp", "quic-v1"]
},
{
id: "v0.28",
implementation: "go-libp2p",
transportStacks: ["tcp", "quic-v1"]
},
{
id: "v0.29",
implementation: "go-libp2p",
transportStacks: ["tcp", "quic-v1"]
},
{
id: "v0.31",
implementation: "go-libp2p",
transportStacks: ["tcp", "quic-v1"]
},
{
id: "v0.46",
implementation: "js-libp2p",
transportStacks: ["tcp"]
},
{
id: "v1.0",
implementation: "js-libp2p",
transportStacks: ["tcp"]
},
]
export const versions: Array<Version> = JSON.parse(fs.readFileSync(path.join(__dirname, '../versionsInput.json'), 'utf8'));
70 changes: 70 additions & 0 deletions perf/runner/versionsInput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[
{
"id": "v0.34",
"implementation": "quic-go",
"transportStacks": [
"quic-v1"
]
},
{
"id": "v0.53",
"implementation": "rust-libp2p",
"transportStacks": [
"tcp",
"quic-v1"
]
},
{
"id": "v0.1",
"implementation": "https",
"transportStacks": [
"tcp"
]
},
{
"id": "v0.27",
"implementation": "go-libp2p",
"transportStacks": [
"tcp",
"quic-v1"
]
},
{
"id": "v0.28",
"implementation": "go-libp2p",
"transportStacks": [
"tcp",
"quic-v1"
]
},
{
"id": "v0.29",
"implementation": "go-libp2p",
"transportStacks": [
"tcp",
"quic-v1"
]
},
{
"id": "v0.31",
"implementation": "go-libp2p",
"transportStacks": [
"tcp",
"quic-v1"
]
},
{
"id": "v0.46",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v1.0",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
}
]
125 changes: 9 additions & 116 deletions transport-interop/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,119 +49,12 @@ function browserImageIDLookup(id: string): string {
return imageID
}

export const versions: Array<Version> = [
{
id: "rust-v0.51",
transports: ["ws", "tcp", "quic-v1", "webrtc-direct"],
secureChannels: ["tls", "noise"],
muxers: ["mplex", "yamux"],
},
{
id: "rust-v0.52",
transports: ["ws", "tcp", "quic-v1", "webrtc-direct"],
secureChannels: ["tls", "noise"],
muxers: ["mplex", "yamux"],
},
{
id: "rust-v0.53",
transports: ["ws", "tcp", "quic-v1", "webrtc-direct"],
secureChannels: ["tls", "noise"],
muxers: ["mplex", "yamux"],
},
// {
// id: "rust-chromium-v0.52",
// transports: [{ name: "webtransport", onlyDial: true }],
// secureChannels: [],
// muxers: [],
// },
{
id: "rust-chromium-v0.53",
"transports": [
{ "name": "webtransport", "onlyDial": true },
{ "name": "webrtc-direct", "onlyDial": true },
{ "name": "ws", "onlyDial": true }
],
"secureChannels": ["noise"],
"muxers": ["mplex", "yamux"]
},
{
id: "js-v0.45",
transports: ["tcp", "ws", { name: "wss", onlyDial: true }],
secureChannels: ["noise"],
muxers: ["mplex", "yamux"],
},
{
id: "js-v0.46",
transports: ["tcp", "ws", { name: "wss", onlyDial: true }],
secureChannels: ["noise"],
muxers: ["mplex", "yamux"],
},
{
id: "chromium-js-v0.46",
containerImageID: browserImageIDLookup,
transports: [{ name: "webtransport", onlyDial: true }, { name: "wss", onlyDial: true }, { name: "webrtc-direct", onlyDial: true }, "webrtc"],
secureChannels: ["noise"],
muxers: ["mplex", "yamux"],
},
{
id: "firefox-js-v0.46",
containerImageID: browserImageIDLookup,
transports: [{ name: "wss", onlyDial: true }, { name: "webrtc-direct", onlyDial: true }, "webrtc"],
secureChannels: ["noise"],
muxers: ["mplex", "yamux"],
},
{
id: "go-v0.33",
transports: ["tcp", "ws", "quic-v1", "webtransport", "webrtc-direct"],
secureChannels: ["tls", "noise"],
muxers: ["yamux"],
},
{
id: "go-v0.32",
transports: ["tcp", "ws", "quic-v1", "webtransport", "webrtc-direct"],
secureChannels: ["tls", "noise"],
muxers: ["yamux"],
},
{
id: "go-v0.31",
transports: ["tcp", "ws", "quic-v1", "webtransport"],
secureChannels: ["tls", "noise"],
muxers: ["yamux"],
},
{
id: "go-v0.30",
transports: ["tcp", "ws", "quic-v1", "webtransport"],
secureChannels: ["tls", "noise"],
muxers: ["yamux"],
},
{
id: "go-v0.29",
transports: ["tcp", "ws", "quic", "quic-v1", "webtransport"],
secureChannels: ["tls", "noise"],
muxers: ["mplex", "yamux"],
},
{
id: "nim-v1.0",
transports: ["tcp", "ws"],
secureChannels: ["noise"],
muxers: ["mplex", "yamux"],
},
{
id: "zig-v0.0.1",
transports: ["quic-v1"],
secureChannels: [],
muxers: [],
},
{
id: "java-v0.0.1",
transports: ["tcp"],
secureChannels: ["tls", "noise"],
muxers: ["mplex", "yamux"],
},
{
id: "java-v0.6",
transports: ["tcp"],
secureChannels: ["tls", "noise"],
muxers: ["mplex", "yamux"],
},
].map((v: Version) => (typeof v.containerImageID === "undefined" ? ({ ...v, containerImageID: canonicalImageIDLookup }) : v))
export const versions: Array<Version> = JSON.parse(fs.readFileSync(path.join(__dirname, 'versionsInput.json') , 'utf8')).map((v: Version) => {
switch(v.containerImageID) {
case "browser":
return { ...v, containerImageID: browserImageIDLookup }
case "canonical":
default:
return { ...v, containerImageID: canonicalImageIDLookup }
}
});
Loading

0 comments on commit 35eb9d5

Please sign in to comment.