Skip to content

Commit

Permalink
ci(travis): use structure of template-formula
Browse files Browse the repository at this point in the history
  • Loading branch information
alxwr committed Apr 25, 2019
1 parent 475ad4f commit 88d3f3e
Show file tree
Hide file tree
Showing 17 changed files with 553 additions and 1 deletion.
106 changes: 106 additions & 0 deletions .gitignore
@@ -0,0 +1,106 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a packager
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.kitchen
.kitchen.local.yml

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# copied `.md` files used for conversion to `.rst` using `m2r`
docs/*.md
1 change: 0 additions & 1 deletion .gitignore/.gitignore

This file was deleted.

61 changes: 61 additions & 0 deletions .travis.yml
@@ -0,0 +1,61 @@
stages:
- test
- commitlint
- name: release
if: branch = master AND type != pull_request

sudo: required
cache: bundler
language: ruby

services:
- docker

before_install:
- bundle install

# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
env:
matrix:
- INSTANCE: default-debian-9-2019-2-py3
- INSTANCE: default-ubuntu-1804-2019-2-py3
- INSTANCE: default-ubuntu-1604-2018-3-py2
- INSTANCE: default-ubuntu-1604-2017-7-py2

script:
- bundle exec kitchen verify ${INSTANCE}

jobs:
include:
# Define the commitlint stage
- stage: commitlint
language: node_js
node_js: lts/*
before_install: skip
script:
- npm install @commitlint/config-conventional -D
- npm install @commitlint/travis-cli -D
- commitlint-travis
# Define the release stage that runs semantic-release
- stage: release
language: node_js
node_js: lts/*
before_install: skip
script:
# Update `AUTHORS.md`
- export MAINTAINER_TOKEN=${GH_TOKEN}
- go get github.com/alxwr/maintainer
- maintainer contributor

# Install all dependencies required for `semantic-release`
- npm install @semantic-release/changelog@3 -D
- npm install @semantic-release/exec@3 -D
- npm install @semantic-release/git@7 -D
deploy:
provider: script
skip_cleanup: true
script:
# Run `semantic-release`
- npx semantic-release@15

1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -0,0 +1 @@

9 changes: 9 additions & 0 deletions FORMULA
@@ -0,0 +1,9 @@
name: prometheus
os: FreeBSD
os_family: FreeBSD
version: 0.0.1
release: 1
minimum_version: 2016.11
summary: Prometheus formula
description: Formula to set up Prometheus
top_level_dir: prometheus
6 changes: 6 additions & 0 deletions Gemfile
@@ -0,0 +1,6 @@
source "https://rubygems.org"

gem 'kitchen-docker', '>= 2.9'
gem 'kitchen-salt', '>= 0.5.0'
gem 'kitchen-inspec', '>= 1.1'

13 changes: 13 additions & 0 deletions LICENSE
@@ -0,0 +1,13 @@
Copyright (c) 2014 Salt Stack Formulas

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
3 changes: 3 additions & 0 deletions commitlint.config.js
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
94 changes: 94 additions & 0 deletions docs/README.rst
@@ -0,0 +1,94 @@
.. _readme:

prometheus-formula
================

|img_travis| |img_sr|

.. |img_travis| image:: https://travis-ci.com/saltstack-formulas/prometheus-formula.svg?branch=master
:alt: Travis CI Build Status
:scale: 100%
:target: https://travis-ci.com/saltstack-formulas/prometheus-formula
.. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
:alt: Semantic Release
:scale: 100%
:target: https://github.com/semantic-release/semantic-release
Manage Prometheus.

.. contents:: **Table of Contents**

General notes
-------------

See the full `SaltStack Formulas installation and usage instructions
<https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.

If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``,
which contains the currently released version. This formula is versioned according to `Semantic Versioning <http://semver.org/>`_.

See `Formula Versioning Section <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning>`_ for more details.

Contributing to this repo
-------------------------

Please see https://github.com/saltstack-formulas/prometheus-formula/blob/master/docs/CONTRIBUTING.rst

Available states
----------------

.. contents::
:local:

``prometheus``
^^^^^^^^^^^^

*Meta-state (This is a state that includes other states)*.

This installs the prometheus package,
manages the prometheus configuration file and then
starts the associated prometheus service.

``prometheus.package``
^^^^^^^^^^^^^^^^^^^^

This state will install the prometheus package only.

``prometheus.config``
^^^^^^^^^^^^^^^^^^^

This state will configure the prometheus service and has a dependency on ``prometheus.install``
via include list.

``prometheus.service``
^^^^^^^^^^^^^^^^^^^^

This state will start the prometheus service and has a dependency on ``prometheus.config``
via include list.

``prometheus.clean``
^^^^^^^^^^^^^^^^^^

*Meta-state (This is a state that includes other states)*.

this state will undo everything performed in the ``prometheus`` meta-state in reverse order, i.e.
stops the service,
removes the configuration file and
then uninstalls the package.

``prometheus.service.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^

This state will stop the prometheus service and disable it at boot time.

``prometheus.config.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^

This state will remove the configuration of the prometheus service and has a
dependency on ``prometheus.service.clean`` via include list.

``prometheus.package.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^

This state will remove the prometheus package and has a depency on
``prometheus.config.clean`` via include list.

64 changes: 64 additions & 0 deletions kitchen.yml
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# For help on this file's format, see https://kitchen.ci/
driver:
name: docker
use_sudo: false
privileged: true
run_command: /lib/systemd/systemd

# Make sure the platforms listed below match up with
# the `env.matrix` instances defined in `.travis.yml`
platforms:
## SALT 2019.2
- name: debian-9-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:debian-9
- name: ubuntu-1804-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:ubuntu-1804

## SALT 2018.3
- name: ubuntu-1604-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:ubuntu-1604

## SALT 2017.7
- name: ubuntu-1604-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:ubuntu-1604

provisioner:
name: salt_solo
log_level: info
salt_install: none
require_chef: false
formula: prometheus
salt_copy_filter:
- .kitchen
- .git
state_top:
base:
'*':
- prometheus
pillars:
top.sls:
base:
'*':
- prometheus
pillars_from_files:
prometheus.sls: pillar.example

verifier:
# https://www.inspec.io/
name: inspec
sudo: true
# cli, documentation, html, progress, json, json-min, json-rspec, junit
reporter:
- cli
inspec_tests:
- path: test/integration/default

suites:
- name: default
30 changes: 30 additions & 0 deletions pre-commit_semantic-release.sh
@@ -0,0 +1,30 @@
#!/bin/sh

###############################################################################
# (A) Update `FORMULA` with `${nextRelease.version}`
###############################################################################
sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA


###############################################################################
# (B) Use `m2r` to convert automatically produced `.md` docs to `.rst`
###############################################################################

# Install `m2r`
sudo -H pip install m2r

# Copy and then convert the `.md` docs
cp *.md docs/
cd docs/
m2r --overwrite *.md

# Change excess `H1` headings to `H2` in converted `CHANGELOG.rst`
sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst
sed -i -e '1,4s/-/=/g' CHANGELOG.rst

# Use for debugging output, when required
# cat AUTHORS.rst
# cat CHANGELOG.rst

# Return back to the main directory
cd ..

0 comments on commit 88d3f3e

Please sign in to comment.