Skip to content

Commit

Permalink
[3/3] Create github workflow to handle the SDK upgrade in processor r…
Browse files Browse the repository at this point in the history
…epo (#642)
  • Loading branch information
larry-aptos authored Jan 10, 2025
1 parent 66cbed1 commit 226b1b5
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/create-release-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Create Release Tag

on:
workflow_dispatch:
inputs:
release_type:
description: 'Type of release (patch/minor)'
required: true
type: choice
options:
- patch
- minor

jobs:
create-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all tags and branches

- name: Get latest tag and create new version
id: generate_version
run: |
# Get the latest tag that matches our pattern
latest_tag=$(git tag -l "aptos-indexer-processors-v*" | sort -V | tail -n 1)
if [ -z "$latest_tag" ]; then
# If no tags exist, start with 1.20.0.
# Last release was 1.19.1.
current_version="1.20.0"
else
# Extract version number from tag
current_version=$(echo $latest_tag | sed 's/aptos-indexer-processors-v//')
fi
# Split version into components
major=$(echo $current_version | cut -d. -f1)
minor=$(echo $current_version | cut -d. -f2)
patch=$(echo $current_version | cut -d. -f3)
# Calculate new version based on input
if [ "${{ inputs.release_type }}" = "minor" ]; then
new_version="${major}.$((minor + 1)).0"
else
new_version="${major}.${minor}.$((patch + 1))"
fi
echo "New version will be: $new_version"
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
echo "current_version=${current_version}" >> $GITHUB_OUTPUT
- name: Create and push tag
run: |
new_tag="aptos-indexer-processors-v${{ steps.generate_version.outputs.new_version }}"
git tag -a "$new_tag" -m "Release $new_tag"
git push origin "$new_tag"
# TODO: roll docker image release into this workflow.
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: aptos-indexer-processors-v${{ steps.generate_version.outputs.new_version }}
name: Release ${{ steps.generate_version.outputs.new_version }}
body: |
Automated release from ${{ steps.generate_version.outputs.current_version }} to ${{ steps.generate_version.outputs.new_version }}
Type: ${{ inputs.release_type }} release
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,37 @@ jobs:

# Run Integration Tests
- name: Run Integration Tests
id: tests
continue-on-error: true
run: |
# TODO: until we have more comprehensive cli parsers, we will need to run tests separately.
cargo test sdk_tests -- --nocapture
working-directory: rust/integration-tests

# Run all Tests
- name: Run Sanity Tests
id: sanity-check
continue-on-error: true
run: |
cargo test regression_tests -- --nocapture
working-directory: rust/integration-tests

- name: Fail if tests fail
if: ${{ steps.sanity-check.outcome == 'failure' && github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'indexer-sdk-update') }}
run: |
echo "Integration failed"
exit 1
- name: Send Slack Notification to oncall
if: ${{ steps.sanity-check.outcome == 'failure' && github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'indexer-sdk-update') }}
uses: slackapi/[email protected]
with:
# eco-infra-oncall channel.
channel-id: 'C0468USBLQJ'
slack-message: |
:warning: Tests failed on PR with indexer-sdk-update label
PR: ${{ github.event.pull_request.html_url }}
Author: ${{ github.event.pull_request.user.login }}
Title: ${{ github.event.pull_request.title }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/update-sdk-dependency.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update SDK Dependency

on:
repository_dispatch:
types: [sdk-dependency-update]
jobs:
update-the-dependency:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install toml
run: cargo install toml-cli
- name: Update the dependency
run: |
set -e
# SDK commit hash
toml set Cargo.toml workspace.dependencies.aptos-indexer-processor-sdk.rev ${{ github.event.client_payload.commit_hash }} > Cargo.tmp && mv Cargo.tmp Cargo.toml
toml set Cargo.toml workspace.dependencies.aptos-indexer-processor-sdk-server-framework.rev ${{ github.event.client_payload.commit_hash }} > Cargo.tmp && mv Cargo.tmp Cargo.toml
toml set Cargo.toml workspace.dependencies.aptos-indexer-testing-framework.rev ${{ github.event.client_payload.aptos_protos_commit_hash }} > Cargo.tmp && mv Cargo.tmp Cargo.toml
# Protos commit hash
toml set Cargo.toml workspace.dependencies.aptos-protos.rev ${{ github.event.client_payload.aptos_protos_commit_hash }} > Cargo.tmp && mv Cargo.tmp Cargo.toml
toml set Cargo.toml workspace.dependencies.aptos-indexer-test-transactions.rev ${{ github.event.client_payload.aptos_protos_commit_hash }} > Cargo.tmp && mv Cargo.tmp Cargo.toml
working-directory: rust/
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit and Push Changes
run: |
set -e
branch_name="${{ github.event.client_payload.branch_name }}-update-sdk"
git checkout -b "$branch_name"
git add Cargo.toml
git commit -m "Update sdk to ${{ github.event.client_payload.commit_hash }}"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git push origin "$branch_name" --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: rust/
- name: Create Pull Request
run: |
branch_name="${{ github.event.client_payload.branch_name }}-update-sdk"
gh pr create --title "Update sdk to upstream branch ${{ github.event.client_payload.branch_name }}" \
--body "This PR updates sdk to new version." \
--base main \
--head "$branch_name" \
--label "indexer-sdk-update"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run Integration Tests
run: cargo test --manifest-path integration-tests/Cargo.toml
working-directory: rust

0 comments on commit 226b1b5

Please sign in to comment.