Skip to content

Commit

Permalink
feat(ci): trigger native_blockifier build directly
Browse files Browse the repository at this point in the history
Signed-off-by: Dori Medini <dori@starkware.co>
  • Loading branch information
dorimedini-starkware committed Dec 18, 2024
1 parent dd0473f commit 79eba72
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 96 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/trigger _workflow.yml

This file was deleted.

119 changes: 75 additions & 44 deletions .github/workflows/upload_artifacts_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
name: Upload-Artifacts

on:
workflow_run:
workflows: [Trigger-Workflow]
types: [completed]
push:
branches:
- main
- main-v[0-9].**
tags:
- v[0-9].**

pull_request:
types:
- opened
- reopened
- synchronize
- auto_merge_enabled
- edited
paths:
# Other than code-related changes, all changes related to the native-blockifier build-and-push
# process should trigger the build (e.g., changes to the Dockerfile, build scripts, etc.).
- '.github/workflows/blockifier_ci.yml'
- '.github/workflows/upload_artifacts_workflow.yml'
- 'build_native_in_docker.sh'
- 'Cargo.lock'
- 'Cargo.toml'
- 'crates/blockifier/**'
- 'crates/native_blockifier/**'
- 'scripts/build_native_blockifier.sh'
- 'scripts/dependencies.sh'
- 'scripts/install_build_tools.sh'
- 'scripts/sequencer-ci.Dockerfile'

# On PR events, cancel existing CI runs on this same PR for this workflow.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
RUSTFLAGS: "-D warnings -C link-arg=-fuse-ld=lld"
Expand All @@ -12,60 +42,61 @@ jobs:
native-blockifier-artifacts-push:
runs-on: starkware-ubuntu-latest-medium
steps:
- uses: actions/checkout@v4

# Commit hash on pull request event would be the head commit of the branch.
- name: Get commit hash prefix for PR update
if: ${{ github.event_name == 'pull_request' }}
env:
COMMIT_SHA: ${{ github.event.workflow_run.head_commit.id }}
run: |
echo "SHORT_HASH=${COMMIT_SHA:0:7}" >> $GITHUB_ENV
echo "COMMIT_SHA=${COMMIT_SHA}" >> $GITHUB_ENV
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
run: echo "SHORT_HASH=${COMMIT_SHA:0:7}" >> $GITHUB_ENV

# This workflow is always triggered in `main` branch context, so need to checkout the commit.
- uses: actions/checkout@v4
with:
ref: ${{ env.COMMIT_SHA }}
# On push event (to main, for example) we should take the commit post-push.
- name: Get commit hash prefix for merge
if: ${{ github.event_name != 'pull_request' }}
env:
COMMIT_SHA: ${{ github.event.after }}
run: echo "SHORT_HASH=${COMMIT_SHA:0:7}" >> $GITHUB_ENV

# Set environment variables.
- name: Set environment variable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr_number=$(gh pr list --head "${{ github.event.workflow_run.head_branch }}" --json number --jq '.[0].number')
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
echo "WORKFLOW_LINK=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
# Comment with a link to the workflow (or update existing comment on rerun).
# Required, as this is a triggered workflow, and does not appear on the PR status page.
- name: Find Comment
if: env.PR_NUMBER != ''
uses: starkware-libs/find-comment@v3
id: find-comment
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ env.PR_NUMBER }}
comment-author: 'github-actions[bot]'
body-includes: Artifacts upload workflows
# # Comment with a link to the workflow (or update existing comment on rerun).
# - name: Find Comment
# if: github.event_name == 'pull_request'
# uses: starkware-libs/find-comment@v3
# id: find-comment
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# issue-number: ${{ github.event.pull_request.number }}
# comment-author: 'github-actions[bot]'
# body-includes: Artifacts upload workflows

- name: Create comment
# If the PR number is found and the comment is not found, create a new comment.
if: env.PR_NUMBER != '' && steps.find-comment.outputs.comment-id == ''
uses: starkware-libs/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ env.PR_NUMBER }}
body: |
Artifacts upload workflows:
* [Started at ${{ github.event.workflow_run.run_started_at }}](${{ env.WORKFLOW_LINK }})
# - name: Create comment
# # If the PR number is found and the comment is not found, create a new comment.
# if: github.event_name == 'pull_request' && steps.find-comment.outputs.comment-id == ''
# uses: starkware-libs/create-or-update-comment@v4
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# issue-number: ${{ github.event.pull_request.number }}
# body: |
# Artifacts upload workflows:
# * [Started at ${{ github.event.pull_request.updated_at }}](${{ env.WORKFLOW_LINK }})

- name: Update comment
# If the PR number is found and the comment exists, update it.
if: env.PR_NUMBER != '' && steps.find-comment.outputs.comment-id != ''
uses: starkware-libs/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: append
body: |
* [Started at ${{ github.event.workflow_run.run_started_at }}](${{ env.WORKFLOW_LINK }})
# - name: Update comment
# # If the PR number is found and the comment exists, update it.
# if: github.event_name == 'pull_request' && steps.find-comment.outputs.comment-id != ''
# uses: starkware-libs/create-or-update-comment@v4
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# comment-id: ${{ steps.find-comment.outputs.comment-id }}
# edit-mode: append
# body: |
# * [Started at ${{ github.event.pull_request.updated_at }}](${{ env.WORKFLOW_LINK }})

# Build artifact.
- uses: ./.github/actions/bootstrap
Expand Down

0 comments on commit 79eba72

Please sign in to comment.