Skip to content

Commit

Permalink
try to simplify runner
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Nov 16, 2024
1 parent 9a68cc7 commit 7661cb0
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 40 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.secrets
76 changes: 46 additions & 30 deletions .github/workflows/live-network-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ on:
push:
branches:
- 9955-feat-point-tests-at-live-networks
workflow_call:
inputs:
branch:
required: true
type: string
test_name:
required: true
type: string
cloud:
required: true
type: string
cluster_name:
required: true
type: string
namespace:
required: true
type: string
helm_instance:
required: true
type: string
workflow_dispatch:
inputs:
branch:
Expand Down Expand Up @@ -102,37 +122,33 @@ jobs:
aws-region: ${{ env.AWS_REGION }}
- name: Update kube config
run: aws eks update-kubeconfig --name ${{ env.CLUSTER_NAME }} --region ${{ env.AWS_REGION }}
- name: Setup and Test
uses: ./.github/ensure-tester-with-images
- name: "Build E2E Image"
timeout-minutes: 40
run: earthly-ci ./yarn-project+export-e2e-test-images
- name: Run Test
timeout-minutes: 90
with:
runner_type: 16core-tester-x86
builder_type: builder-x86
builder_images_to_copy: aztecprotocol/aztec:${{ needs.build.outputs.git_commit }} aztecprotocol/end-to-end:${{ needs.build.outputs.git_commit }}
builder_command: scripts/earthly-ci ./yarn-project+export-e2e-test-images
tester_ttl: 90
run: |
set -eux
cd yarn-project/end-to-end
export FORCE_COLOR=1
export NAMESPACE=${{ env.NAMESPACE }}
export INSTANCE_NAME=${{ env.HELM_INSTANCE }}
export AZTEC_DOCKER_TAG=${{ needs.build.outputs.git_commit }}
export TEST_NAME="./src/spartan/${{ env.TEST_NAME }}.test.ts"
docker run --rm --network=host \
-v ~/.kube:/root/.kube \
-e K8S=true \
-e SPARTAN_DIR="/usr/src/spartan" \
-e NAMESPACE="$NAMESPACE" \
-e HOST_PXE_PORT=8080 \
-e CONTAINER_PXE_PORT=8080 \
-e HOST_ETHEREUM_PORT=8545 \
-e CONTAINER_ETHEREUM_PORT=8545 \
-e DEBUG="aztec:*" \
-e LOG_JSON=1 \
-e LOG_LEVEL=debug \
-e INSTANCE_NAME="$INSTANCE_NAME" \
aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG $TEST_NAME
run: |
set -eux
cd yarn-project/end-to-end
export FORCE_COLOR=1
export NAMESPACE=${{ env.NAMESPACE }}
export INSTANCE_NAME=${{ env.HELM_INSTANCE }}
export AZTEC_DOCKER_TAG=${{ needs.build.outputs.git_commit }}
export TEST_NAME="./src/spartan/${{ env.TEST_NAME }}.test.ts"
docker run --rm --network=host \
-v ~/.kube:/root/.kube \
-e K8S=true \
-e SPARTAN_DIR="/usr/src/spartan" \
-e NAMESPACE="$NAMESPACE" \
-e HOST_PXE_PORT=8080 \
-e CONTAINER_PXE_PORT=8080 \
-e HOST_ETHEREUM_PORT=8545 \
-e CONTAINER_ETHEREUM_PORT=8545 \
-e DEBUG="aztec:*" \
-e LOG_JSON=1 \
-e LOG_LEVEL=debug \
-e INSTANCE_NAME="$INSTANCE_NAME" \
aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG $TEST_NAME
success-check:
runs-on: ubuntu-20.04
Expand Down
173 changes: 173 additions & 0 deletions .github/workflows/release-cron-handler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: Hourly Passive Test Trigger

on:
schedule:
- cron: "0 * * * *" # Every hour
workflow_dispatch:
inputs:
pr_number:
description: "PR number with the release branch"
required: true
type: number
branch:
description: "Branch to test"
required: false
type: string
default: "9955-feat-point-tests-at-live-networks"
test_name:
description: "Test to run (e.g., transfer, reorg)"
required: false
type: string
default: "smoke"
cloud:
description: "Cloud provider to use"
required: false
type: string
default: "aws"
cluster_name:
description: "Kubernetes cluster name"
required: false
type: string
default: "spartan"
namespace:
description: "Kubernetes namespace"
required: false
type: string
default: "devnet-1val"
helm_instance:
description: "Helm instance name"
required: false
type: string
default: "spartan"

env:
PR_NUMBER: ${{ github.event.inputs.pr_number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKERHUB_PASSWORD: "${{ secrets.DOCKERHUB_PASSWORD }}"
BUILD_INSTANCE_SSH_KEY: ${{ secrets.BUILD_INSTANCE_SSH_KEY }}
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
USERNAME: ${{ github.event.pull_request.user.login || github.actor }}
GH_SELF_HOSTED_RUNNER_TOKEN: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CLOUD: ${{ github.event.inputs.cloud || 'aws' }}
CLUSTER_NAME: ${{ github.event.inputs.cluster_name || 'spartan' }}
BRANCH: ${{ github.event.inputs.branch || '9955-feat-point-tests-at-live-networks' }}
TEST_NAME: ${{ github.event.inputs.test_name || 'smoke' }}
NAMESPACE: ${{ github.event.inputs.namespace || 'devnet-1val' }}
HELM_INSTANCE: ${{ github.event.inputs.helm_instance || 'spartan' }}
COMMENT_API_URL: repos/aztecprotocol/aztec-packages/issues/comments
WAIT_FOR_RUNNERS: false

jobs:
trigger_test:
runs-on: ubuntu-latest
outputs:
comment_id: ${{ env.comment_id }}
test_running: ${{ env.test_running }}
steps:
- name: checkout
uses: actions/checkout@v4

- name: setup gh
run: |
# check if gh is already logged in
export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}"
- name: Fetch test status comment
id: fetch_comment
continue-on-error: true
run: |
COMMENT=$(gh pr view ${{ env.PR_NUMBER }} --json comments --jq '.comments[] | select(.body | contains("start_time"))')
echo "COMMENT=$COMMENT"
COMMENT_ID=$(echo "$COMMENT" | jq -r '.id')
COMMENT_BODY=$(echo "$COMMENT" | jq -r '.body' | head -n 1)
echo "COMMENT_BODY=$COMMENT_BODY"
echo "comment_id=$COMMENT_ID" >> $GITHUB_ENV
echo "$COMMENT_BODY" > comment.json
- name: Parse JSON comment
if: env.comment_id != ''
id: parse_comment
run: |
set -x
START_TIME=$(jq -r '.start_time' comment.json)
STOP_TIME=$(jq -r '.stop_time' comment.json)
STATUS=$(jq -r '.status' comment.json)
CURRENT_TIME=$(date +%s)
ELAPSED=$((CURRENT_TIME - START_TIME))
echo "Start Time: $START_TIME"
echo "Stop Time: $STOP_TIME"
echo "Status: $STATUS"
echo "Elapsed Time: $ELAPSED"
# Store parsed values in outputs
echo "start_time=$START_TIME" >> $GITHUB_ENV
echo "status=$STATUS" >> $GITHUB_ENV
echo "elapsed=$ELAPSED" >> $GITHUB_ENV
if [ "$STATUS" != "running" ]; then
echo "Test is not running. Exiting."
echo "test_running=false" >> $GITHUB_ENV
exit 0
fi
if [ "$ELAPSED" -gt 259200 ]; then
echo "Test period complete. Updating status to success."
UPDATED_JSON=$(jq ".stop_time = \"$CURRENT_TIME\" | .status = \"success\"" comment.json)
echo "$UPDATED_JSON" > comment.json
echo "test_running=false" >> $GITHUB_ENV
exit 0
fi
# Update the last_test_time before running the test
CURRENT_TIME=$(date +%s)
UPDATED_JSON=$(jq ".last_test_time = \"$CURRENT_TIME\"" comment.json)
echo "$UPDATED_JSON" > comment.json
echo "test_running=true" >> $GITHUB_ENV
call_network_test:
needs: trigger_test
if: needs.trigger_test.outputs.comment_id != '' && needs.trigger_test.outputs.test_running == 'true'
uses: ./.github/workflows/live-network-test.yml
with:
branch: ${{ needs.trigger_test.outputs.branch }}
test_name: ${{ needs.trigger_test.outputs.test_name }}
cloud: ${{ needs.trigger_test.outputs.cloud }}
cluster_name: ${{ needs.trigger_test.outputs.cluster_name }}
namespace: ${{ needs.trigger_test.outputs.namespace }}
helm_instance: ${{ needs.trigger_test.outputs.helm_instance }}
secrets: inherit

retrieve_test_result:
needs: [trigger_test, call_network_test]
if: always()
runs-on: ubuntu-latest
steps:
- name: debug
run: |
echo "PR_NUMBER=$PR_NUMBER"
echo "comment_id=$comment_id"
echo "test_running=$test_running"
cat comment.json
- name: Update JSON comment with result
if: needs.trigger_test.outputs.comment_id != '' && failure() && needs.trigger_test.outputs.test_running == 'true'
id: update_comment
run: |
STOP_TIME=$(date +%s)
UPDATED_JSON=$(jq ".stop_time = \"$STOP_TIME\" | .status = \"failed\"" comment.json)
echo "$UPDATED_JSON" > comment.json
- name: Update sticky comment
id: update_sticky_comment
if: needs.trigger_test.outputs.comment_id != '' && needs.trigger_test.outputs.test_running == 'true'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: running_status
number: ${{ env.PR_NUMBER }}
path: comment.json
28 changes: 18 additions & 10 deletions .github/workflows/release-kickoff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,41 @@ jobs:
start_network:
runs-on: ubuntu-latest
steps:
- name: Start network and record start time
id: start_network
- name: Get existing running status comment
id: get_existing_comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: running_status
number: ${{ env.PR_NUMBER }}
only_create: true
message: "{}"

- name: Exit with success if comment already exists
if: steps.get_existing_comment.outputs.previous_comment_id != ''
run: |
START_TIME=$(date +%s)
echo "START_TIME=$START_TIME" >> $GITHUB_ENV
echo "::notice::A test is already running"
- name: Create or update test status comment
id: create_comment
if: steps.get_existing_comment.outputs.previous_comment_id == ''
run: |
# Write JSON in readable format
START_TIME=$(date +%s)
COMMENT_JSON=$(cat <<EOF
{
"start_time": "${START_TIME}",
"stop_time": null,
"status": "running",
"result": null
"result": null,
"last_test_time": null
}
EOF)
echo "$COMMENT_JSON"
# Convert to single line and store
COMMENT_BODY=$(echo "$COMMENT_JSON" | tr -d '\n')
echo $COMMENT_BODY
COMMENT_BODY=$(echo "$COMMENT_JSON" | jq -c .)
echo "comment_body=$COMMENT_BODY" >> $GITHUB_OUTPUT
- name: Add running status to sticky comment
uses: marocchino/sticky-pull-request-comment@v2
if: steps.get_existing_comment.outputs.previous_comment_id == ''
with:
header: running_status
number: ${{ env.PR_NUMBER }}
Expand Down

0 comments on commit 7661cb0

Please sign in to comment.