2023-09-02 10:16:35 +02:00
|
|
|
name: Add new implementation versions
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
schedule:
|
|
|
|
# “At minute 36 past every 24th hour.” - https://crontab.guru/#36_*/24_*_*_*
|
|
|
|
- cron: '36 */24 * * *'
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
pull-requests: write
|
|
|
|
actions: write
|
|
|
|
|
|
|
|
jobs:
|
2024-03-26 17:13:03 +00:00
|
|
|
add:
|
|
|
|
name: Add new ${{ matrix.repository_name }} version to ${{ matrix.test_name }}
|
2023-09-02 10:16:35 +02:00
|
|
|
runs-on: ubuntu-latest
|
2024-03-26 17:13:03 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- repository_name: go-libp2p
|
|
|
|
implementation_name: go-libp2p
|
|
|
|
test_name: perf
|
|
|
|
implementation_update_script: |
|
|
|
|
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
|
|
|
|
- repository_name: go-libp2p
|
|
|
|
implementation_name: go
|
|
|
|
test_name: transport-interop
|
|
|
|
implementation_update_script: |
|
|
|
|
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
|
|
|
|
- repository_name: rust-libp2p
|
|
|
|
implementation_name: rust-libp2p
|
|
|
|
test_name: perf
|
|
|
|
implementation_update_script: |
|
|
|
|
sed -i "s/commitSha := .*/commitSha := ${REMOTE_SHA}/g" Makefile
|
|
|
|
- repository_name: rust-libp2p
|
|
|
|
implementation_name: rust
|
|
|
|
test_name: transport-interop
|
|
|
|
implementation_update_script: |
|
|
|
|
sed -i "s/image_name := rust-${LOCAL_MAJOR_MINOR_VERSION}/image_name := rust-${REMOTE_MAJOR_MINOR_VERSION}/g" Makefile
|
|
|
|
sed -i "s/commitSha := .*/commitSha := ${REMOTE_SHA}/g" Makefile
|
|
|
|
- repository_name: js-libp2p
|
|
|
|
implementation_name: js-libp2p
|
|
|
|
test_name: perf
|
|
|
|
implementation_update_script: |
|
|
|
|
suffix="$(echo "${REMOTE_MAJOR_MINOR_VERSION#v}" | sed 's/\./-/g')"
|
|
|
|
sed -i "s/perf-js-libp2p-[^\"]*/perf-js-libp2p-$suffix/g" package.json
|
|
|
|
npm install libp2p@$REMOTE_VERSION
|
|
|
|
- repository_name: js-libp2p
|
|
|
|
implementation_name: js
|
|
|
|
test_name: transport-interop
|
|
|
|
implementation_update_script: |
|
|
|
|
sed -i "s/image_name := js-${LOCAL_MAJOR_MINOR_VERSION}\..*/image_name := js-${REMOTE_VERSION}/g" Makefile
|
|
|
|
npm install libp2p@$REMOTE_VERSION
|
2023-09-02 10:16:35 +02:00
|
|
|
env:
|
2024-03-26 17:13:03 +00:00
|
|
|
BRANCH: add/${{ matrix.test_name }}/${{ matrix.repository_name }}
|
2023-09-02 10:16:35 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout test-plans
|
2024-03-26 17:13:03 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-09-02 10:16:35 +02:00
|
|
|
- name: Configure git
|
|
|
|
run: |
|
2023-09-04 09:40:32 +02:00
|
|
|
git fetch origin $BRANCH && git checkout $BRANCH || git checkout -b $BRANCH
|
|
|
|
git rebase $GITHUB_REF -X theirs || git rebase --abort
|
2023-09-02 10:16:35 +02:00
|
|
|
git config --global user.email $GITHUB_ACTOR@users.noreply.github.com
|
|
|
|
git config --global user.name $GITHUB_ACTOR
|
|
|
|
- id: go
|
2024-03-26 17:13:03 +00:00
|
|
|
uses: actions/setup-go@v5
|
2023-09-02 10:16:35 +02:00
|
|
|
with:
|
|
|
|
go-version: stable
|
|
|
|
- name: Get the latest version (local)
|
|
|
|
id: local
|
2024-03-26 17:13:03 +00:00
|
|
|
env:
|
|
|
|
IMPLEMENTATION_DIRECTORY: ${{ matrix.test_name }}/impl/${{ matrix.implementation_name }}
|
|
|
|
run: |
|
|
|
|
pushd $IMPLEMENTATION_DIRECTORY
|
|
|
|
ls -d v* | sort -V | tail -n-1 | xargs -I{} echo "version={}" | tee -a $GITHUB_OUTPUT
|
|
|
|
popd
|
2023-09-02 10:16:35 +02:00
|
|
|
- name: Get the latest version (remote)
|
|
|
|
id: remote
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
2024-03-26 17:13:03 +00:00
|
|
|
REPOSITORY_NAME: ${{ matrix.repository_name }}
|
|
|
|
run: |
|
|
|
|
releases="$(gh api --paginate repos/libp2p/$REPOSITORY_NAME/releases)"
|
|
|
|
latest="$(jq 'map(select(.tag_name | startswith("libp2p-"))) | first' <<< "$releases")"
|
|
|
|
if [[ "$latest" == "null" ]]; then
|
|
|
|
latest="$(jq 'first' <<< "$releases")"
|
|
|
|
fi
|
|
|
|
tag_name=$(jq -r '.tag_name' <<< "$latest")
|
|
|
|
target_commitish=$(jq -r '.target_commitish' <<< "$latest")
|
|
|
|
echo "version=${tag_name#libp2p-}" | tee -a $GITHUB_OUTPUT
|
|
|
|
echo "target_commitish=${target_commitish}" | 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
|
2023-09-02 10:16:35 +02:00
|
|
|
- name: Add the latest version
|
|
|
|
if: ${{ !startsWith(steps.remote.outputs.version, steps.local.outputs.version) }}
|
|
|
|
env:
|
2024-03-26 17:13:03 +00:00
|
|
|
LOCAL_MAJOR_MINOR_VERSION: ${{ steps.local.outputs.version }}
|
2023-09-02 10:16:35 +02:00
|
|
|
REMOTE_VERSION: ${{ steps.remote.outputs.version }}
|
2024-03-26 17:13:03 +00:00
|
|
|
REMOTE_MAJOR_MINOR_VERSION: ${{ steps.mm.outputs.remote }}
|
|
|
|
REMOTE_SHA: ${{ steps.remote.outputs.sha }}
|
2023-09-02 10:16:35 +02:00
|
|
|
GO_VERSION: ${{ steps.go.outputs.go-version }}
|
2024-03-26 17:13:03 +00:00
|
|
|
GO_MAJOR_MINOR_VERSION: ${{ steps.mm.outputs.go }}
|
2023-09-02 10:16:35 +02:00
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
2024-03-26 17:13:03 +00:00
|
|
|
IMPLEMENTATION_DIRECTORY: ${{ matrix.test_name }}/impl/${{ matrix.implementation_name }}
|
|
|
|
VERSIONS_DIRECTORY: ${{ matrix.test_name == 'perf' && format('{0}/runner', matrix.test_name) || matrix.test_name }}
|
|
|
|
IMPLEMENTATION_NAME: ${{ matrix.implementation_name }}
|
|
|
|
REPOSITORY_NAME: ${{ matrix.repository_name }}
|
|
|
|
TEST_NAME: ${{ matrix.test_name }}
|
2023-09-02 10:16:35 +02:00
|
|
|
run: |
|
2024-03-26 17:13:03 +00:00
|
|
|
pushd $IMPLEMENTATION_DIRECTORY
|
|
|
|
cp -r $LOCAL_MAJOR_MINOR_VERSION $REMOTE_MAJOR_MINOR_VERSION
|
|
|
|
pushd $REMOTE_MAJOR_MINOR_VERSION
|
|
|
|
${{ matrix.implementation_update_script }}
|
|
|
|
popd
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd $VERSIONS_DIRECTORY
|
|
|
|
versions=''
|
|
|
|
if [[ "$TEST_NAME" == "perf" ]]; then
|
|
|
|
versions="$(jq '. + map(select(.implementation == env.IMPLEMENTATION_NAME and .id == env.LOCAL_MAJOR_MINOR_VERSION) | .id = env.REMOTE_MAJOR_MINOR_VERSION)' versionsInput.json)"
|
|
|
|
else
|
|
|
|
versions="$(jq '. + map(select(.id == "\(env.IMPLEMENTATION_NAME)-\(env.LOCAL_MAJOR_MINOR_VERSION)") | .id = "\(env.IMPLEMENTATION_NAME)-\(env.REMOTE_MAJOR_MINOR_VERSION)")' versionsInput.json)"
|
|
|
|
fi
|
|
|
|
echo "$versions" > versionsInput.json
|
|
|
|
popd
|
|
|
|
|
2023-09-02 10:16:35 +02:00
|
|
|
git add .
|
2024-03-26 17:13:03 +00:00
|
|
|
git commit -m "chore: add $REPOSITORY_NAME@$REMOTE_VERSION to $TEST_NAME"
|
|
|
|
|
2023-09-02 10:16:35 +02:00
|
|
|
git push origin $BRANCH --force
|
2024-03-26 17:13:03 +00:00
|
|
|
|
2023-09-04 09:40:32 +02:00
|
|
|
if [[ $(gh pr list --state open --base $GITHUB_REF --head $BRANCH | wc -l) -eq 0 ]]; then
|
2024-03-26 17:13:03 +00:00
|
|
|
gh pr create --title "chore: add $REPOSITORY_NAME@$REMOTE_VERSION to $TEST_NAME" --body "This PR adds $REPOSITORY_NAME@$REMOTE_VERSION to $TEST_NAME" --head $BRANCH --base $GITHUB_REF
|
|
|
|
fi
|
|
|
|
|
2024-03-26 17:16:34 +00:00
|
|
|
gh workflow run $TEST_NAME.yml --ref $BRANCH
|