pikaur_builder/piker/template/drone.yml.j2

261 lines
4.9 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 }}
platform:
os: linux
arch: amd64
workspace:
path: /drone
steps:
- name: cache-init_{{ pkg }}
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 }}
path: /build2
- name: etc_{{ pkg }}
path: /cache_stage/etc
- name: opt_{{ pkg }}
path: /cache_stage/opt
- name: var_{{ pkg }}
path: /cache_stage/var
- name: usr_{{ pkg }}
path: /cache_stage/usr
- name: output
path: /output
- name: cache-acl_{{ pkg }}
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 }}
path: /build
- name: etc_{{ pkg }}
path: /etc
- name: opt_{{ pkg }}
path: /opt
- name: var_{{ pkg }}
path: /var
- name: usr_{{ pkg }}
path: /usr
- name: build_{{ pkg }}
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
commands:
- |
if [ -f /output/lock ]; then
while [ -f /output/lock ]; do
sleep 10
echo "Waiting $(cat /output/lock)"
done
else
echo "{{ pkg }}" >> /output/lock
fi
- |
set -euo pipefail
/usr/bin/pikaur -G --noconfirm {{ pkg }}|tee /output/{{ pkg }}.log
/usr/bin/pikaur -Py --keepbuilddeps --noconfirm {{ pkg }}/PKGBUILD|tee /output/{{ pkg }}.log
- rm -f /output/lock
volumes:
- name: build_{{ pkg }}
path: /build
- name: etc_{{ pkg }}
path: /etc
- name: opt_{{ pkg }}
path: /opt
- name: var_{{ pkg }}
path: /var
- name: usr_{{ pkg }}
path: /usr
- name: output
path: /output
volumes:
- name: build_{{ pkg }}
host:
path: {{ base_path }}/{{ pkg }}
- name: etc_{{ pkg }}
host:
path: {{ base_path }}/etc/{{ pkg }}
- name: opt_{{ pkg }}
host:
path: {{ base_path }}/opt/{{ pkg }}
- name: var_{{ pkg }}
host:
path: {{ base_path }}/var/{{ pkg }}
- name: usr_{{ pkg }}
host:
path: {{ base_path }}/usr/{{ pkg }}
- 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 }}
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 }}] FAILURE"
commands:
- /sendmail.sh /output/{{ pkg }}.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 }}
{% 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 }}
{%- endfor %}