-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: automate adding new go-libp2p versions to perf #256
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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: | ||
go: | ||
runs-on: ubuntu-latest | ||
env: | ||
DIR: perf/impl/go-libp2p | ||
REPO: libp2p/go-libp2p | ||
BRANCH: perf/go-libp2p | ||
steps: | ||
- name: Checkout test-plans | ||
uses: actions/checkout@v3 | ||
- name: Configure git | ||
run: | | ||
git fetch $BRANCH && git checkout $BRANCH && git rebase $GITHUB_REF -X theirs || git checkout -b $BRANCH | ||
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 | ||
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 }} | ||
- 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 | ||
- name: Add the latest version | ||
if: ${{ !startsWith(steps.remote.outputs.version, steps.local.outputs.version) }} | ||
env: | ||
LOCAL_VERSION: ${{ steps.local.outputs.version }} | ||
REMOTE_VERSION: ${{ steps.remote.outputs.version }} | ||
GO_VERSION: ${{ steps.go.outputs.go-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" | ||
git push origin $BRANCH --force | ||
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 workflow run perf.yml --ref $BRANCH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙏 |
||
working-directory: ${{ env.DIR }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
perf | ||
.cache | ||
v0.28 | ||
galargh marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,10 @@ GO_FILES := $(wildcard *.go) | |
all: perf | ||
|
||
perf: $(GO_FILES) | ||
docker run --rm --user "$(shell id -u):$(shell id -g)" -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp -e GOCACHE=/usr/src/myapp/.cache golang:1.20 go build -o perf . | ||
docker run --rm --user "$(shell id -u):$(shell id -g)" -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp -e GOCACHE=/usr/src/myapp/.cache golang:$(shell awk '/^go [0-9]+(\.[0-9]+)?$$/ {print $$2}' go.mod) go build -o perf . | ||
galargh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
clean: | ||
rm perf | ||
rm .cache | ||
rm v0.28 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is created when one runs |
||
|
||
.PHONY: all clean |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered using
go list -m -versions github.com/libp2p/go-libp2p@latest
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, didn't know about this one. If you prefer, this should behave the same.