Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Migrate from Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
JGoutin committed Jun 30, 2021
1 parent 9ca7834 commit 7c51544
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 23 deletions.
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
skip_list:
- '304' # Detect CMake option "-DPYTHON3=ON" and environment variable.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
filename = *.py,src/
max-line-length = 88
extend-ignore = E203, E402
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
extends: default
rules:
line-length: disable
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/Accelize/ansible-role-accelize-drm.svg?branch=master)](https://travis-ci.org/Accelize/ansible-role-ansible-drm)
[![Build Status](https://dev.azure.com/Accelize/DRM/_apis/build/status/Ansible%20-%20Accelize%20DRM?branchName=master)](https://dev.azure.com/Accelize/DRM/_build/latest?definitionId=27&branchName=master)

Accelize DRM Ansible Role
=========================
Expand Down
100 changes: 100 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
name: Ansible Role Accelize DRM

trigger:
batch: true
branches:
include:
- master
tags:
include:
- "*"
paths:
exclude:
- "*.md"
- ".gitignore"
- "LICENSE"

pr: none

pool:
vmImage: ubuntu-20.04

jobs:
- job: tests
displayName: Tests
variables:
cacheDir: /tmp/.pipeline_cache
steps:

- checkout: self
fetchDepth: 1
path: ansible-role-accelize-drm # Must match role name in molecule/converge.yml

- task: Cache@2
inputs:
key: cache
path: $(cacheDir)
displayName: Cache packages

- script: |
echo "##vso[task.prependpath]$HOME/.local/bin"
pip install --disable-pip-version-check --cache-dir $(cacheDir)/.pip_packages -U ansible flake8 yamllint ansible-lint black bandit molecule-docker pytest-testinfra
displayName: Get dependencies
condition: always()
- script: flake8
displayName: Lint Python modules
condition: always()

- script: black . --check --diff
displayName: Check black style is applied
condition: always()

- script: bandit -r . -x ./molecule
displayName: Check Python security
condition: always()

- script: yamllint -s .
displayName: Lint YAML files
condition: always()

- script: ansible-lint .
displayName: Lint Ansible configuration
condition: always()

- script: molecule test
displayName: Test Ansible role
condition: always()
env:
ANSIBLE_STDOUT_CALLBACK: debug
ANSIBLE_FORCE_COLOR: "True"
ANSIBLE_NOCOLOR": "False"

- job:
displayName: Ansible Galaxy publish
dependsOn: tests
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags'), ne(variables['Build.Reason'], 'Schedule'))
variables:
- group: ansibleGalaxy
steps:

- checkout: none

- script: ansible-galaxy role import --token $(AnsibleGalaxyToken) --role-name accelize.accelize_drm Accelize ansible-role-accelize-drm
displayName: Publish role to Ansible Galaxy

- task: GitHubRelease@1
displayName: Publish GitHub release
inputs:
gitHubConnection: Accelize-application
repositoryName: $(Build.Repository.Name)
action: create
target: $(Build.SourceVersion)
tagSource: gitTag
tagPattern: '[0-9]+\.[0-9]+\.[0-9]+'
isPreRelease: contains($(libraryVersion.version), '-')
releaseNotesSource: inline
releaseNotesInline: Role Available on Ansible galaxy.
changeLogCompareToRelease: lastFullRelease
changeLogType: commitBased
21 changes: 12 additions & 9 deletions molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")


def test_packages_installed(host):
"""
Test that packages are installed
"""
if (host.ansible.get_variables().get('accelize_drm_no_install') or
host.ansible.get_variables().get('accelize_drm_from_source')):
pytest.skip('No packages installed')
if host.ansible.get_variables().get(
"accelize_drm_no_install"
) or host.ansible.get_variables().get("accelize_drm_from_source"):
pytest.skip("No packages installed")

assert host.package("libaccelize-drm").is_installed

Expand All @@ -23,9 +25,10 @@ def test_include_installed(host):
"""
Test that includes are installed
"""
if (not host.ansible.get_variables().get('accelize_drm_devel') and
not host.ansible.get_variables().get('accelize_drm_from_source')):
pytest.skip('No headers installed')
if not host.ansible.get_variables().get(
"accelize_drm_devel"
) and not host.ansible.get_variables().get("accelize_drm_from_source"):
pytest.skip("No headers installed")

assert host.file("/usr/include/accelize/drm.h").exists

Expand All @@ -34,5 +37,5 @@ def test_library_configuration_installed(host):
"""
Test that library configuration files are installed
"""
assert host.file('/root/.accelize_drm/cred.json').exists
assert host.file('/etc/accelize_drm/conf.json').exists
assert host.file("/root/.accelize_drm/cred.json").exists
assert host.file("/etc/accelize_drm/conf.json").exists

0 comments on commit 7c51544

Please sign in to comment.