-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Zombienet CI improvements #9172
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
Merged
Merged
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
5f2198a
ci: use matrix jobs for cumulus tests
lrubasze 293a36c
ci: tweaks
lrubasze bc2228d
ci: more tweaks
lrubasze 592e05e
ci: fix artifact naming
lrubasze 6ad19c9
ci: use matrix jobs for polkadot tests
lrubasze 73c33fd
ci: use matrix jobs for parachain template tests
lrubasze df33b5e
ci: use matrix jobs for substrate tests
lrubasze a32ff98
cleanup
lrubasze b63a19f
ci: some fixes
lrubasze dae6ad1
ci: flaky handling
lrubasze d8cf342
ci: generate test matrix
lrubasze 622ba2c
ci: generate test matrix for parachain-template tests
lrubasze a2d4f12
ci: generate test matrix for substrate tests
lrubasze 0f3bb8d
ci: generate test matrix for polkadot tests
lrubasze b5ecb02
Merge branch 'master' into lrubasze-zombienet-ci-improviements
lrubasze ec2a6b7
ci: fix test matrix setting
lrubasze a07bd16
ci: fix #2 test matrix setting
lrubasze 218632c
ci: fix #3 test matrix setting
lrubasze 084892c
ci: remove debug
lrubasze 77f0cca
ci: fix test-filter and job-name setting
lrubasze 991bf50
ci: unset rust envs
lrubasze 948f199
ci: cleanup
lrubasze 8efbb76
ci: zombienet readme added
lrubasze 6f85b7b
ci: zombienet readme tweaks
lrubasze 878cd39
Merge branch 'master' into lrubasze-zombienet-ci-improviements
lrubasze 743acb2
ci: add some comments on scripts
lrubasze faf8395
ci: zombienet readme improvements
lrubasze 3ac7075
Update .github/workflows/zombienet-reusable-preflight.yml
pepoviola e01a023
ci, try permissions
pepoviola 5acb494
ci, try permissions
pepoviola 8794302
add permissions
pepoviola ceaabca
Merge branch 'master' into lrubasze-zombienet-ci-improviements
lrubasze 67e6576
Merge branch 'master' into lrubasze-zombienet-ci-improviements
lrubasze 869031a
test update
lrubasze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Exit on error | ||
| # set -e | ||
|
|
||
| function dbg { | ||
| local msg="$@" | ||
|
|
||
| local tstamp=$(date "+%Y-%m-%d %T") | ||
| printf "%s - %s\n" "$tstamp" "$msg" | ||
| } | ||
|
|
||
| function write_job_results_to_csv { | ||
| local run_id="$1" | ||
| local branch="$2" | ||
| local csv_file="$3" | ||
|
|
||
| dbg "Writing job results for run $run_id to $csv_file" | ||
|
|
||
| # Get job details for the completed run, filtering only jobs starting with 'zombienet-' and with success or failure conclusions | ||
| gh run view "$run_id" --json jobs --jq \ | ||
| '.jobs[] | select(.name | startswith("zombienet-")) | | ||
| select(.conclusion == "success" or .conclusion == "failure") | | ||
| [.databaseId, .name, .conclusion, .startedAt, "'"$branch"'", .url] | @csv' >> "$csv_file" | ||
| } | ||
|
|
||
| # Parse command line arguments | ||
| WORKFLOW_FILE="" | ||
| BRANCH="" | ||
| MAX_RESULT_CNT=-1 | ||
| TEST_PATTERN="" | ||
|
|
||
| while getopts "w:b:m:p:h" opt; do | ||
| case $opt in | ||
| w) WORKFLOW_FILE="$OPTARG" ;; | ||
| b) BRANCH="$OPTARG" ;; | ||
| m) MAX_RESULT_CNT="$OPTARG" ;; | ||
| p) TEST_PATTERN="$OPTARG" ;; | ||
| h) echo "Usage: $0 -w <workflow-file> -b <branch> [-m max-triggers] [-p test-pattern]" | ||
| echo " -w: Workflow file (required)" | ||
| echo " -b: Branch name (required)" | ||
| echo " -m: Maximum number of triggers (optional, default: infinite)" | ||
| echo " -p: Test pattern for workflow input (optional)" | ||
| exit 0 ;; | ||
| \?) echo "Invalid option -$OPTARG" >&2 | ||
| echo "Use -h for help" | ||
| exit 1 ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ -z "$WORKFLOW_FILE" || -z "$BRANCH" ]]; then | ||
| echo "Error: Both workflow file (-w) and branch (-b) are required" | ||
| echo "Usage: $0 -w <workflow-file> -b <branch> [-m max-triggers] [-p test-pattern]" | ||
| echo "Use -h for help" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Create CSV file with headers | ||
| CSV_FILE="workflow_results_$(date +%Y%m%d_%H%M%S).csv" | ||
| echo "job_id,job_name,conclusion,started_at,branch,job_url" > "$CSV_FILE" | ||
| dbg "Created CSV file: $CSV_FILE" | ||
|
|
||
| dbg "Starting loop for workflow: $WORKFLOW_FILE on branch: $BRANCH" | ||
|
|
||
| TRIGGER_CNT=0 | ||
| RESULT_CNT=0 | ||
|
|
||
| while [[ $MAX_RESULT_CNT -eq -1 || $RESULT_CNT -lt $MAX_RESULT_CNT ]]; do | ||
|
|
||
| dbg "Waiting until workflow $WORKFLOW_FILE (branch: $BRANCH) jobs are completed" | ||
|
|
||
| while true ; do | ||
| echo "" | ||
| gh run list --workflow=$WORKFLOW_FILE -e workflow_dispatch -b $BRANCH -L 5 | ||
| sleep 2 | ||
| # if job is completed it should have non-empty conclusion field | ||
| ALL_JOBS_COMPLETED=$(gh run list --workflow=$WORKFLOW_FILE -e workflow_dispatch -b $BRANCH --json conclusion --jq 'all(.[]; .conclusion != "")') | ||
| if [[ "$ALL_JOBS_COMPLETED" == "true" ]]; then | ||
| break | ||
| fi | ||
| sleep 60 | ||
| done | ||
| dbg "Workflow $WORKFLOW_FILE (branch: $BRANCH) jobs completed" | ||
|
|
||
| # Skip the first iteration - latest run id is not the one we triggered here | ||
| if [ $TRIGGER_CNT -gt 0 ]; then | ||
| # Get the most recent completed run ID and write job results to CSV | ||
| LATEST_RUN_ID=$(gh run list --workflow=$WORKFLOW_FILE -e workflow_dispatch -b $BRANCH -L 1 --json databaseId --jq '.[0].databaseId') | ||
| write_job_results_to_csv "$LATEST_RUN_ID" "$BRANCH" "$CSV_FILE" | ||
| RESULT_CNT=$(( RESULT_CNT + 1 )) | ||
| fi | ||
|
|
||
| TRIGGER_CNT=$(( TRIGGER_CNT + 1 )) | ||
| dbg "Triggering #$TRIGGER_CNT workflow $WORKFLOW_FILE (branch: $BRANCH)" | ||
|
|
||
| if [[ -n "$TEST_PATTERN" ]]; then | ||
| gh workflow run "$WORKFLOW_FILE" --ref "$BRANCH" -f test_pattern="$TEST_PATTERN" | ||
| else | ||
| gh workflow run "$WORKFLOW_FILE" --ref "$BRANCH" | ||
| fi | ||
|
|
||
| dbg "Sleeping 60s" | ||
| sleep 60 | ||
| done | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| import argparse | ||
| import yaml | ||
| import json | ||
| import fnmatch | ||
|
|
||
| def parse_args(): | ||
| parser = argparse.ArgumentParser(description="Parse test matrix YAML file with optional filtering") | ||
| parser.add_argument("--matrix", required=True, help="Path to the YAML matrix file") | ||
| parser.add_argument("--flaky-tests", default="", help="Newline-separated list of flaky job names") | ||
| parser.add_argument("--test-pattern", default="", help="Pattern to match job_name (substring or glob)") | ||
| return parser.parse_args() | ||
|
|
||
| def load_jobs(matrix_path): | ||
| with open(matrix_path, "r") as f: | ||
| return yaml.safe_load(f) | ||
|
|
||
| def filter_jobs(jobs, flaky_tests, test_pattern): | ||
| flaky_set = set(name.strip() for name in flaky_tests.splitlines() if name.strip()) | ||
| filtered = [] | ||
|
|
||
| for job in jobs: | ||
| name = job.get("job-name", "") | ||
|
|
||
| # If test_pattern provided then don't care about flaky tests, just check test_pattern | ||
| if test_pattern and len(test_pattern) > 0: | ||
| if fnmatch.fnmatch(name, f"*{test_pattern}*"): | ||
| filtered.append(job) | ||
| elif name not in flaky_set: | ||
| filtered.append(job) | ||
|
|
||
| return filtered | ||
|
|
||
| def main(): | ||
| args = parse_args() | ||
| jobs = load_jobs(args.matrix) | ||
| result = filter_jobs(jobs, args.flaky_tests, args.test_pattern) | ||
| print(json.dumps(result)) | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.