From f100d1db13394753b22210315bb8ba4a4ac67250 Mon Sep 17 00:00:00 2001 From: Larry Liu Date: Thu, 28 Mar 2024 15:40:37 -0700 Subject: [PATCH 1/3] add workflow to check protobuf compatibility. --- .../protobuf-compatibility-check/action.yaml | 59 +++++++++++++++++++ .../check-protobuf-compatibility.yaml | 27 +++++++++ .../nightly-check-protobuf-compatibility.yaml | 39 ++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 .github/actions/protobuf-compatibility-check/action.yaml create mode 100644 .github/workflows/check-protobuf-compatibility.yaml create mode 100644 .github/workflows/nightly-check-protobuf-compatibility.yaml diff --git a/.github/actions/protobuf-compatibility-check/action.yaml b/.github/actions/protobuf-compatibility-check/action.yaml new file mode 100644 index 000000000..db62a5b4d --- /dev/null +++ b/.github/actions/protobuf-compatibility-check/action.yaml @@ -0,0 +1,59 @@ +name: "Protobuf compatibility check" +description: | + "Runs a compatibility check for protobuf files." +inputs: + upstream_commit_version: + description: "Commit version of aptos-core that upstream is using" + required: true + default: "main" + +runs: + using: composite + steps: + - name: Install the buf CLI + shell: bash + run: | + BIN="/usr/local/bin" && \ + VERSION="1.30.0" && \ + curl -sSL \ + "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \ + -o "${BIN}/buf" && \ + chmod +x "${BIN}/buf" + + # Checkout current repo with current commit + - name: Checkout current repo + uses: actions/checkout@v4 + with: + path: "aptos-indexer-processors" + + - name: Parse the toml in this repo + id: get_tag_output + shell: bash + run: | + set -ex + curl -sSLf "$(curl -sSLf https://api.github.com/repos/tomwright/dasel/releases/latest | grep browser_download_url | grep linux_amd64 | grep -v .gz | cut -d\" -f 4)" -L -o dasel && chmod +x dasel + mv ./dasel /usr/local/bin/dasel + cd aptos-indexer-processors + tag_output=$(dasel -r toml -f rust/Cargo.toml workspace.dependencies.aptos-protos.tag -w - ) + echo "::set-output name=tag_output::$tag_output" + + - name: Checkout aptos-core + uses: actions/checkout@v4 + with: + repository: "aptos-labs/aptos-core" + path: "aptos-core" + ref: ${{ steps.get_tag_output.outputs.tag_output }} + + - name: Check compatibility + shell: bash + run: | + set -ex + cd aptos-core/protos/proto + repo_url="https://github.com/aptos-labs/aptos-core.git#tag=${{ inputs.upstream_commit_version }},subdir=protos/proto" + if buf breaking --against "$repo_url" --verbose; then + echo "No breaking changes found" + else + echo "Breaking changes found" + echo "Did new oneof/enum fields get added?" + exit 1 + fi diff --git a/.github/workflows/check-protobuf-compatibility.yaml b/.github/workflows/check-protobuf-compatibility.yaml new file mode 100644 index 000000000..2d2461ef2 --- /dev/null +++ b/.github/workflows/check-protobuf-compatibility.yaml @@ -0,0 +1,27 @@ +name: "Check Protobuf Compatibility" +on: + workflow_dispatch: + inputs: + upstream_commit_version: + description: 'The commit version to check compatibility against' + required: false + default: 'main' + pull_request: + + # 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: + CheckProtobufCompatibilityAgainstCurrentPR: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/protobuf-compatibility-check/ + with: + # Either current PR or the latest commit on the branch + upstream_commit_version: ${{ github.event.inputs.upstream_commit_version || 'main' }} \ No newline at end of file diff --git a/.github/workflows/nightly-check-protobuf-compatibility.yaml b/.github/workflows/nightly-check-protobuf-compatibility.yaml new file mode 100644 index 000000000..b0dfc4b7e --- /dev/null +++ b/.github/workflows/nightly-check-protobuf-compatibility.yaml @@ -0,0 +1,39 @@ +name: "Nightly Check Protobuf Compatibility" +on: + workflow_dispatch: + schedule: + - cron: "0 9 * * *" + +# 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: + CheckProtobufCompatibilityAgainstTestnet: + runs-on: ubuntu-latest + steps: + - name: Get current version + id: get_upstream_commit_version + run: | + echo "::set-output name=upstream_commit_version::$(curl -s https://api.testnet.aptoslabs.com/v1 | jq -r .git_hash)" + + - uses: actions/checkout@v4 + - uses: ./.github/actions/protobuf-compatibility-check/ + with: + upstream_commit_version: ${{ steps.get_upstream_commit_version.outputs.upstream_commit_version }} + + CheckProtobufCompatibilityAgainstMainnet: + runs-on: ubuntu-latest + steps: + - name: Get current version + id: get_upstream_commit_version + run: | + echo "::set-output name=upstream_commit_version::$(curl -s https://api.mainnet.aptoslabs.com/v1 | jq -r .git_hash)" + + - uses: actions/checkout@v4 + - uses: ./.github/actions/protobuf-compatibility-check/ + with: + upstream_commit_version: ${{ steps.get_upstream_commit_version.outputs.upstream_commit_version }} \ No newline at end of file From c66a57820219d1871b0c4763cd2d24648a2655ef Mon Sep 17 00:00:00 2001 From: Larry Liu Date: Thu, 28 Mar 2024 15:53:27 -0700 Subject: [PATCH 2/3] add workflow to check protobuf compatibility. --- .github/workflows/check-protobuf-compatibility.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-protobuf-compatibility.yaml b/.github/workflows/check-protobuf-compatibility.yaml index 2d2461ef2..2b2215508 100644 --- a/.github/workflows/check-protobuf-compatibility.yaml +++ b/.github/workflows/check-protobuf-compatibility.yaml @@ -1,14 +1,15 @@ name: "Check Protobuf Compatibility" on: - workflow_dispatch: + workflow_call: inputs: upstream_commit_version: + type: string description: 'The commit version to check compatibility against' required: false default: 'main' pull_request: - # cancel redundant builds +# 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. From 66cec2c0cca5b10559c50da23d3418a3da62fe90 Mon Sep 17 00:00:00 2001 From: Larry Liu Date: Thu, 28 Mar 2024 15:55:48 -0700 Subject: [PATCH 3/3] test. --- .github/workflows/check-protobuf-compatibility.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/check-protobuf-compatibility.yaml b/.github/workflows/check-protobuf-compatibility.yaml index 2b2215508..ba7955f62 100644 --- a/.github/workflows/check-protobuf-compatibility.yaml +++ b/.github/workflows/check-protobuf-compatibility.yaml @@ -1,9 +1,8 @@ name: "Check Protobuf Compatibility" on: - workflow_call: + workflow_dispatch: inputs: upstream_commit_version: - type: string description: 'The commit version to check compatibility against' required: false default: 'main'