Artem Goncharov fe58fb9947 Prepare git patch and archive for rust package
Apply the generated sources on top of the target repository and create
patch file. In addition to that save complete content as job artifacts.

post job is pushing changes to the upstream repository (using public SSH
key of repository set by Zuul and added as a deployment key). PR is not
created, since that requires additionally separate API key.

Change-Id: I090b87e05ede95f8542a427207bea711e5cc5df4
2024-07-31 08:44:09 +02:00

73 lines
1.9 KiB
YAML

---
- hosts: all
vars:
archive_path: "{{ ansible_user_dir }}/archive.tar.gz"
tasks:
- name: "Ensure local output dirs"
delegate_to: localhost
ansible.builtin.file:
path: "{{ zj_output_dir }}"
state: directory
mode: 0755
with_items:
- "{{ zuul.executor.work_root }}/artifacts"
loop_control:
loop_var: zj_output_dir
- name: "Archive generated code"
community.general.archive:
path: "{{ codegenerator_base_dir }}/wrk/rust"
dest: "{{ archive_path }}"
- name: "Collect archived generated code"
ansible.posix.synchronize:
dest: "{{ zj_output.dest }}"
mode: pull
src: "{{ zj_output.src }}"
verify_host: true
owner: false
group: false
loop:
- dest: "{{ zuul.executor.work_root }}/artifacts/"
src: "{{ archive_path }}"
loop_control:
loop_var: zj_output
- name: "Return source code artifact to Zuul"
zuul_return:
data:
zuul:
artifacts:
- name: "Code changes"
url: "artifacts/archive.tar.gz"
metadata:
type: "content"
- name: Find generated patch file
ansible.builtin.stat:
path: "{{ patch_path }}"
register: patch_stat
- name: "Collect patch file"
ansible.posix.synchronize:
dest: "{{ zuul.executor.work_root }}/artifacts/"
mode: pull
src: "{{ patch_path }}"
verify_host: true
owner: false
group: false
when:
- "patch_stat.stat.exists"
- name: "Return patch artifact to Zuul"
zuul_return:
data:
zuul:
artifacts:
- name: "Git patch"
url: "artifacts/{{ zuul.change }}.patch"
metadata:
type: "rust_patch"
when:
- "patch_stat.stat.exists"