add branch validation to queue

This commit is contained in:
2025-12-22 15:09:37 +01:00
parent a4205f513d
commit 53aa6469ba
3 changed files with 60 additions and 5 deletions

View File

@@ -252,6 +252,29 @@ def submit_step1():
'output': f'Exception: {str(e)}' 'output': f'Exception: {str(e)}'
}) })
@jobs_bp.route('/submit/step2', methods=['POST'])
@login_required
def submit_step2():
branch_name = request.form.get('branch_name')
scenario_map_json = request.form.get('scenario_map')
selected_scenarios_json = request.form.get('selected_scenarios')
try:
scenario_map = json.loads(scenario_map_json) if scenario_map_json else {}
selected_scenarios = json.loads(selected_scenarios_json) if selected_scenarios_json else []
except json.JSONDecodeError:
flash('Invalid scenario data', 'error')
return redirect(url_for('jobs.submit'))
if not selected_scenarios:
flash('Please select at least one scenario', 'error')
return redirect(url_for('jobs.submit'))
return render_template('jobs/submit_step3.html',
branch_name=branch_name,
scenarios=selected_scenarios,
scenario_map=scenario_map)
@jobs_bp.route('/submit/step2-validated', methods=['POST']) @jobs_bp.route('/submit/step2-validated', methods=['POST'])
@login_required @login_required
def submit_step2_validated(): def submit_step2_validated():
@@ -312,28 +335,45 @@ def submit_step2():
@login_required @login_required
def submit_step3(): def submit_step3():
branch_name = request.form.get('branch_name') branch_name = request.form.get('branch_name')
scenarios = request.form.get('scenarios') scenarios_json = request.form.get('scenarios')
scenario_map_json = request.form.get('scenario_map')
environment = request.form.get('environment') environment = request.form.get('environment')
try:
scenarios = json.loads(scenarios_json) if scenarios_json else []
scenario_map = json.loads(scenario_map_json) if scenario_map_json else {}
except json.JSONDecodeError:
flash('Invalid scenario data', 'error')
return redirect(url_for('jobs.submit'))
return render_template('jobs/submit_step4.html', return render_template('jobs/submit_step4.html',
branch_name=branch_name, branch_name=branch_name,
scenarios=scenarios, scenarios=scenarios,
scenario_map=scenario_map,
environment=environment) environment=environment)
@jobs_bp.route('/submit/final', methods=['POST']) @jobs_bp.route('/submit/final', methods=['POST'])
@login_required @login_required
def submit_final(): def submit_final():
branch_name = request.form.get('branch_name') branch_name = request.form.get('branch_name')
scenarios = request.form.get('scenarios') scenarios_json = request.form.get('scenarios')
scenario_map_json = request.form.get('scenario_map')
environment = request.form.get('environment') environment = request.form.get('environment')
test_mode = request.form.get('test_mode') test_mode = request.form.get('test_mode')
keep_devbenches = request.form.get('keep_devbenches') == 'on' keep_devbenches = request.form.get('keep_devbenches') == 'on'
reuse_results = request.form.get('reuse_results') == 'on' reuse_results = request.form.get('reuse_results') == 'on'
try:
scenarios = json.loads(scenarios_json) if scenarios_json else []
scenario_map = json.loads(scenario_map_json) if scenario_map_json else {}
except json.JSONDecodeError:
flash('Invalid scenario data', 'error')
return redirect(url_for('jobs.submit'))
job = Job( job = Job(
user_id=current_user.id, user_id=current_user.id,
branch_name=branch_name, branch_name=branch_name,
scenarios=scenarios, scenarios=json.dumps(scenarios), # Store as JSON string
environment=environment, environment=environment,
test_mode=test_mode, test_mode=test_mode,
keep_devbenches=keep_devbenches, keep_devbenches=keep_devbenches,
@@ -344,7 +384,7 @@ def submit_final():
db.session.add(job) db.session.add(job)
db.session.commit() db.session.commit()
# TODO: Start test execution in background # TODO: Start test execution in background using scenario_map
flash('Test job submitted successfully', 'success') flash('Test job submitted successfully', 'success')
return redirect(url_for('dashboard.index')) return redirect(url_for('dashboard.index'))

View File

@@ -29,9 +29,23 @@
</div> </div>
</div> </div>
<div style="background: #eff6ff; padding: 15px; border-radius: 8px; margin-bottom: 20px;">
<strong>Branch:</strong> {{ branch_name }}<br>
<strong>Selected Scenarios:</strong> {{ scenarios|length }} scenario{{ 's' if scenarios|length != 1 else '' }}
<details style="margin-top: 10px;">
<summary style="cursor: pointer; color: var(--primary);">View selected scenarios</summary>
<ul style="margin-top: 10px; padding-left: 20px;">
{% for scenario in scenarios %}
<li style="font-size: 12px; color: #6b7280;">{{ scenario }}</li>
{% endfor %}
</ul>
</details>
</div>
<form method="POST" action="{{ url_for('jobs.submit_step3') }}"> <form method="POST" action="{{ url_for('jobs.submit_step3') }}">
<input type="hidden" name="branch_name" value="{{ branch_name }}"> <input type="hidden" name="branch_name" value="{{ branch_name }}">
<input type="hidden" name="scenarios" value="{{ scenarios|tojson }}"> <input type="hidden" name="scenarios" value="{{ scenarios|tojson }}">
<input type="hidden" name="scenario_map" value="{{ scenario_map|tojson }}">
<div class="radio-group"> <div class="radio-group">
<label class="radio-item"> <label class="radio-item">

View File

@@ -31,7 +31,8 @@
<form method="POST" action="{{ url_for('jobs.submit_final') }}"> <form method="POST" action="{{ url_for('jobs.submit_final') }}">
<input type="hidden" name="branch_name" value="{{ branch_name }}"> <input type="hidden" name="branch_name" value="{{ branch_name }}">
<input type="hidden" name="scenarios" value="{{ scenarios }}"> <input type="hidden" name="scenarios" value="{{ scenarios|tojson }}">
<input type="hidden" name="scenario_map" value="{{ scenario_map|tojson }}">
<input type="hidden" name="environment" value="{{ environment }}"> <input type="hidden" name="environment" value="{{ environment }}">
<div class="radio-group"> <div class="radio-group">