2022-03-14 14:58:20 +13:00
|
|
|
// Distros to Test on ;)
|
|
|
|
|
local distros = ['centos7',
|
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:
|
2022-11-01 22:29:23 +13:00
|
|
|
{ host:
|
|
|
|
|
{ from_secret: 'EMAIL_HOST' },
|
2022-03-14 17:08:34 +13:00
|
|
|
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-04-02 22:41:07 +13:00
|
|
|
pull: true,
|
2022-04-02 22:15:36 +13:00
|
|
|
image: 'guisea/ansible-molecule:alpine-latest',
|
2022-03-14 17:08:34 +13:00
|
|
|
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-11-02 15:00:12 +13:00
|
|
|
when:
|
2022-11-02 15:21:40 +13:00
|
|
|
{ event: {exclude: ['tag']},
|
2022-11-02 15:18:36 +13:00
|
|
|
},
|
2022-03-15 14:04:31 +13:00
|
|
|
};
|
2022-03-14 14:18:48 +13:00
|
|
|
|
2022-11-02 15:40:29 +13:00
|
|
|
local gen_release() =
|
|
|
|
|
{kind: 'pipeline',
|
|
|
|
|
type: 'docker',
|
2022-11-02 16:05:31 +13:00
|
|
|
image: 'guisea/ansible-molecule:alpine-latest',
|
2022-11-02 15:42:34 +13:00
|
|
|
name: 'Generate Release',
|
2022-11-02 15:40:29 +13:00
|
|
|
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}',
|
|
|
|
|
'tar -czf ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz ./*', // Create an archive of the role
|
2022-11-02 15:44:46 +13:00
|
|
|
'curl --user ${GITEA_USER}:${GITEA_TOKEN} --upload-file ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz https://${GITEA_URL}/api/packages/${GITEA_REPOUSER}/generic/ansible-role-common/${DRONE_TAG}/${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz',
|
2022-11-02 15:40:29 +13:00
|
|
|
],
|
|
|
|
|
when:
|
|
|
|
|
{ event: {include: ['tag']},
|
|
|
|
|
},
|
2022-11-02 15:43:20 +13:00
|
|
|
};
|
2022-11-02 15:40:29 +13:00
|
|
|
|
2022-11-02 16:00:39 +13:00
|
|
|
local gen_pipeline_release() =
|
|
|
|
|
{kind: 'pipeline',
|
|
|
|
|
type: 'docker',
|
|
|
|
|
name: 'Generate release from tag',
|
|
|
|
|
steps:
|
|
|
|
|
[gen_release()],
|
|
|
|
|
when:
|
|
|
|
|
{ event: {include: ['tag']},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
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('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',
|
2022-11-02 15:40:29 +13:00
|
|
|
name: 'Notify normal',
|
2022-11-02 16:09:27 +13:00
|
|
|
clone_disable: true,
|
2022-03-15 14:35:29 +13:00
|
|
|
steps: [email_notification()],
|
|
|
|
|
when:
|
2022-11-02 15:40:29 +13:00
|
|
|
{ status: [ 'success', 'failure' ] ,
|
|
|
|
|
event: {exclude: ['tag']},
|
|
|
|
|
},
|
2022-03-15 14:04:31 +13:00
|
|
|
depends_on:
|
|
|
|
|
['Test on %(distro)s' % { distro: distro }
|
|
|
|
|
for distro in distros]
|
2022-11-02 15:43:55 +13:00
|
|
|
},
|
2022-11-02 15:59:12 +13:00
|
|
|
gen_pipeline_release(),
|
2022-11-02 15:47:23 +13:00
|
|
|
{kind: 'pipeline',
|
|
|
|
|
type: 'docker',
|
2022-11-02 16:09:27 +13:00
|
|
|
clone_disable: true,
|
2022-11-02 15:47:23 +13:00
|
|
|
name: 'Notify Tagged release',
|
|
|
|
|
steps: [email_notification()],
|
|
|
|
|
when:
|
|
|
|
|
{ status: [ 'success', 'failure' ] ,
|
|
|
|
|
event: {include: ['tag']},
|
|
|
|
|
},
|
|
|
|
|
depends_on:
|
2022-11-02 16:01:57 +13:00
|
|
|
['Generate release from tag']
|
2022-11-02 15:47:23 +13:00
|
|
|
},
|
2022-03-14 14:58:20 +13:00
|
|
|
]
|