Files
ansible-role-common/.drone.jsonnet

80 lines
1.9 KiB
Jsonnet
Raw Normal View History

2022-03-14 14:58:20 +13:00
// Distros to Test on ;)
local distros = ['centos7',
2022-03-14 15:29:51 +13:00
'centos8',
2022-03-14 15:34:17 +13:00
'rockylinux8',
2022-03-14 14:18:48 +13:00
'debian10',
'debian11'];
2022-03-14 17:08:34 +13:00
/* Configuration of DIND */
local docker_service() =
{
name: 'docker',
image: 'docker:dind',
privileged: true,
volumes: [{ name: 'dockersock', path: '/var/run' },],
};
local email_notification() =
{
2022-03-15 14:35:29 +13:00
name: 'notify by email',
2022-03-14 17:08:34 +13:00
image: 'drillster/drone-email',
settings:
{ host: 'mail.guise.net.nz',
username:
{ from_secret: 'EMAIL_USER' },
password:
{ from_secret: 'EMAIL_PASS' },
from: 'drone@guise.net.nz'
2022-03-15 14:38:46 +13:00
}
2022-03-14 17:08:34 +13:00
};
local test_distro(distribution) =
2022-03-15 16:19:35 +13:00
{
name: 'Molecule test on %(distribution)s' % { distribution: distribution },
volumes: [{ name: 'dockersock', path: '/var/run' },],
2022-03-14 17:08:34 +13:00
image: 'guisea/ansible-molecule:latest',
commands: [
'sleep 10', // give docker enough time to start
'mkdir ${DRONE_REPO_NAME}',
'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}',
'cd ${DRONE_REPO_NAME}',
'molecule test'
],
environment:
{ MOLECULE_DISTRO: '%(distribution)s' % { distribution: distribution }
},
};
2022-03-14 12:18:38 +13:00
2022-03-15 14:04:31 +13:00
local gen_pipeline(distro) =
{kind: 'pipeline',
2022-03-14 14:18:48 +13:00
type: 'docker',
name: 'Test on %(distro)s' % { distro: distro },
2022-03-15 07:14:13 +13:00
steps:
2022-03-15 14:18:00 +13:00
[test_distro(distro)],
2022-03-15 07:14:13 +13:00
services:
2022-03-15 14:16:05 +13:00
[docker_service()],
2022-03-14 14:18:48 +13:00
volumes:
2022-03-14 14:58:20 +13:00
[{
2022-03-14 14:18:48 +13:00
name: 'dockersock',
temp: {},
2022-03-17 12:09:58 +13:00
},],
2022-03-15 14:04:31 +13:00
};
2022-03-14 14:18:48 +13:00
2022-03-14 14:58:20 +13:00
// Generate the output
2022-03-15 07:14:13 +13:00
[
2022-03-15 14:04:31 +13:00
gen_pipeline('centos7'),
gen_pipeline('centos8'),
gen_pipeline('rockylinux8'),
gen_pipeline('debian10'),
gen_pipeline('debian11'),
2022-03-15 07:14:13 +13:00
{kind: 'pipeline',
2022-03-15 14:35:29 +13:00
type: 'docker',
name: 'Notify',
steps: [email_notification()],
when:
{ status: [ 'success', 'failure' ] },
2022-03-15 14:04:31 +13:00
depends_on:
['Test on %(distro)s' % { distro: distro }
for distro in distros]
}
2022-03-14 14:58:20 +13:00
]