Skip to content

Commit

Permalink
rebase develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Dec 11, 2024
2 parents 98bab57 + 7d4d99b commit 1167862
Show file tree
Hide file tree
Showing 460 changed files with 16,689 additions and 14,906 deletions.
4 changes: 4 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ reviews:
instructions: >-
Review the shell scripts, point out issues relative to security,
performance, and maintainability.
- path: '{*e2e*,*_test.go}'
instructions: >-
Errors in tests may be handled via require.NoError(t, err) rather
than explicitly returning error.
auto_review:
drafts: false
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @brewmaster012 @kingpinXD @lumtis @ws4charlie @skosito @swift1337 @fbac
* @zeta-chain/protocol-engineering

.github/** @zeta-chain/devops
2 changes: 1 addition & 1 deletion .github/actions/upgrade-testing/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
with:
python-version: 'pypy3.9'

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4 #v3 reaches deprecation on November 30, 2024
with:
name: binaries-${{ github.sha }}
path: ./
Expand Down
145 changes: 123 additions & 22 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,90 @@ concurrency:
cancel-in-progress: true

jobs:
# this cannot run on forks as forks cannot push packages in pull request context
# forked pull request will fall back to slow build
build-zetanode:
runs-on: ubuntu-22.04
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node') && github.actor != 'dependabot[bot]'
env:
DOCKER_IMAGE: ghcr.io/${{ github.repository_owner }}/zetanode
DOCKER_TAG: ${{ github.ref == 'refs/heads/develop' && 'develop' || github.sha }}
outputs:
image: ${{ fromJson(steps.build.outputs.metadata)['image.name'] }}
steps:
- uses: actions/checkout@v4

# configure docker to use the containerd snapshotter
# so that we can use the buildkit cache
- uses: depot/use-containerd-snapshotter-action@v1

- name: Login to Docker Hub registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_READ_ONLY }}

- name: Login to github docker registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Restore go cache
uses: actions/cache@v4
id: restore-go-cache
with:
path: |
go-cache
key: cache-${{ hashFiles('go.sum') }}

- name: Inject go cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"go-cache": "/root/.cache/go-build"
}
skip-extraction: ${{ steps.restore-go-cache.outputs.cache-hit || github.event_name != 'push' }}

# this ensures that the version is consistent between cache build and make build
- name: Set version for cache
run: |
NODE_VERSION=$(./version.sh)
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_ENV
NODE_COMMIT=$(git log -1 --format='%H')
echo "NODE_COMMIT=$NODE_COMMIT" >> $GITHUB_ENV
# build zetanode with cache options
- name: Build zetanode for cache
id: build
uses: docker/build-push-action@v6
env:
CACHE_FROM_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache"
CACHE_TO_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max"
with:
context: .
file: ./Dockerfile-localnet
push: true
tags: ${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }}
cache-from: ${{ env.CACHE_FROM_CONFIG }}
cache-to: ${{ github.event_name == 'push' && env.CACHE_TO_CONFIG || '' }}
target: latest-runtime
build-args: |
NODE_VERSION=${{ env.NODE_VERSION }}
NODE_COMMIT=${{ env.NODE_COMMIT }}
matrix-conditionals:
needs: build-zetanode
if: ${{ !cancelled() }}
runs-on: ubuntu-22.04
env:
GH_TOKEN: ${{ github.token }}
outputs:
DEFAULT_TESTS: ${{ steps.matrix-conditionals.outputs.DEFAULT_TESTS }}
UPGRADE_TESTS: ${{ steps.matrix-conditionals.outputs.UPGRADE_TESTS }}
CONSENSUS_TESTS: ${{ steps.matrix-conditionals.outputs.CONSENSUS_TESTS }}
UPGRADE_LIGHT_TESTS: ${{ steps.matrix-conditionals.outputs.UPGRADE_LIGHT_TESTS }}
UPGRADE_IMPORT_MAINNET_TESTS: ${{ steps.matrix-conditionals.outputs.UPGRADE_IMPORT_MAINNET_TESTS }}
ADMIN_TESTS: ${{ steps.matrix-conditionals.outputs.ADMIN_TESTS }}
Expand All @@ -43,25 +120,30 @@ jobs:
TSS_MIGRATION_TESTS: ${{ steps.matrix-conditionals.outputs.TSS_MIGRATION_TESTS }}
SOLANA_TESTS: ${{ steps.matrix-conditionals.outputs.SOLANA_TESTS }}
TON_TESTS: ${{ steps.matrix-conditionals.outputs.TON_TESTS }}
V2_TESTS: ${{ steps.matrix-conditionals.outputs.V2_TESTS }}
V2_MIGRATION_TESTS: ${{ steps.matrix-conditionals.outputs.V2_MIGRATION_TESTS }}
LEGACY_TESTS: ${{ steps.matrix-conditionals.outputs.LEGACY_TESTS }}
ENABLE_MONITORING: ${{ steps.matrix-conditionals.outputs.ENABLE_MONITORING }}
steps:
# use api rather than event context to avoid race conditions (label added after push)
- id: matrix-conditionals
uses: actions/github-script@v7
with:
script: |
if (context.eventName === 'pull_request') {
const getPrLabels = async (pull_number) => {
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
const labels = pr.labels.map(label => label.name);
console.log("labels:", labels);
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
});
const labels = pr.labels.map(label => label.name);
console.log(`labels for ${pull_number}:`, labels);
return labels;
}
if (context.eventName === 'pull_request') {
const labels = await getPrLabels(context.payload.pull_request.number);
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_TESTS', labels.includes('UPGRADE_TESTS'));
core.setOutput('CONSENSUS_TESTS', labels.includes('CONSENSUS_TESTS'));
core.setOutput('UPGRADE_LIGHT_TESTS', labels.includes('UPGRADE_LIGHT_TESTS'));
core.setOutput('UPGRADE_IMPORT_MAINNET_TESTS', labels.includes('UPGRADE_IMPORT_MAINNET_TESTS'));
core.setOutput('ADMIN_TESTS', labels.includes('ADMIN_TESTS'));
Expand All @@ -70,12 +152,23 @@ jobs:
core.setOutput('TSS_MIGRATION_TESTS', labels.includes('TSS_MIGRATION_TESTS'));
core.setOutput('SOLANA_TESTS', labels.includes('SOLANA_TESTS'));
core.setOutput('TON_TESTS', labels.includes('TON_TESTS'));
core.setOutput('V2_TESTS', labels.includes('V2_TESTS')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', labels.includes('V2_MIGRATION_TESTS')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('LEGACY_TESTS', labels.includes('LEGACY_TESTS'));
core.setOutput('ENABLE_MONITORING', labels.includes('ENABLE_MONITORING'));
} else if (context.eventName === 'merge_group') {
// default mergequeue tests
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_LIGHT_TESTS', true);
// conditional tests based on PR labels
const commit_message = context.payload.merge_group.head_commit.message;
const pr_match = commit_message.split('\n')[0].match(/\(#(\d+)\)$/);
if (!pr_match) {
console.error("unable to extract PR number from mergequeue commit message");
return;
}
const pr_number = pr_match[1];
const pr_labels = await getPrLabels(pr_number);
core.setOutput('CONSENSUS_TESTS', !pr_labels.includes('CONSENSUS_BREAKING_ACK'));
} else if (context.eventName === 'push' && context.ref === 'refs/heads/develop') {
core.setOutput('DEFAULT_TESTS', true);
} else if (context.eventName === 'push' && context.ref.startsWith('refs/heads/release/')) {
Expand All @@ -88,7 +181,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
core.setOutput('TON_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('LEGACY_TESTS', true);
} else if (context.eventName === 'schedule') {
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_TESTS', true);
Expand All @@ -100,7 +193,7 @@ jobs:
core.setOutput('TSS_MIGRATION_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
core.setOutput('TON_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('LEGACY_TESTS', true);
} else if (context.eventName === 'workflow_dispatch') {
const makeTargets = context.payload.inputs['make-targets'].split(',');
core.setOutput('DEFAULT_TESTS', makeTargets.includes('default-test'));
Expand All @@ -113,20 +206,25 @@ jobs:
core.setOutput('TSS_MIGRATION_TESTS', makeTargets.includes('tss-migration-test'));
core.setOutput('SOLANA_TESTS', makeTargets.includes('solana-test'));
core.setOutput('TON_TESTS', makeTargets.includes('ton-test'));
core.setOutput('V2_TESTS', makeTargets.includes('v2-test')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', makeTargets.includes('v2-migration-test')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('LEGACY_TESTS', makeTargets.includes('legacy-test'));
core.setOutput('ENABLE_MONITORING', context.payload.inputs['enable-monitoring']);
}
e2e:
needs: matrix-conditionals
needs:
- build-zetanode
- matrix-conditionals
if: ${{ !cancelled() }}
strategy:
fail-fast: false
matrix:
include:
- make-target: "start-e2e-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.DEFAULT_TESTS == 'true' }}
- make-target: "start-e2e-consensus-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.CONSENSUS_TESTS == 'true' }}
- make-target: "start-upgrade-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.UPGRADE_TESTS == 'true' }}
Expand Down Expand Up @@ -157,28 +255,27 @@ jobs:
- make-target: "start-ton-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.TON_TESTS == 'true' }}
- make-target: "start-v2-test"
- make-target: "start-legacy-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.V2_TESTS == 'true' }}
- make-target: "start-upgrade-v2-migration-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.V2_MIGRATION_TESTS == 'true' }}
run: ${{ needs.matrix-conditionals.outputs.LEGACY_TESTS == 'true' }}
name: ${{ matrix.make-target }}
uses: ./.github/workflows/reusable-e2e.yml
with:
make-target: ${{ matrix.make-target }}
runs-on: ${{ matrix.runs-on}}
run: ${{ matrix.run }}
timeout-minutes: "${{ matrix.timeout-minutes || 25 }}"
zetanode-image: ${{ needs.build-zetanode.outputs.image }}
enable-monitoring: ${{ needs.matrix-conditionals.outputs.ENABLE_MONITORING == 'true' }}
secrets: inherit
# this allows you to set a required status check
e2e-ok:
runs-on: ubuntu-22.04
needs:
- build-zetanode
- matrix-conditionals
- e2e
if: always()
if: ${{ !cancelled() }}
steps:
- name: Send slack message with results
uses: actions/github-script@v7
Expand Down Expand Up @@ -224,6 +321,10 @@ jobs:
- run: |
result="${{ needs.build-zetanode.result }}"
if [[ $result == "failed" ]]; then
exit 1
fi
result="${{ needs.e2e.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
Expand Down
35 changes: 1 addition & 34 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ jobs:
echo "${{ github.ref }}"
check-goreleaser:
if: inputs.skip_checks != true
runs-on: ${{ vars.RELEASE_RUNNER }}
steps:
- uses: actions/checkout@v4
- name: Build release snapshot
if: inputs.skip_checks != true
run: |
make release-snapshot
Expand Down Expand Up @@ -94,38 +94,6 @@ jobs:
run: |
echo "continue"
check-upgrade-handler-updated:
needs:
- check-branch
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:

- uses: actions/checkout@v4
if: inputs.skip_checks != true
with:
fetch-depth: 0

- name: Major Version in Upgrade Handler Must Match Tag
if: inputs.skip_checks != true
run: |
UPGRADE_HANDLER_MAJOR_VERSION=$(cat app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"' | cut -d '.' -f 1 | tr -d '\n')
USER_INPUT_VERSION=$(echo "${{ inputs.version }}" | cut -d '.' -f 1 | tr -d '\n')
echo "Upgrade Handler Major Version: ${UPGRADE_HANDLER_MAJOR_VERSION}"
echo "User Inputted Release Version: ${USER_INPUT_VERSION}"
if [ ${USER_INPUT_VERSION} != $UPGRADE_HANDLER_MAJOR_VERSION ]; then
echo "ERROR: The input version doesn't match the release handler for the branch selected. Please ensure the upgrade handler of the branch you selected when you ran the pipeline matches the input version."
echo "Did you forget to update the 'releaseVersion' in app/setup_handlers.go?"
exit 1
fi
echo "The major version found in 'releaseVersion' in app/setup_handlers.go matches this tagged release - Moving Forward!"
- name: Mark Job Complete Skipped
if: inputs.skip_checks == true
shell: bash
run: |
echo "continue"
publish-release:
permissions:
id-token: write
Expand All @@ -134,7 +102,6 @@ jobs:
if: inputs.skip_release != true
needs:
- check-changelog
- check-upgrade-handler-updated
- check-branch
- check-goreleaser
runs-on: ${{ vars.RELEASE_RUNNER }}
Expand Down
Loading

0 comments on commit 1167862

Please sign in to comment.