pikaur_builder/piker/template/drone.yml.j2

269 lines
5.3 KiB
Django/Jinja

---
kind: pipeline
type: docker
name: pre_clean
platform:
os: linux
arch: amd64
workspace:
path: /drone
steps:
- name: remove-locks
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
user: root
commands:
- rm -f /output/lock
volumes:
- name: output
path: /output
volumes:
- name: output
host:
path: {{ base_path }}/output
{% for pkg in pkgs %}
---
kind: pipeline
type: docker
name: {{ pkg.name }}
platform:
os: linux
arch: amd64
workspace:
path: /drone
steps:
- name: cache-init_{{ pkg.name }}
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
user: root
commands:
- |
if ! [ "$(ls -A /cache_stage/etc)" ]; then
cp -r /etc/. /cache_stage/etc/
getfacl -p -R /etc > /cache_stage/etc/permissions.acl
fi
- |
if ! [ "$(ls -A /cache_stage/opt)" ]; then
cp -r /opt/. /cache_stage/opt/
getfacl -p -R /opt > /cache_stage/opt/permissions.acl
fi
- |
if ! [ "$(ls -A /cache_stage/var)" ]; then
cp -r /var/. /cache_stage/var/
getfacl -p -R /var > /cache_stage/var/permissions.acl
fi
- |
if ! [ "$(ls -A /cache_stage/usr)" ]; then
cp -r /usr/. /cache_stage/usr/
getfacl -p -R /usr > /cache_stage/usr/permissions.acl
fi
- |
if ! [ "$(ls -A /build2)" ]; then
cp -r /build/. /build2/
getfacl -p -R /usr > /build2/permissions.acl
fi
- chmod a+rw /output
volumes:
- name: build_{{ pkg.name }}
path: /build2
- name: etc_{{ pkg.name }}
path: /cache_stage/etc
- name: opt_{{ pkg.name }}
path: /cache_stage/opt
- name: var_{{ pkg.name }}
path: /cache_stage/var
- name: usr_{{ pkg.name }}
path: /cache_stage/usr
- name: output
path: /output
- name: cache-acl_{{ pkg.name }}
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
user: root
commands:
- setfacl --restore=/etc/permissions.acl
- setfacl --restore=/opt/permissions.acl
- setfacl --restore=/var/permissions.acl
- setfacl --restore=/usr/permissions.acl
- setfacl --restore=/build/permissions.acl
- chown -R {{ user_uid }}:{{ user_gid }} /build
volumes:
- name: build_{{ pkg.name }}
path: /build
- name: etc_{{ pkg.name }}
path: /etc
- name: opt_{{ pkg.name }}
path: /opt
- name: var_{{ pkg.name }}
path: /var
- name: usr_{{ pkg.name }}
path: /usr
- name: build_{{ pkg.name }}
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
commands:
{%- for cmd in pkg.pre_cmd|default([]) %}
- {{ cmd }}
{%- endfor %}
- |
if [ -f /output/lock ]; then
while [ -f /output/lock ]; do
sleep 10
echo "Waiting $(cat /output/lock)"
done
else
echo "{{ pkg.name }}" >> /output/lock
fi
- |
set -euo pipefail
cd /build
rm -rf {{ pkg.name }}
/usr/bin/pikaur -G --noconfirm {{ pkg.name }} 2>&1|tee /output/{{ pkg.name }}.log
/usr/bin/pikaur -Py --keepbuilddeps --noconfirm {{ pkg.name }}/PKGBUILD 2>&1|tee /output/{{ pkg.name }}.log
{%- for cmd in pkg.post_cmd|default([]) %}
- {{ cmd }}
{%- endfor %}
- rm -f /output/lock
volumes:
- name: build_{{ pkg.name }}
path: /build
- name: etc_{{ pkg.name }}
path: /etc
- name: opt_{{ pkg.name }}
path: /opt
- name: var_{{ pkg.name }}
path: /var
- name: usr_{{ pkg.name }}
path: /usr
- name: output
path: /output
volumes:
- name: build_{{ pkg.name }}
host:
path: {{ base_path }}/{{ pkg.name }}
- name: etc_{{ pkg.name }}
host:
path: {{ base_path }}/etc/{{ pkg.name }}
- name: opt_{{ pkg.name }}
host:
path: {{ base_path }}/opt/{{ pkg.name }}
- name: var_{{ pkg.name }}
host:
path: {{ base_path }}/var/{{ pkg.name }}
- name: usr_{{ pkg.name }}
host:
path: {{ base_path }}/usr/{{ pkg.name }}
- name: output
host:
path: {{ base_path }}/output
trigger:
branch:
- master
event:
- push
- cron
depends_on:
- pre_clean
---
kind: pipeline
type: docker
name: notify_failure-{{ pkg.name }}
clone:
disable: true
steps:
- name: notify_failure
pull: if-not-exists
image: leophys/mailer:{{ mailer_version }}
environment:
M_SERVER_ADDRESS:
from_secret: m_server_address
M_USER:
from_secret: m_user
M_PASSWORD:
from_secret: m_password
M_FROM:
from_secret: m_from
M_TO:
from_secret: m_to
M_SUB: "[{{ pkg.name }}] FAILURE"
commands:
- /sendmail.sh /output/{{ pkg.name }}.log
volumes:
- name: output
path: /output
- name: clean_lock
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
user: root
commands:
- rm -f /output/lock
volumes:
- name: output
path: /output
volumes:
- name: output
host:
path: {{ base_path }}/output
trigger:
status:
- failure
depends_on:
- {{ pkg.name }}
{% endfor %}
---
kind: pipeline
type: docker
name: notify_success
clone:
disable: true
steps:
- name: notify_success
pull: if-not-exists
image: leophys/mailer:{{ mailer_version }}
environment:
M_SERVER_ADDRESS:
from_secret: m_server_address
M_USER:
from_secret: m_user
M_PASSWORD:
from_secret: m_password
M_FROM:
from_secret: m_from
M_TO:
from_secret: m_to
M_SUB: "[archlinux] SUCCESS"
M_TEXT: "Success building archlinux packages"
trigger:
status:
- success
depends_on:
{%- for pkg in pkgs %}
- {{ pkg.name }}
{%- endfor %}