diff --git a/.github/workflows/check-protos.yaml b/.github/workflows/check-protos.yaml deleted file mode 100644 index e3f9ac69c8154..0000000000000 --- a/.github/workflows/check-protos.yaml +++ /dev/null @@ -1,72 +0,0 @@ -# This workflow exists to make sure that we know when the protos and the generated code -# are out of sync. In this workflow we generate code from the protos and make sure it -# matches what is checked in. - -# To make this much faster we don't use our own rust setup script. There is no need -# right now because the packages we're installing work fine with the latest version -# of Rust, at least at the time of writing. Famous last words of course, it's possible -# that the preinstalled version of the toolchain will break this at some point, but -# that probably won't happen for quite a while. - -name: "Check Protos" -on: - pull_request: - types: [labeled, opened, synchronize, reopened, auto_merge_enabled] - push: - branches: - - main - -# Cancel redundant builds. -concurrency: - # For push and workflow_dispatch events we use `github.sha` in the concurrency group and don't really cancel each other out/limit concurrency. - # For pull_request events newer jobs cancel earlier jobs to save on CI etc. - group: ${{ github.workflow }}-${{ github.event_name }}-${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.sha || github.head_ref || github.ref }} - cancel-in-progress: true - -jobs: - check: - runs-on: ubuntu-latest - if: | # Only run on each PR once an appropriate event occurs - ( - github.event_name == 'workflow_dispatch' || - github.event_name == 'push' || - contains(github.event.pull_request.labels.*.name, 'CICD:run-e2e-tests') || - github.event.pull_request.auto_merge != null - ) - steps: - - uses: actions/checkout@v4 - - # Install buf, which we use to generate code from the protos for Rust and TS. - - name: Install buf - uses: bufbuild/buf-setup-action@v1.24.0 - with: - version: 1.28.1 - - - uses: pre-commit/action@v3.0.0 - - # Install protoc itself. - - name: Install Protoc - uses: arduino/setup-protoc@v2 - with: - version: "25.x" - - # Set up pnpm. - - uses: pnpm/action-setup@v4 - - # Set up Poetry. - - name: Install Python deps for generating code from protos - uses: ./.github/actions/python-setup - with: - pyproject_directory: ./protos/python - - # Install the Rust, TS, and Python codegen deps. - - name: Install deps for generating code from protos - run: cd protos && ./scripts/install_deps.sh - - # Finally, generate code based on the protos. - - name: Generate code - run: cd protos && ./scripts/build_protos.sh - - # Confirm that nothing has changed. - - name: Confirm that nothing has changed - run: git diff --exit-code diff --git a/.github/workflows/indexer-protos-sdk-update.yaml b/.github/workflows/indexer-protos-sdk-update.yaml new file mode 100644 index 0000000000000..852e6a994f308 --- /dev/null +++ b/.github/workflows/indexer-protos-sdk-update.yaml @@ -0,0 +1,106 @@ +name: Checks the proto changes and release +'on': + pull_request: + types: [labeled, opened, synchronize, reopened, auto_merge_enabled] + branches: + - main + paths: + - protos/proto/aptos/transaction/v1/transaction.proto + +jobs: + check-protos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # Install buf, which we use to generate code from the protos for Rust and TS. + - name: Install buf + uses: bufbuild/buf-setup-action@v1.24.0 + with: + version: 1.28.1 + - uses: pre-commit/action@v3.0.0 + # Install protoc itself. + - name: Install Protoc + uses: arduino/setup-protoc@v2 + with: + version: "25.x" + # Set up pnpm. + - uses: pnpm/action-setup@v4 + # Set up Poetry. + - name: Install Python deps for generating code from protos + uses: ./.github/actions/python-setup + with: + pyproject_directory: ./protos/python + # Install the Rust, TS, and Python codegen deps. + - name: Install deps for generating code from protos + run: cd protos && ./scripts/install_deps.sh + # Finally, generate code based on the protos. + - name: Generate code + run: cd protos && ./scripts/build_protos.sh + + - name: Confirm that nothing has changed + run: git diff --exit-code + update-sdk: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + if: | # Only run on each PR once an appropriate event occurs + ( + github.event_name == 'push' || + contains(github.event.pull_request.labels.*.name, 'indexer-sdk-update') + ) + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # Install buf, which we use to generate code from the protos for Rust and TS. + - name: Install buf + uses: bufbuild/buf-setup-action@v1.24.0 + with: + version: 1.28.1 + + - name: Check the format of the proto files + run: | + set -e + buf format -d aptos/transaction/v1/transaction.proto --exit-code + working-directory: protos/proto + - name: Capture the commit hash + id: commit_hash + run: | + # Echo the commit hash to the output + echo "::set-output name=commit_hash::$(echo $GITHUB_SHA)" + # Echo the PR branch name to the output + echo "::set-output name=branch_name::${{ github.head_ref }}" + + - name: Google Cloud Auth + id: auth + uses: "google-github-actions/auth@v2" + with: + workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }} + - name: Get Secret Manager Secrets + id: secrets + uses: 'google-github-actions/get-secretmanager-secrets@v2' + with: + secrets: |- + token:aptos-ci/github-actions-repository-dispatch + + - name: Dispatch Event to SDK Repo + uses: peter-evans/repository-dispatch@v3.0.0 + with: + token: ${{ steps.secrets.outputs.token }} + repository: 'aptos-labs/aptos-indexer-processor-sdk' + event-type: 'proto-dependency-update' + client-payload: '{"commit_hash": "${{ github.sha }}", "branch_name": "${{ steps.commit_hash.outputs.branch_name }}"}' + # TOOD: enable this once the forge test is stable. + # - name: Run Forge Tests + # uses: ./.github/workflows/workflow-run-forge + # with: + # GIT_SHA: ${{ github.sha }} + # FORGE_TEST_SUITE: sdk_update + # IMAGE_TAG: ${{ github.sha }} + # FORGE_RUNNER_DURATION_SECS: 3600 + # COMMENT_HEADER: forge-sdk-update + # FORGE_NAMESPACE: forge-sdk-update-namespace + # SKIP_JOB: ${{ !contains(github.event.pull_request.labels.*.name, 'CICD:run-sdk-update-test') }} + # SEND_RESULTS_TO_TRUNK: true