Skip to content
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

[jump_ci] Improve the reliability #638

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions projects/jump_ci/toolbox/jump_ci_prepare_topsail/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

- name: Save git ref
set_fact:
git_ref: "\

Check warning on line 69 in projects/jump_ci/toolbox/jump_ci_prepare_topsail/tasks/main.yml

View workflow job for this annotation

GitHub Actions / build

jinja[spacing]

Jinja2 spacing could be improved: {% if jump_ci_prepare_topsail_git_ref -%} {{ jump_ci_prepare_topsail_git_ref }} {%- elif jump_ci_prepare_topsail_pr_number -%} refs/pull/{{ jump_ci_prepare_topsail_pr_number }}/merge {%- else -%} main {%- endif -%} -> {% if jump_ci_prepare_topsail_git_ref -%} {{ jump_ci_prepare_topsail_git_ref }}{%- elif jump_ci_prepare_topsail_pr_number -%} refs/pull/{{ jump_ci_prepare_topsail_pr_number }}/merge{%- else -%} main{%- endif -%}
{% if jump_ci_prepare_topsail_git_ref -%}
{{ jump_ci_prepare_topsail_git_ref }}
{%- elif jump_ci_prepare_topsail_pr_number -%}
Expand Down Expand Up @@ -127,14 +127,31 @@
register: has_image
failed_when: false

- name: List all the old images to delete

Check failure on line 130 in projects/jump_ci/toolbox/jump_ci_prepare_topsail/tasks/main.yml

View workflow job for this annotation

GitHub Actions / build

risky-shell-pipe

Shells that use pipes should set the pipefail option.
shell:
podman image ls
--filter until=4h
--filter label=name=topsail
--filter 'label=preserve!=true'
--format json
| jq -r '.[] | select(.Containers == 0) | .Id'
register: podman_images_to_delete_cmd

# To add the 'preserve=true' label:
#
# CONTAINER_NAME=localhost/topsail:main
# LABEL="preserve=true"
# echo "FROM $CONTAINER_NAME" | podman build --label "$LABEL" -t "$CONTAINER_NAME" -

- name: Prune old images
command:
podman image prune --force
--filter until=4h
--filter label=jump-ci=true
podman image rm "{image_id}"
when:
- jump_ci_prepare_topsail_cleanup_old_pr_images
- has_image.rc != 0
loop: "{{ podman_images_to_delete_cmd.stdout_lines }}"
loop_control:
loop_var: image_id

- name: "Build image as an update {{ image_full_name }}"
shell: |
Expand Down
Loading