This commit is contained in:
Robert Kaussow 2020-01-16 11:27:46 +01:00
parent 7292e0ef37
commit 32f40b56f3
15 changed files with 625 additions and 283 deletions

View File

@ -1,300 +1,350 @@
local PythonVersion(pyversion="3.5") = { local PythonVersion(pyversion='3.5') = {
name: "python" + std.strReplace(pyversion, '.', '') + "-pytest", name: 'python' + std.strReplace(pyversion, '.', '') + '-pytest',
image: "python:" + pyversion, image: 'python:' + pyversion,
pull: "always", environment: {
environment: { PY_COLORS: 1,
PY_COLORS: 1 },
}, commands: [
commands: [ 'pip install -r test-requirements.txt -qq',
"pip install -r test-requirements.txt -qq", 'pip install -qq .',
"pip install -qq .", 'ansible-doctor --help',
"ansible-doctor --help", ],
], depends_on: [
depends_on: [ 'clone',
"clone", ],
],
}; };
local PipelineLint = { local PipelineLint = {
kind: "pipeline", kind: 'pipeline',
name: "lint", name: 'lint',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
{ {
name: "flake8", name: 'flake8',
image: "python:3.7", image: 'python:3.7',
pull: "always", environment: {
environment: { PY_COLORS: 1,
PY_COLORS: 1 },
}, commands: [
commands: [ 'pip install -r test-requirements.txt -qq',
"pip install -r test-requirements.txt -qq", 'pip install -qq .',
"pip install -qq .", 'flake8 ./ansibledoctor',
"flake8 ./ansibledoctor", ],
],
},
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
}, },
],
trigger: {
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
},
}; };
local PipelineTest = { local PipelineTest = {
kind: "pipeline", kind: 'pipeline',
name: "test", name: 'test',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
PythonVersion(pyversion="3.5"), PythonVersion(pyversion='3.5'),
PythonVersion(pyversion="3.6"), PythonVersion(pyversion='3.6'),
PythonVersion(pyversion="3.7"), PythonVersion(pyversion='3.7'),
PythonVersion(pyversion="3.8-rc"), PythonVersion(pyversion='3.8-rc'),
], ],
trigger: { depends_on: [
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"], 'lint',
}, ],
depends_on: [ trigger: {
"lint", ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
], },
}; };
local PipelineSecurity = { local PipelineSecurity = {
kind: "pipeline", kind: 'pipeline',
name: "security", name: 'security',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
{ {
name: "bandit", name: 'bandit',
image: "python:3.7", image: 'python:3.7',
pull: "always", environment: {
environment: { PY_COLORS: 1,
PY_COLORS: 1 },
}, commands: [
commands: [ 'pip install -r test-requirements.txt -qq',
"pip install -r test-requirements.txt -qq", 'pip install -qq .',
"pip install -qq .", 'bandit -r ./ansibledoctor -x ./ansibledoctor/tests',
"bandit -r ./ansibledoctor -x ./ansibledoctor/tests", ],
],
},
],
depends_on: [
"test",
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
}, },
],
depends_on: [
'test',
],
trigger: {
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
},
}; };
local PipelineBuildPackage = { local PipelineBuildPackage = {
kind: "pipeline", kind: 'pipeline',
name: "build-package", name: 'build-package',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
},
steps: [
{
name: 'build',
image: 'python:3.7',
commands: [
'python setup.py sdist bdist_wheel',
],
}, },
steps: [ {
{ name: 'checksum',
name: "build", image: 'alpine',
image: "python:3.7", commands: [
pull: "always", 'cd dist/ && sha256sum * > ../sha256sum.txt',
commands: [ ],
"python setup.py sdist bdist_wheel",
]
},
{
name: "checksum",
image: "alpine",
pull: "always",
commands: [
"cd dist/ && sha256sum * > ../sha256sum.txt"
],
},
{
name: "publish-github",
image: "plugins/github-release",
pull: "always",
settings: {
overwrite: true,
api_key: { "from_secret": "github_token"},
files: ["dist/*", "sha256sum.txt"],
title: "${DRONE_TAG}",
note: "CHANGELOG.md",
},
when: {
ref: [ "refs/tags/**" ],
},
},
{
name: "publish-pypi",
image: "plugins/pypi",
pull: "always",
settings: {
username: { "from_secret": "pypi_username" },
password: { "from_secret": "pypi_password" },
repository: "https://upload.pypi.org/legacy/",
skip_build: true
},
when: {
ref: [ "refs/tags/**" ],
},
},
],
depends_on: [
"security",
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
}, },
{
name: 'publish-github',
image: 'plugins/github-release',
settings: {
overwrite: true,
api_key: { from_secret: 'github_token' },
files: ['dist/*', 'sha256sum.txt'],
title: '${DRONE_TAG}',
note: 'CHANGELOG.md',
},
when: {
ref: ['refs/tags/**'],
},
},
{
name: 'publish-pypi',
image: 'plugins/pypi',
settings: {
username: { from_secret: 'pypi_username' },
password: { from_secret: 'pypi_password' },
repository: 'https://upload.pypi.org/legacy/',
skip_build: true,
},
when: {
ref: ['refs/tags/**'],
},
},
],
depends_on: [
'security',
],
trigger: {
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
},
}; };
local PipelineBuildContainer(arch="amd64") = { local PipelineBuildContainer(arch='amd64') = {
kind: "pipeline", kind: 'pipeline',
name: "build-container-" + arch, name: 'build-container-' + arch,
platform: { platform: {
os: "linux", os: 'linux',
arch: arch, arch: arch,
}, },
steps: [ steps: [
{ {
name: "build", name: 'build',
image: "python:3.7", image: 'python:3.7',
pull: "always",
commands: [ commands: [
"python setup.py bdist_wheel", 'python setup.py bdist_wheel',
] ],
}, },
{ {
name: "dryrun", name: 'dryrun',
image: "plugins/docker:18-linux-" + arch, image: 'plugins/docker:18-linux-' + arch,
pull: "always",
settings: { settings: {
dry_run: true, dry_run: true,
dockerfile: "Dockerfile", dockerfile: 'Dockerfile',
repo: "xoxys/ansible-doctor", repo: 'xoxys/ansible-doctor',
username: { "from_secret": "docker_username" }, username: { from_secret: 'docker_username' },
password: { "from_secret": "docker_password" }, password: { from_secret: 'docker_password' },
}, },
when: { when: {
ref: ["refs/pull/**"], ref: ['refs/pull/**'],
}, },
}, },
{ {
name: "publish", name: 'publish',
image: "plugins/docker:18-linux-" + arch, image: 'plugins/docker:18-linux-' + arch,
pull: "always",
settings: { settings: {
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
dockerfile: "Dockerfile", dockerfile: 'Dockerfile',
repo: "xoxys/ansible-doctor", repo: 'xoxys/ansible-doctor',
username: { "from_secret": "docker_username" }, username: { from_secret: 'docker_username' },
password: { "from_secret": "docker_password" }, password: { from_secret: 'docker_password' },
}, },
when: { when: {
ref: ["refs/heads/master", "refs/tags/**"], ref: ['refs/heads/master', 'refs/tags/**'],
}, },
}, },
], ],
depends_on: [ depends_on: [
"security", 'security',
], ],
trigger: { trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"], ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineDocs = {
kind: 'pipeline',
name: 'docs',
platform: {
os: 'linux',
arch: 'amd64',
},
concurrency: {
limit: 1,
},
steps: [
{
name: 'assets',
image: 'byrnedo/alpine-curl',
commands: [
'mkdir -p docs/themes/hugo-geekdoc/',
'curl -L https://github.com/xoxys/hugo-geekdoc/releases/latest/download/hugo-geekdoc.tar.gz | tar -xz -C docs/themes/hugo-geekdoc/ --strip-components=1',
],
},
{
name: 'test',
image: 'klakegg/hugo:0.59.1-ext-alpine',
commands: [
'cd docs/ && hugo-official',
],
},
{
name: 'freeze',
image: 'appleboy/drone-ssh',
settings: {
host: { from_secret: 'ssh_host' },
key: { from_secret: 'ssh_key' },
script: [
'cp -R /var/www/virtual/geeklab/html/ansible-doctor.geekdocs.de/ /var/www/virtual/geeklab/html/ansibledoctor_freeze/',
'ln -sfn /var/www/virtual/geeklab/html/ansibledoctor_freeze /var/www/virtual/geeklab/ansible-doctor.geekdocs.de',
],
username: { from_secret: 'ssh_username' },
},
},
{
name: 'publish',
image: 'appleboy/drone-scp',
settings: {
host: { from_secret: 'ssh_host' },
key: { from_secret: 'ssh_key' },
rm: true,
source: 'docs/public/*',
strip_components: 2,
target: '/var/www/virtual/geeklab/html/ansible-doctor.geekdocs.de/',
username: { from_secret: 'ssh_username' },
},
},
{
name: 'cleanup',
image: 'appleboy/drone-ssh',
settings: {
host: { from_secret: 'ssh_host' },
key: { from_secret: 'ssh_key' },
script: [
'ln -sfn /var/www/virtual/geeklab/html/ansible-doctor.geekdocs.de /var/www/virtual/geeklab/ansible-doctor.geekdocs.de',
'rm -rf /var/www/virtual/geeklab/html/ansibledoctor_freeze/',
],
username: { from_secret: 'ssh_username' },
},
},
],
depends_on: [
'build-package',
'build-container-amd64',
'build-container-arm64',
'build-container-arm',
],
trigger: {
ref: ['refs/heads/master', 'refs/tags/**'],
}, },
}; };
local PipelineNotifications = { local PipelineNotifications = {
kind: "pipeline", kind: 'pipeline',
name: "notifications", name: 'notifications',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
{ {
image: "plugins/manifest", image: 'plugins/manifest',
name: "manifest", name: 'manifest',
pull: "always",
settings: { settings: {
ignore_missing: true, ignore_missing: true,
auto_tag: true, auto_tag: true,
username: { from_secret: "docker_username" }, username: { from_secret: 'docker_username' },
password: { from_secret: "docker_password" }, password: { from_secret: 'docker_password' },
spec: "manifest.tmpl", spec: 'manifest.tmpl',
},
when: {
ref: [
'refs/heads/master',
'refs/tags/**',
],
}, },
}, },
{ {
name: "readme", name: 'readme',
image: "sheogorath/readme-to-dockerhub", image: 'sheogorath/readme-to-dockerhub',
pull: "always",
environment: { environment: {
DOCKERHUB_USERNAME: { from_secret: "docker_username" }, DOCKERHUB_USERNAME: { from_secret: 'docker_username' },
DOCKERHUB_PASSWORD: { from_secret: "docker_password" }, DOCKERHUB_PASSWORD: { from_secret: 'docker_password' },
DOCKERHUB_REPO_PREFIX: "xoxys", DOCKERHUB_REPO_PREFIX: 'xoxys',
DOCKERHUB_REPO_NAME: "ansible-doctor", DOCKERHUB_REPO_NAME: 'ansible-doctor',
README_PATH: "README.md", README_PATH: 'README.md',
SHORT_DESCRIPTION: "ansible-doctor - Simple annotation based documentation for your roles" SHORT_DESCRIPTION: 'ansible-doctor - Simple annotation based documentation for your roles',
},
when: {
ref: [
'refs/heads/master',
'refs/tags/**',
],
}, },
}, },
{ {
name: "microbadger", name: 'microbadger',
image: "plugins/webhook", image: 'plugins/webhook',
pull: "always",
settings: { settings: {
urls: { from_secret: "microbadger_url" }, urls: { from_secret: 'microbadger_url' },
}, },
}, },
{ {
name: "matrix", name: 'matrix',
image: "plugins/matrix", image: 'plugins/matrix',
settings: { settings: {
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}", homeserver: { from_secret: 'matrix_homeserver' },
roomid: { "from_secret": "matrix_roomid" }, roomid: { from_secret: 'matrix_roomid' },
homeserver: { "from_secret": "matrix_homeserver" }, 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" }, username: { from_secret: 'matrix_username' },
password: { "from_secret": "matrix_password" }, password: { from_secret: 'matrix_password' },
}, },
}, },
], ],
depends_on: [ depends_on: [
"build-package", 'docs',
"build-container-amd64",
"build-container-arm64",
"build-container-arm"
], ],
trigger: { trigger: {
ref: ["refs/heads/master", "refs/tags/**"], ref: ['refs/heads/master', 'refs/tags/**'],
status: [ "success", "failure" ], status: ['success', 'failure'],
}, },
}; };
[ [
PipelineLint, PipelineLint,
PipelineTest, PipelineTest,
PipelineSecurity, PipelineSecurity,
PipelineBuildPackage, PipelineBuildPackage,
PipelineBuildContainer(arch="amd64"), PipelineBuildContainer(arch='amd64'),
PipelineBuildContainer(arch="arm64"), PipelineBuildContainer(arch='arm64'),
PipelineBuildContainer(arch="arm"), PipelineBuildContainer(arch='arm'),
PipelineNotifications, PipelineDocs,
PipelineNotifications,
] ]

View File

@ -8,7 +8,6 @@ platform:
steps: steps:
- name: flake8 - name: flake8
pull: always
image: python:3.7 image: python:3.7
commands: commands:
- pip install -r test-requirements.txt -qq - pip install -r test-requirements.txt -qq
@ -20,8 +19,8 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- "refs/pull/**" - refs/pull/**
--- ---
kind: pipeline kind: pipeline
@ -33,7 +32,6 @@ platform:
steps: steps:
- name: python35-pytest - name: python35-pytest
pull: always
image: python:3.5 image: python:3.5
commands: commands:
- pip install -r test-requirements.txt -qq - pip install -r test-requirements.txt -qq
@ -45,7 +43,6 @@ steps:
- clone - clone
- name: python36-pytest - name: python36-pytest
pull: always
image: python:3.6 image: python:3.6
commands: commands:
- pip install -r test-requirements.txt -qq - pip install -r test-requirements.txt -qq
@ -57,7 +54,6 @@ steps:
- clone - clone
- name: python37-pytest - name: python37-pytest
pull: always
image: python:3.7 image: python:3.7
commands: commands:
- pip install -r test-requirements.txt -qq - pip install -r test-requirements.txt -qq
@ -69,7 +65,6 @@ steps:
- clone - clone
- name: python38-rc-pytest - name: python38-rc-pytest
pull: always
image: python:3.8-rc image: python:3.8-rc
commands: commands:
- pip install -r test-requirements.txt -qq - pip install -r test-requirements.txt -qq
@ -83,8 +78,8 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- "refs/pull/**" - refs/pull/**
depends_on: depends_on:
- lint - lint
@ -99,7 +94,6 @@ platform:
steps: steps:
- name: bandit - name: bandit
pull: always
image: python:3.7 image: python:3.7
commands: commands:
- pip install -r test-requirements.txt -qq - pip install -r test-requirements.txt -qq
@ -111,8 +105,8 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- "refs/pull/**" - refs/pull/**
depends_on: depends_on:
- test - test
@ -127,35 +121,31 @@ platform:
steps: steps:
- name: build - name: build
pull: always
image: python:3.7 image: python:3.7
commands: commands:
- python setup.py sdist bdist_wheel - python setup.py sdist bdist_wheel
- name: checksum - name: checksum
pull: always
image: alpine image: alpine
commands: commands:
- "cd dist/ && sha256sum * > ../sha256sum.txt" - cd dist/ && sha256sum * > ../sha256sum.txt
- name: publish-github - name: publish-github
pull: always
image: plugins/github-release image: plugins/github-release
settings: settings:
api_key: api_key:
from_secret: github_token from_secret: github_token
files: files:
- "dist/*" - dist/*
- sha256sum.txt - sha256sum.txt
note: CHANGELOG.md note: CHANGELOG.md
overwrite: true overwrite: true
title: "${DRONE_TAG}" title: ${DRONE_TAG}
when: when:
ref: ref:
- "refs/tags/**" - refs/tags/**
- name: publish-pypi - name: publish-pypi
pull: always
image: plugins/pypi image: plugins/pypi
settings: settings:
password: password:
@ -166,13 +156,13 @@ steps:
from_secret: pypi_username from_secret: pypi_username
when: when:
ref: ref:
- "refs/tags/**" - refs/tags/**
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- "refs/pull/**" - refs/pull/**
depends_on: depends_on:
- security - security
@ -187,13 +177,11 @@ platform:
steps: steps:
- name: build - name: build
pull: always
image: python:3.7 image: python:3.7
commands: commands:
- python setup.py bdist_wheel - python setup.py bdist_wheel
- name: dryrun - name: dryrun
pull: always
image: plugins/docker:18-linux-amd64 image: plugins/docker:18-linux-amd64
settings: settings:
dockerfile: Dockerfile dockerfile: Dockerfile
@ -205,10 +193,9 @@ steps:
from_secret: docker_username from_secret: docker_username
when: when:
ref: ref:
- "refs/pull/**" - refs/pull/**
- name: publish - name: publish
pull: always
image: plugins/docker:18-linux-amd64 image: plugins/docker:18-linux-amd64
settings: settings:
auto_tag: true auto_tag: true
@ -222,13 +209,13 @@ steps:
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- "refs/pull/**" - refs/pull/**
depends_on: depends_on:
- security - security
@ -243,13 +230,11 @@ platform:
steps: steps:
- name: build - name: build
pull: always
image: python:3.7 image: python:3.7
commands: commands:
- python setup.py bdist_wheel - python setup.py bdist_wheel
- name: dryrun - name: dryrun
pull: always
image: plugins/docker:18-linux-arm64 image: plugins/docker:18-linux-arm64
settings: settings:
dockerfile: Dockerfile dockerfile: Dockerfile
@ -261,10 +246,9 @@ steps:
from_secret: docker_username from_secret: docker_username
when: when:
ref: ref:
- "refs/pull/**" - refs/pull/**
- name: publish - name: publish
pull: always
image: plugins/docker:18-linux-arm64 image: plugins/docker:18-linux-arm64
settings: settings:
auto_tag: true auto_tag: true
@ -278,13 +262,13 @@ steps:
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- "refs/pull/**" - refs/pull/**
depends_on: depends_on:
- security - security
@ -299,13 +283,11 @@ platform:
steps: steps:
- name: build - name: build
pull: always
image: python:3.7 image: python:3.7
commands: commands:
- python setup.py bdist_wheel - python setup.py bdist_wheel
- name: dryrun - name: dryrun
pull: always
image: plugins/docker:18-linux-arm image: plugins/docker:18-linux-arm
settings: settings:
dockerfile: Dockerfile dockerfile: Dockerfile
@ -317,10 +299,9 @@ steps:
from_secret: docker_username from_secret: docker_username
when: when:
ref: ref:
- "refs/pull/**" - refs/pull/**
- name: publish - name: publish
pull: always
image: plugins/docker:18-linux-arm image: plugins/docker:18-linux-arm
settings: settings:
auto_tag: true auto_tag: true
@ -334,17 +315,91 @@ steps:
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- "refs/pull/**" - refs/pull/**
depends_on: depends_on:
- security - security
---
kind: pipeline
name: docs
platform:
os: linux
arch: amd64
concurrency:
limit: 1
steps:
- name: assets
image: byrnedo/alpine-curl
commands:
- mkdir -p docs/themes/hugo-geekdoc/
- curl -L https://github.com/xoxys/hugo-geekdoc/releases/latest/download/hugo-geekdoc.tar.gz | tar -xz -C docs/themes/hugo-geekdoc/ --strip-components=1
- name: test
image: klakegg/hugo:0.59.1-ext-alpine
commands:
- cd docs/ && hugo-official
- name: freeze
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_host
key:
from_secret: ssh_key
script:
- cp -R /var/www/virtual/geeklab/html/ansible-doctor.geekdocs.de/ /var/www/virtual/geeklab/html/ansibledoctor_freeze/
- ln -sfn /var/www/virtual/geeklab/html/ansibledoctor_freeze /var/www/virtual/geeklab/ansible-doctor.geekdocs.de
username:
from_secret: ssh_username
- name: publish
image: appleboy/drone-scp
settings:
host:
from_secret: ssh_host
key:
from_secret: ssh_key
rm: true
source: docs/public/*
strip_components: 2
target: /var/www/virtual/geeklab/html/ansible-doctor.geekdocs.de/
username:
from_secret: ssh_username
- name: cleanup
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_host
key:
from_secret: ssh_key
script:
- ln -sfn /var/www/virtual/geeklab/html/ansible-doctor.geekdocs.de /var/www/virtual/geeklab/ansible-doctor.geekdocs.de
- rm -rf /var/www/virtual/geeklab/html/ansibledoctor_freeze/
username:
from_secret: ssh_username
trigger:
ref:
- refs/heads/master
- refs/tags/**
depends_on:
- build-package
- build-container-amd64
- build-container-arm64
- build-container-arm
--- ---
kind: pipeline kind: pipeline
name: notifications name: notifications
@ -355,7 +410,6 @@ platform:
steps: steps:
- name: manifest - name: manifest
pull: always
image: plugins/manifest image: plugins/manifest
settings: settings:
auto_tag: true auto_tag: true
@ -365,13 +419,8 @@ steps:
spec: manifest.tmpl spec: manifest.tmpl
username: username:
from_secret: docker_username from_secret: docker_username
when:
ref:
- refs/heads/master
- "refs/tags/**"
- name: readme - name: readme
pull: always
image: sheogorath/readme-to-dockerhub image: sheogorath/readme-to-dockerhub
environment: environment:
DOCKERHUB_PASSWORD: DOCKERHUB_PASSWORD:
@ -382,13 +431,8 @@ steps:
from_secret: docker_username from_secret: docker_username
README_PATH: README.md README_PATH: README.md
SHORT_DESCRIPTION: ansible-doctor - Simple annotation based documentation for your roles SHORT_DESCRIPTION: ansible-doctor - Simple annotation based documentation for your roles
when:
ref:
- refs/heads/master
- "refs/tags/**"
- name: microbadger - name: microbadger
pull: always
image: plugins/webhook image: plugins/webhook
settings: settings:
urls: urls:
@ -410,19 +454,16 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
status: status:
- success - success
- failure - failure
depends_on: depends_on:
- build-package - docs
- build-container-amd64
- build-container-arm64
- build-container-arm
--- ---
kind: signature kind: signature
hmac: 24cc5ebb0319158e48a67f6433b0712b02ed5e50cd7fcb3ec0a9651d0e0d6c6a hmac: effd4a9b4d0a8672e91c75931a015e4ae4d343678d408c5061f9009b00d859ae
... ...

5
.gitignore vendored
View File

@ -101,3 +101,8 @@ env*/
.pytest_cache .pytest_cache
pip-wheel-metadata pip-wheel-metadata
# Hugo documentation
docs/themes/
docs/public/
resources/_gen/

28
docs/config.yaml Normal file
View File

@ -0,0 +1,28 @@
---
baseURL: https://ansible-doctor.geekdocs.de/
title: ansible-doctor
theme: hugo-geekdoc
pygmentsUseClasses: true
pygmentsCodeFences: true
# Geekdoc configuration
disablePathToLower: true
enableGitInfo: true
# Needed for mermaid/katex shortcodes
markup:
goldmark:
renderer:
unsafe: true
tableOfContents:
startLevel: 1
params:
geekdocMenuBundle: true
geekdocToC: 3
geekdocRepo: https://github.com/xoxys/ansible-doctor
geekdocEditPath: edit/master/docs/content
geekdocDateFormat: "Jan 2, 2006"
geekdocSearch: true

17
docs/content/_index.md Normal file
View File

@ -0,0 +1,17 @@
---
title: Documentation
---
[![Build Status](https://cloud.drone.io/api/badges/xoxys/ansible-doctor/status.svg)](https://cloud.drone.io/xoxys/ansible-doctor)
[![](https://img.shields.io/pypi/pyversions/ansible-doctor.svg)](https://pypi.org/project/ansible-doctor/)
[![](https://img.shields.io/pypi/status/ansible-doctor.svg)](https://pypi.org/project/ansible-doctor/)
[![](https://img.shields.io/pypi/v/ansible-doctor.svg)](https://pypi.org/project/ansible-doctor/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
This project is based on the idea (and at some parts on the code) of [ansible-autodoc](https://github.com/AndresBott/ansible-autodoc) by Andres Bott so credits goes to him for his work.
*ansible-doctor* is a simple annotation like documentation generator based on Jinja2 templates. While *ansible-doctor* comes with a default template called `readme`, it is also possible to write your own templates. This gives you the ability to customize the output and render the data to every format you like (e.g. html or xml).
*ansible-doctor* is designed to work within your CI pipeline to complete your testing and deployment workflow. Releases are available as Python Packages at [GitHub](https://github.com/xoxys/ansible-doctor/releases) or [PyPI](https://pypi.org/project/ansible-doctor/) and as Docker Image at [DockerHub](https://hub.docker.com/r/xoxys/ansible-doctor).
You can find the full documentation at [ansible-doctor.geekdocs.de](https://ansible-doctor.geekdocs.de).

View File

@ -0,0 +1,13 @@
---
title: Configuration
---
*ansible-doctor* comes with default settings which should be sufficient for most users to start, but you can adjust most settings to your needs.
Changes can be made on different locations which will be processed in the following order (last wins):
* default config (build-in)
* global config file (path depends on your operating system)
* folder-based config file (.ansibledoctor.yml|.ansibledoctor.yaml|.ansibledoctor in current working dir)
* environment variables
* cli options

View File

@ -0,0 +1,29 @@
---
title: CLI options
---
You can get all available cli options by running `ansible-later --help`:
{{< highlight Shell "linenos=table" >}}
$ ansible-doctor --help
usage: ansible-doctor [-h] [-c CONFIG_FILE] [-o OUTPUT_DIR] [-f] [-d] [-v]
[-q] [--version]
role_dir
Generate documentation from annotated Ansible roles using templates
positional arguments:
role_dir role directory (default: current working dir)
optional arguments:
-h, --help show this help message and exit
-c CONFIG_FILE, --config CONFIG_FILE
location of configuration file
-o OUTPUT_DIR, --output OUTPUT_DIR
output base dir
-f, --force force overwrite output file
-d, --dry-run dry run without writing
-v increase log level
-q decrease log level
--version show program's version number and exit
{{< /highlight >}}

View File

@ -0,0 +1,36 @@
---
title: Default settings
---
{{< highlight YAML "linenos=table" >}}
---
# default is your current working dir
role_dir:
# don't write anything to filesystem
dry_run: False
logging:
# possible options debug | info | warning | error | critical
level: "warning"
# you can enable json logging if a parsable output is required
json: False
# path to write rendered template file
# default is your current working dir
output_dir:
# default is in-build templates dir
template_dir:
template: readme
# don't ask to overwrite if output file exists
force_overwrite: False
# load custom header from given file and append template output
# to it before write.
custom_header: ""
exclude_files: []
# Examples
# exclude_files:
# - molecule/
# - files/**/*.py
{{< /highlight >}}

View File

@ -0,0 +1,18 @@
---
title: Environment Variables
---
{{< highlight Shell "linenos=table" >}}
ANSIBLE_DOCTOR_CONFIG_FILE=
ANSIBLE_DOCTOR_ROLE_DIR=
ANSIBLE_DOCTOR_DRY_RUN=false
ANSIBLE_DOCTOR_LOG_LEVEL=warning
ANSIBLE_DOCTOR_LOG_JSON=false
ANSIBLE_DOCTOR_OUTPUT_DIR=
ANSIBLE_DOCTOR_TEMPLATE_DIR=
ANSIBLE_DOCTOR_TEMPLATE=readme
ANSIBLE_DOCTOR_FORCE_OVERWRITE=false
ANSIBLE_DOCTOR_CUSTOM_HEADER=
ANSIBLE_DOCTOR_EXCLUDE_FILES=
ANSIBLE_DOCTOR_EXCLUDE_FILES=molecule/,files/**/*.py
{{< /highlight >}}

View File

@ -0,0 +1,4 @@
---
title: Setup
---

View File

@ -0,0 +1,22 @@
---
title: Using docker
---
{{< highlight Shell "linenos=table" >}}
docker run \
-e ANSIBLE_DOCTOR_ROLE_DIR=example/demo-role/ \
-e ANSIBLE_DOCTOR_OUTPUT_DIR=example/ \
-e ANSIBLE_DOCTOR_FORCE_OVERWRITE=true \
-e ANSIBLE_DOCTOR_CUSTOM_HEADER=example/demo-role/HEADER.md \
-e ANSIBLE_DOCTOR_LOG_LEVEL=info \
-e PY_COLORS=1 \
-v $(pwd):/doctor \
-w /doctor \
xoxys/ansible-doctor
{{< /highlight >}}
{{< hint info >}}
**Info**
Keep in mind, that you have to pass selinux labels (:Z or :z) to your mount option if you are working on selinux enabled systems.
{{< /hint >}}

15
docs/content/setup/pip.md Normal file
View File

@ -0,0 +1,15 @@
---
title: Using pip
---
{{< highlight Shell "linenos=table" >}}
# From PyPI as unprivilegd user
$ pip install ansible-doctor --user
# .. or as root
$ sudo pip install ansible-doctor
# From Wheel file
$ pip install https://github.com/xoxys/ansible-doctor/releases/download/v0.1.1/ansible_doctor-0.1.1-py2.py3-none-any.whl
{{< /highlight >}}

View File

@ -0,0 +1,35 @@
---
title: Usage
---
```Shell
ansible-doctor FOLDER
```
If you don't pass a folder to *ansible-doctor* your current working directory will be used. The first step is to identify if the given folder is an ansible role. This check is very simple, if the folder contains a subfolder called `tasks` is MUST be an ansible role! :)
After the successful check, *ansible-doctor* will try to read some static files into a dictionary:
* defaults/main.yml
* meta/main.yml
This will be the base result set which is used as data source for every output template. Without any work, you will get at least a documentation about available variables and some meta information. Theses basic information can be expanded with a set of available annotations. In general, an annotation is a comment with an identifier. This identifier is followed by colon separated options and ends with a value.
{{< highlight Yaml "linenos=table" >}}
# @identifier option1:option2: <value>
# @var docker_registry_password:example: "%8gv_5GA?"
# @var docker_registry_password:description: Very secure password to login to the docker registry
# @var docker_registry_password:description: >
# You can also write it as multiline description
# Very secure password to login to the docker registry.
# @end
docker_registry_password: "secret"
{{< /highlight >}}
These list of pre-defined identifiers is currently available:
* @meta
* @todo
* @var
* @tag

19
docs/data/menu/main.yml Normal file
View File

@ -0,0 +1,19 @@
---
main:
- name: Setup
sub:
- name: Using pip
ref: "/setup/pip"
- name: Using docker
ref: "/setup/docker"
- name: Configuration
ref: "/configuration"
sub:
- name: Default settings
ref: "/configuration/defaults"
- name: CLI options
ref: "/configuration/cli"
- name: Environment variables
ref: "/configuration/env"
- name: Usage
ref: "/usage"

10
docs/data/menu/more.yml Normal file
View File

@ -0,0 +1,10 @@
---
more:
- name: Releases
ref: "https://github.com/xoxys/ansible-doctor/releases"
external: true
icon: "download"
- name: "View Source"
ref: "https://github.com/xoxys/ansible-doctor"
external: true
icon: "github"