Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ignore] test PR for changes in new workflow for compat test #14701

Open
wants to merge 37 commits into
base: yzaccc/auto-bump-forge-compat-base-image-to-latest-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
df93f9b
Automatically bump Forge compat base image to latest release
Sep 19, 2024
29f276f
refined
Sep 19, 2024
03bbc8f
temporarilly changing the trigger from pull_request_target to pull_re…
Sep 19, 2024
8d4bf67
temporarilly changing the trigger from pull_request_target to pull_re…
Sep 19, 2024
e9b4bbc
temporarilly changing the trigger from pull_request_target to pull_re…
Sep 19, 2024
7410679
refined the algorithm to find the last release branch
Sep 19, 2024
5f91ed3
refined workflow
Sep 19, 2024
85e0751
refined workflow
Sep 19, 2024
a244c00
refined workflow
Sep 19, 2024
dc4d810
fix rust-images-consensus-only-perf-test errors
Sep 19, 2024
bbecf69
fix rust-images-consensus-only-perf-test errors
Sep 19, 2024
e6a5e43
refined
Sep 19, 2024
2197361
refined
Sep 19, 2024
4ed32c0
changed put logic in py script in stead of bash
Sep 20, 2024
4f72522
changed put logic in py script in stead of bash
Sep 20, 2024
08f4ad1
changed put logic in py script in stead of bash
Sep 20, 2024
5641bbf
changed put logic in py script in stead of bash
Sep 20, 2024
ab9f125
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
f4b7080
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
89ecf38
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
616c435
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
6c2b1b9
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
20fe4fb
refined
Sep 20, 2024
cafb369
refined
Sep 20, 2024
4551a0b
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
5a14c92
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
5d48852
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
7bc9c31
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
5000d1b
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
c612656
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
e7f1b5b
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
97ad2d6
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
1c544c3
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
203b6b7
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
688beba
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
81b8cd2
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
eea1722
branch to test against yzaccc/auto-bump-forge-compat-base-image-to-la…
Sep 20, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Determine Branch to Fetch Latest Docker Image for Compat Test"
description: |
Determine the branch to fetch the latest docker image tag from for the compat test

inputs:
base-branch:
description: "The base branch to determine the target from"
required: true

outputs:
TARGET_BRANCH:
description: "The determined target branch"
value: ${{ steps.determine-target-branch.outputs.TARGET_BRANCH }}

runs:
using: composite
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.base-branch }}
path: checkout_branch
fetch-depth: 0

- uses: ./checkout_branch/.github/actions/python-setup
with:
pyproject_directory: checkout_branch/testsuite

- name: Determine target branch
id: determine-target-branch
run: |
base_branch="${{ inputs.base-branch }}"
target_branch=$(./testrun determine_target_branch_to_fetch_last_released_image.py "$base_branch")
echo "TARGET_BRANCH=${target_branch}" >> $GITHUB_OUTPUT
echo "Determined TARGET_BRANCH: ${target_branch}"
shell: bash
working-directory: checkout_branch/testsuite # the checkout_branch is a subdirectory
4 changes: 3 additions & 1 deletion .github/actions/get-latest-docker-image-tag/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ runs:
for variant in "${variants[@]}"; do
variants_args+=("--variant" "$variant")
done
./testrun find_latest_image.py "${variants_args[@]}"
IMAGE_TAG=$(./testrun find_latest_image.py "${variants_args[@]}")
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "Latest image tag: $IMAGE_TAG"
shell: bash
working-directory: checkout_branch/testsuite # the checkout_branch is a subdirectory
76 changes: 64 additions & 12 deletions .github/workflows/docker-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,11 @@ jobs:
# by this GHA. If there is a Forge namespace collision, Forge will pre-empt the existing test running in the namespace.
FORGE_NAMESPACE: forge-e2e-${{ needs.determine-docker-build-metadata.outputs.targetCacheId }}
SKIP_JOB: ${{ needs.file_change_determinator.outputs.only_docs_changed == 'true' }}

# Run e2e compat test against testnet branch. This is a PR required job.
forge-compat-test:
# This job determines the last released docker image tag, which is used by forge compat test.
fetch-last-released-docker-image-tag:
needs:
- permission-check
- determine-docker-build-metadata
- rust-images
- rust-images-failpoints
- rust-images-performance
- rust-images-consensus-only-perf-test
- file_change_determinator
if: |
!failure() && !cancelled() && needs.permission-check.result == 'success' && (
(github.event_name == 'push' && github.ref_name != 'main') ||
Expand All @@ -307,17 +301,75 @@ jobs:
github.event.pull_request.auto_merge != null ||
contains(github.event.pull_request.body, '#e2e')
)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags

# To test the compat test against the last released docker image, we need to get the last released docker image tag.
# This step determines appropriate branch to fetch the latest docker image tag from based on the current branch.
# Determine the IMAGE_TAG based on the latest release R and check for images built on branch R - 1:
# - ex. For commits on the aptos-release-v1.19 branch, the IMAGE_TAG should be the latest commit built on aptos-release-v1.18
# - For commits on the main branch, the IMAGE_TAG should be the latest commit on the max release aptos-release-v<MAX> branch
- name: Determine target branch
uses: ./.github/actions/determine-branch-to-fetch-last-released-image
id: determine-target-branch
with:
base-branch: ${{ github.base_ref || github.ref_name }}

# actions/get-latest-docker-image-tag requires docker utilities and having authenticated to internal docker image registries
- uses: aptos-labs/aptos-core/.github/actions/docker-setup@main
id: docker-setup
with:
GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
GCP_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}
EXPORT_GCP_PROJECT_VARIABLES: "false"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DOCKER_ARTIFACT_REPO: ${{ secrets.AWS_DOCKER_ARTIFACT_REPO }}
GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }}

- name: Get Docker Image Tag
uses: ./.github/actions/get-latest-docker-image-tag
id: get-docker-image-tag
with:
branch: ${{ steps.determine-target-branch.outputs.TARGET_BRANCH }}
variants: "failpoints performance"

- name: Log TARGET_BRANCH and IMAGE_TAG
run: |
echo "TARGET_BRANCH: ${{ steps.determine-target-branch.outputs.TARGET_BRANCH }}"
echo "IMAGE_TAG: ${{ steps.get-docker-image-tag.outputs.IMAGE_TAG }}"

- name: Set IMAGE_TAG as job output
run: echo "IMAGE_TAG=${{ steps.get-docker-image-tag.outputs.IMAGE_TAG }}" >> $GITHUB_OUTPUT

outputs:
IMAGE_TAG: ${{ steps.get-docker-image-tag.outputs.IMAGE_TAG }}

# Run e2e compat test against testnet branch. This is a PR required job.
forge-compat-test:
needs:
- fetch-last-released-docker-image-tag
- permission-check
- determine-docker-build-metadata
- rust-images
- rust-images-failpoints
- rust-images-performance
# - rust-images-consensus-only-perf-test
- file_change_determinator
uses: aptos-labs/aptos-core/.github/workflows/workflow-run-forge.yaml@main
secrets: inherit
with:
GIT_SHA: ${{ needs.determine-docker-build-metadata.outputs.gitSha }}
FORGE_TEST_SUITE: compat
IMAGE_TAG: 25a081116546670e62ca927ba90478de78557056 #aptos-node-v1.20
IMAGE_TAG: ${{ needs.fetch-last-released-docker-image-tag.outputs.IMAGE_TAG }}
FORGE_RUNNER_DURATION_SECS: 300
COMMENT_HEADER: forge-compat
FORGE_NAMESPACE: forge-compat-${{ needs.determine-docker-build-metadata.outputs.targetCacheId }}
SKIP_JOB: ${{ needs.file_change_determinator.outputs.only_docs_changed == 'true' }}

# Run forge framework upgradability test. This is a PR required job.
forge-framework-upgrade-test:
needs:
Expand Down
2 changes: 1 addition & 1 deletion mempool/src/shared_mempool/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ fn validate_and_add_transactions<NetworkClient, TransactionValidator>(
sequence_info,
timeline_state,
client_submitted,
read_time_at_sender,
ready_time_at_sender,
priority,
);
statuses.push((transaction, (mempool_status, None)));
Expand Down
97 changes: 97 additions & 0 deletions testsuite/determine_target_branch_to_fetch_last_released_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import sys
import subprocess
import re

def get_latest_release_branch():
"""Get the latest aptos-release-vX.Y branch"""
result = subprocess.run(['git', 'ls-remote', '--heads', 'origin', 'aptos-release-v*'], capture_output=True, text=True)
branches = re.findall(r'refs/heads/(aptos-release-v\d+\.\d+)$', result.stdout, re.MULTILINE)

if not branches:
raise ValueError("No aptos-release branches found")

# Return the highest version release branch
return max(branches, key=lambda x: [int(n) for n in x.split('v')[1].split('.')])

def get_latest_branch_for_previous_major(major):
"""Get the latest aptos-release-v(previous_major).Y branch"""
prev_major = int(major) - 1
result = subprocess.run(['git', 'ls-remote', '--heads', 'origin', f'aptos-release-v{prev_major}.*'], capture_output=True, text=True)
branches = re.findall(rf'refs/heads/(aptos-release-v{prev_major}\.\d+)$', result.stdout, re.MULTILINE)

if branches:
return max(branches, key=lambda x: int(x.split('.')[-1]))
return None

def get_release_branch_from_tag(tag):
"""Extract release branch name from the aptos-node-vX.Y.Z-* tag"""
match = re.match(r'^aptos-node-v(\d+)\.(\d+)\.\d+-.*$', tag)
if match:
major, minor = match.groups()
return f'aptos-release-v{major}.{minor}'
return None

def get_latest_tag_in_history(branch, max_commits=100):
"""Search commit history for a tag like aptos-node-vX.Y.Z-*"""
result = subprocess.run(['git', 'log', '-n', str(max_commits), '--format=%H', branch], capture_output=True, text=True)
commits = result.stdout.strip().split('\n')

for commit in commits:
tags = subprocess.run(['git', 'tag', '--points-at', commit], capture_output=True, text=True).stdout.strip().split('\n')

# Find the first tag that matches aptos-node-vX.Y.Z-*
for tag in tags:
if re.match(r'^aptos-node-v\d+\.\d+\.\d+-.*$', tag):
return tag
return None

def branch_exists(branch):
"""Check if a branch exists in the remote repository"""
result = subprocess.run(['git', 'ls-remote', '--heads', 'origin', branch], capture_output=True)
return result.returncode == 0

def determine_target_branch(base_branch, max_commits=5000):
"""Determine the appropriate target branch based on the base branch"""
if base_branch == 'main':
# For main, use the latest release branch
return get_latest_release_branch()

elif base_branch.startswith('aptos-release-v'):
# If the base branch is a release branch, find the previous release branch
match = re.match(r'^aptos-release-v(\d+)\.(\d+)', base_branch)
if match:
major, minor = match.groups()
if minor == '0':
return get_latest_branch_for_previous_major(major)
else:
return f'aptos-release-v{major}.{int(minor) - 1}'
else:
raise ValueError(f"Invalid release branch format: {base_branch}")

else:
# For non-main/non-release branches, search history for a tag like aptos-node-vX.Y.Z-*
print(f"Searching {base_branch}'s history for the latest aptos-node tag.", file=sys.stderr)
latest_tag = get_latest_tag_in_history(base_branch, max_commits)

if latest_tag:
release_branch = get_release_branch_from_tag(latest_tag)
if release_branch and branch_exists(release_branch):
return release_branch
else:
raise ValueError(f"Release branch {release_branch} does not exist")
else:
raise ValueError(f"No aptos-node tag found in the last {max_commits} commits of {base_branch}. Please rebase or correct the branch.")

if __name__ == '__main__':
if len(sys.argv) != 2:
print("Usage: python determine_target_branch.py <base_branch>", file=sys.stderr)
sys.exit(1)

base_branch = sys.argv[1]
try:
target_branch = determine_target_branch(base_branch)
print(f"Target branch is {target_branch}", file=sys.stderr)
print(target_branch)
except ValueError as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
Loading