Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7
Comment thread
pcaversaccio marked this conversation as resolved.
groups:
github-actions:
patterns:
- "*"
51 changes: 36 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@ on:
inputs:
tag:
default: ''
type: string
push:
branches:
- master
pull_request:
release:
types: [published] # releases and pre-releases (release candidates)

permissions:
contents: read

env:
PYTHON_VERSION: "3.12"

defaults:
run:
shell: bash

jobs:
unix-build:
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
matrix:
os:
Expand All @@ -29,22 +37,22 @@ jobs:
- macos-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
# grab the commit passed in via `tag`, if any
ref: ${{ github.event.inputs.tag }}
# need to fetch unshallow so that setuptools_scm can infer the version
fetch-depth: 0
persist-credentials: false

# debug
- name: Git shorthash
run: git rev-parse --short HEAD

- name: Python
uses: actions/setup-python@v6
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.11"
cache: "pip"
python-version: ${{ env.PYTHON_VERSION }}

- name: Generate Binary
run: |
Expand All @@ -58,31 +66,32 @@ jobs:


- name: Upload Artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: vyper-${{ runner.os }}
path: dist/vyper.*

windows-build:
runs-on: windows-latest
timeout-minutes: 45

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
# grab the commit passed in via `tag`, if any
ref: ${{ github.event.inputs.tag }}
# need to fetch unshallow so that setuptools_scm can infer the version
fetch-depth: 0
persist-credentials: false

# debug
- name: Git shorthash
run: git rev-parse --short HEAD

- name: Python
uses: actions/setup-python@v6
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.11"
cache: "pip"
python-version: ${{ env.PYTHON_VERSION }}

- name: Generate Binary
run: >-
Expand All @@ -91,7 +100,7 @@ jobs:
./make.cmd freeze

- name: Upload Artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: vyper-${{ runner.os }}
path: dist/vyper.*
Expand All @@ -100,34 +109,46 @@ jobs:
needs: [windows-build, unix-build]
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
# Upload generated binaries to the GitHub release.
contents: write

steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: artifacts/
merge-multiple: true

- name: Upload assets
working-directory: artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
RELEASE_ID: ${{ github.event.release.id }}
run: |
set -Eeuxo pipefail
set -Eeuo pipefail
for BIN_NAME in $(ls)
do
curl -L \
--no-progress-meter \
-X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "Authorization: Bearer ${GH_TOKEN}"\
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=${BIN_NAME/+/%2B}" \
"https://uploads.github.com/repos/${REPOSITORY}/releases/${RELEASE_ID}/assets?name=${BIN_NAME/+/%2B}" \
--data-binary "@${BIN_NAME}"
done

# check build success for pull requests
build-success:
if: always()
runs-on: ubuntu-latest
timeout-minutes: 45
needs: [windows-build, unix-build]
permissions: {}
steps:
- name: check that all builds succeeded
if: ${{ contains(needs.*.result, 'failure') }}
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/bytecode-size-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Bytecode Size PR Comment

on:
workflow_run: # zizmor: ignore[dangerous-triggers] Comment-only follow-up; never checks out or executes PR code.
workflows: ["Bytecode Size Report"]
types: [completed]

permissions: {}

jobs:
comment:
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
# Download the report artifact from the completed measurement run.
actions: read
# Required by artifact download and workflow run metadata reads.
contents: read
# Update only the benchmark report comment on the pull request.
pull-requests: write
steps:
- name: Download report
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: bytecode-size-report
path: report
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Post or update PR comment
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const fs = require('fs');
const marker = '<!-- bytecode-size-report -->';
const report = fs.readFileSync('report/report.md', 'utf8');
const body = marker + '\n\n' + report;
const workflowRun = context.payload.workflow_run;
let issue_number = (workflowRun.pull_requests || []).find(pr => pr.number)?.number;
if (!issue_number) {
const headOwner = workflowRun.head_repository?.owner?.login;
const headBranch = workflowRun.head_branch;
if (!headOwner || !headBranch) {
core.info('Could not resolve pull request for workflow run.');
return;
}
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${headOwner}:${headBranch}`
});
const pull = pulls.find(pr => pr.head.sha === workflowRun.head_sha) || pulls[0];
if (!pull) {
core.info(`No open pull request found for ${headOwner}:${headBranch}.`);
return;
}
issue_number = pull.number;
}
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number
});
const existing = comments.find(c => c.body.includes(marker));
if (existing) {
return github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body
});
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number,
body
});
85 changes: 14 additions & 71 deletions .github/workflows/bytecode-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,43 @@ name: Bytecode Size Report
on:
pull_request:
branches: [master]
pull_request_target:
branches: [master]

permissions:
contents: read
pull-requests: write

env:
PYTHON_VERSION: "3.12"

jobs:
bytecode-size:
# pull_request: untrusted contributors only (step summary, no comment)
# pull_request_target: trusted contributors only (step summary + comment)
if: |
(github.event_name == 'pull_request' && !contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association)) ||
(github.event_name == 'pull_request_target' && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association))
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Invalidate existing comment
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v7
with:
script: |
const marker = '<!-- bytecode-size-report -->';
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number
});
const existing = comments.find(c => c.body.includes(marker));
if (!existing) return;
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: marker + '\n\n⏳ **Recalculating bytecode sizes...**'
});

- name: Checkout merge commit
uses: actions/checkout@v6
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
path: head
fetch-depth: 0
fetch-tags: true
persist-credentials: false

- name: Checkout base
uses: actions/checkout@v6
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.base_ref }}
path: base
fetch-depth: 0
fetch-tags: true
persist-credentials: false

- name: Copy scripts to base
run: cp -r head/.github/scripts base/.github/

- name: Set up Python
uses: actions/setup-python@v6
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.12"
python-version: ${{ env.PYTHON_VERSION }}

- name: Install vyper (base)
working-directory: base
Expand All @@ -80,50 +58,15 @@ jobs:
run: python .github/scripts/measure_bytecode.py > ../head-sizes.json

- name: Generate report
id: report
run: |
python3 head/.github/scripts/compare_bytecode.py base-sizes.json head-sizes.json > report.md
cat report.md >> "$GITHUB_STEP_SUMMARY"
{
echo 'REPORT<<EOF'
cat report.md
echo 'EOF'
} >> "$GITHUB_OUTPUT"

- name: Post or update PR comment
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v7
with:
script: |
const marker = '<!-- bytecode-size-report -->';
const body = marker + '\n\n' + process.env.REPORT;
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number
});
const existing = comments.find(c => c.body.includes(marker));
if (existing) {
return github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: body
});
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: body
});
env:
REPORT: ${{ steps.report.outputs.REPORT }}

- name: Upload size data
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: bytecode-sizes
name: bytecode-size-report
path: |
base-sizes.json
head-sizes.json
report.md
Loading