refactor ci pipeline
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2019-10-16 22:24:46 +02:00
parent 1a1873c77a
commit ad8452b3d4
5 changed files with 224 additions and 135 deletions

View File

@ -1,107 +1,148 @@
local AnsibleVersions(version="latest", package="ansible") = {
name: "ansible-" + version,
image: "python:3.7",
pull: "always",
environment: {
PY_COLORS: 1
},
commands: [
"pip install " + package + " ansible-later~=0.2.0 -qq",
"git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy",
"ansible-later -c ~/policy/config.yml"
],
depends_on: [
"clone",
],
};
local PipelineLinting = {
kind: "pipeline",
name: "linting",
platform: {
os: "linux",
arch: "amd64",
},
steps: [
AnsibleVersions(version="latest", package="ansible"),
AnsibleVersions(version="master", package="git+https://github.com/ansible/ansible.git@devel"),
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
},
kind: "pipeline",
name: "linting",
platform: {
os: "linux",
arch: "amd64",
},
steps: [
{
name: "ansible-later",
image: "xoxys/ansible-later:latest",
environment: {
PY_COLORS: 1
},
commands: [
"git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy",
"ansible-later -c ~/policy/config.yml"
],
},
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
},
};
local PipelineDeployment = {
kind: "pipeline",
name: "deployment",
platform: {
os: "linux",
arch: "amd64",
},
workspace: {
base: "/drone/src",
path: "xoxys.droneci"
},
steps: [
{
name: "molecule",
image: "xoxys/molecule:do-linux-amd64",
pull: "always",
environment: {
DO_API_KEY: { "from_secret": "do_api_key" },
USER: "root",
MOLECULE_CUSTOM_MODULES_REPO: "https://gitea.rknet.org/ansible/custom_modules",
MOLECULE_CUSTOM_FILTERS_REPO: "https://gitea.rknet.org/ansible/custom_filters",
PY_COLORS: 1
},
commands: [
"/bin/bash /docker-entrypoint.sh",
"molecule test -s default",
],
kind: "pipeline",
name: "deployment",
platform: {
os: "linux",
arch: "amd64",
},
concurrency: {
limit: 1
},
workspace: {
base: "/drone/src",
path: "xoxys.droneci"
},
steps: [
{
name: "ansible-molecule",
image: "xoxys/molecule:do-linux-amd64",
environment: {
DO_API_KEY: { "from_secret": "do_api_key" },
USER: "root",
MOLECULE_CUSTOM_MODULES_REPO: "https://gitea.rknet.org/ansible/custom_modules",
MOLECULE_CUSTOM_FILTERS_REPO: "https://gitea.rknet.org/ansible/custom_filters",
PY_COLORS: 1
},
commands: [
"/bin/bash /docker-entrypoint.sh",
"molecule test -s default",
],
},
],
depends_on: [
"linting",
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**"],
},
],
depends_on: [
"linting",
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**"],
},
};
local PipelineNotifications = {
kind: "pipeline",
name: "notifications",
platform: {
os: "linux",
arch: "amd64",
},
clone: {
disable: true,
},
steps: [
{
name: "matrix",
image: "plugins/matrix",
settings: {
homeserver: "https://matrix.rknet.org",
roomid: "MtidqQXWWAtQcByBhH:rknet.org",
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}",
username: { "from_secret": "matrix_username" },
password: { "from_secret": "matrix_password" },
},
local PipelineDocumentation = {
kind: "pipeline",
name: "documentation",
platform: {
os: "linux",
arch: "amd64",
},
steps: [
{
name: "ansible-doctor",
image: "xoxys/ansible-doctor:latest",
environment: {
ANSIBLE_DOCTOR_LOG_LEVEL: "INFO",
ANSIBLE_DOCTOR_FORCE_OVERWRITE: true,
ANSIBLE_DOCTOR_EXCLUDE_FILES: "molecule/",
ANSIBLE_DOCTOR_CUSTOM_HEADER: "HEADER.md",
PY_COLORS: 1
},
},
{
name: "push-to-repo",
image: "plugins/git-action:latest",
settings: {
actions: ["commit", "push"],
author_email: "shipper@rknet.org",
author_name: "DroneShipper",
branch: "master",
message: "[SKIP CI] update readme",
remote: "https://gitea.rknet.org/ansible/xoxys.droneci",
netrc_machine: "gitea.rknet.org",
netrc_username: {"from_secret": "gitea_username"},
netrc_password: {"from_secret": "gitea_token"},
},
when: {
ref: ["refs/heads/master"],
},
},
],
depends_on: [
"deployment",
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
},
};
local PipelineNotification= {
kind: "pipeline",
name: "notification",
platform: {
os: "linux",
arch: "amd64",
},
clone: {
disable: true,
},
steps: [
{
name: "matrix",
image: "plugins/matrix",
settings: {
homeserver: { "from_secret": "matrix_homeserver" },
roomid: { "from_secret": "matrix_roomid" },
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}",
username: { "from_secret": "matrix_username" },
password: { "from_secret": "matrix_password" },
},
},
],
depends_on: [
"documentation",
],
trigger: {
status: [ "success", "failure" ],
ref: ["refs/heads/master", "refs/tags/**"],
},
],
depends_on: [
"deployment",
],
trigger: {
status: [ "success", "failure" ],
ref: ["refs/heads/master", "refs/tags/**"],
},
};
[
PipelineLinting,
PipelineDeployment,
PipelineNotifications,
PipelineLinting,
PipelineDeployment,
PipelineDocumentation,
PipelineNotification,
]

View File

@ -7,29 +7,13 @@ platform:
arch: amd64
steps:
- name: ansible-latest
pull: always
image: python:3.7
- name: ansible-later
image: xoxys/ansible-later:latest
commands:
- pip install ansible ansible-later~=0.2.0 -qq
- git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy
- ansible-later -c ~/policy/config.yml
environment:
PY_COLORS: 1
depends_on:
- clone
- name: ansible-master
pull: always
image: python:3.7
commands:
- "pip install git+https://github.com/ansible/ansible.git@devel ansible-later~=0.2.0 -qq"
- git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy
- ansible-later -c ~/policy/config.yml
environment:
PY_COLORS: 1
depends_on:
- clone
trigger:
ref:
@ -45,13 +29,15 @@ platform:
os: linux
arch: amd64
concurrency:
limit: 1
workspace:
base: /drone/src
path: xoxys.droneci
steps:
- name: molecule
pull: always
- name: ansible-molecule
image: xoxys/molecule:do-linux-amd64
commands:
- /bin/bash /docker-entrypoint.sh
@ -74,7 +60,54 @@ depends_on:
---
kind: pipeline
name: notifications
name: documentation
platform:
os: linux
arch: amd64
steps:
- name: ansible-doctor
image: xoxys/ansible-doctor:latest
environment:
ANSIBLE_DOCTOR_CUSTOM_HEADER: HEADER.md
ANSIBLE_DOCTOR_EXCLUDE_FILES: molecule/
ANSIBLE_DOCTOR_FORCE_OVERWRITE: true
ANSIBLE_DOCTOR_LOG_LEVEL: INFO
PY_COLORS: 1
- name: push-to-repo
image: plugins/git-action:latest
settings:
actions:
- commit
- push
author_email: "shipper@rknet.org"
author_name: DroneShipper
branch: master
message: "[SKIP CI] update readme"
netrc_machine: gitea.rknet.org
netrc_password:
from_secret: gitea_token
netrc_username:
from_secret: gitea_username
remote: https://gitea.rknet.org/ansible/xoxys.droneci
when:
ref:
- refs/heads/master
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- deployment
---
kind: pipeline
name: notification
platform:
os: linux
@ -87,10 +120,12 @@ steps:
- name: matrix
image: plugins/matrix
settings:
homeserver: https://matrix.rknet.org
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid: MtidqQXWWAtQcByBhH:rknet.org
roomid:
from_secret: matrix_roomid
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
username:
from_secret: matrix_username
@ -104,10 +139,10 @@ trigger:
- failure
depends_on:
- deployment
- documentation
---
kind: signature
hmac: e9eabb9d399e38f77f8fb1a28ee5579922fd93dcb7c766573c6ea7e03e02661c
hmac: 17f9b58b6ccc3675fe5d1b425680c2316f1a1d4002f35d3509dcb477c05c9b02
...

2
.gitignore vendored
View File

@ -9,5 +9,3 @@ __pycache__/
*.py[cod]
*$py.class
# ---> Molecule
.yamllint

4
HEADER.md Normal file
View File

@ -0,0 +1,4 @@
# xoxys.droneci
[![Build Status](https://drone.rknet.org/api/badges/ansible/xoxys.droneci/status.svg)](https://drone.rknet.org/ansible/xoxys.droneci)

View File

@ -4,8 +4,9 @@ droneci_service_directory: /var/lib/docker/services/drone-ci
droneci_docker_socket_path: /var/run/docker.sock
droneci_host: http://localhost
droneci_secret: myveryownsecret
# Path to the license key file
# droneci_license_key: # defaults to not set
# @var droneci_license_key:description Path to the license key file
# @var droneci_license_key: $ "_unset_"
droneci_restart_policy: always
@ -13,16 +14,25 @@ droneci_server_container_name: drone-server
droneci_server_image: "drone/drone:{{ droneci_version }}"
droneci_server_exposed_port: 8080
droneci_server_exposed_ip: 127.0.0.1
# droneci_server_memory_limit: 512m # defaults to not set
# droneci_server_memory_reservation: 256m # defaults to not set
# droneci_server_extra_hosts: []
# @var droneci_server_memory_limit: $ "_unset_"
# @var droneci_server_memory_limit:example: 512m
# @var droneci_server_memory_reservation: $ "_unset_"
# @var droneci_server_memory_reservation:example: 256m
droneci_server_extra_hosts: []
droneci_server_privileged: False
droneci_agent_container_name: drone-agent
droneci_agent_image: "drone/agent:{{ droneci_version }}"
droneci_agent_capacity: 2
# droneci_agent_memory_limit: 512m # defaults to not set
# droneci_agent_memory_reservation: 256m # defaults to not set
# @var droneci_agent_memory_limit:example 512m
# @var droneci_agent_memory_limit: $ "_unset_"
# @var droneci_agent_memory_reservation:example 256m
# @var droneci_agent_memory_reservation: $ "_unset_"
droneci_agent_privileged: False
droneci_postgres_enabled: False
@ -63,16 +73,17 @@ droneci_postgres_user:
droneci_gitea_enabled: False
droneci_gitea_server: http://my-git.example.com
droneci_gitea_skip_verify: False
# To enable gitea oauth set both
# droneci_gitea_oauth_client_id: 1111-222-33333-44444 # defaults to not set
# droneci_gitea_oauth_client_secret: 1234abcd5678efgh # defaults to not set
# droneci_admin: # defaults to not set
# droneci_http_proxy: # defaults to not set
# droneci_https_proxy: # defaults to not set
# droneci_no_proxy: (see below)
# - drone-server
# - drone-agent
# @var droneci_admin: $ "_unset_"
# @var droneci_http_proxy: $ "_unset_"
# @var droneci_https_proxy: $ "_unset_"
# @var droneci_no_proxy: $ ["drone-server", "drone-agent"]
droneci_no_proxy: []
droneci_iptables_enabled: False
droneci_open_ports: