From 8b091857d6e3a78155286c3d67596a89bfc5d796 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 23 Sep 2019 19:55:46 +0100 Subject: [PATCH] feat(semantic-release): implement for this formula * Checked using https://github.com/myii/ssf-formula/pull/42 --- .gitignore | 122 ++++++++++++++++++ .travis.yml | 22 ++-- FORMULA | 9 ++ docs/CONTRIBUTING.rst | 159 +++++++++++++++++++++++ README.rst => docs/README.rst | 191 ++++++++++++++++++++-------- kitchen.yml | 25 +++- pre-commit_semantic-release.sh | 30 +++++ release-rules.js | 18 +++ release.config.js | 106 +++++++++++++++ test/integration/default/inspec.yml | 1 + 10 files changed, 615 insertions(+), 68 deletions(-) create mode 100644 .gitignore create mode 100644 FORMULA create mode 100644 docs/CONTRIBUTING.rst rename README.rst => docs/README.rst (74%) create mode 100755 pre-commit_semantic-release.sh create mode 100644 release-rules.js create mode 100644 release.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0bbb03c --- /dev/null +++ b/.gitignore @@ -0,0 +1,122 @@ +# 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 +kitchen.local.yml +junit-*.xml + +# 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/ + +# Bundler +Gemfile.lock + +# copied `.md` files used for conversion to `.rst` using `m2r` +docs/*.md + +# Vim +*.sw? + +## Collected when centralising formulas (check and sort) +# `collectd-formula` +.pytest_cache/ +/.idea/ +Dockerfile.*_* +ignore/ +tmp/ diff --git a/.travis.yml b/.travis.yml index 2e1631f..fd71fca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,27 +22,31 @@ env: - INSTANCE: default-debian-10-develop-py3 # - INSTANCE: default-ubuntu-1804-develop-py3 # - INSTANCE: default-centos-7-develop-py3 - - INSTANCE: default-fedora-30-develop-py3 + # - INSTANCE: default-fedora-30-develop-py3 # - INSTANCE: default-opensuse-leap-15-develop-py3 # - INSTANCE: default-amazonlinux-2-develop-py2 + # - INSTANCE: default-arch-base-latest-develop-py2 # - INSTANCE: default-debian-9-2019-2-py3 - INSTANCE: default-ubuntu-1804-2019-2-py3 - - INSTANCE: default-centos-7-2019-2-py3 - # - INSTANCE: default-fedora-30-2019-2-py3 + # - INSTANCE: default-centos-7-2019-2-py3 + - INSTANCE: default-fedora-30-2019-2-py3 # - INSTANCE: default-opensuse-leap-15-2019-2-py3 - # INSTANCE: default-amazonlinux-2-2019-2-py2 + # - INSTANCE: default-amazonlinux-2-2019-2-py2 + # - INSTANCE: default-arch-base-latest-2019-2-py2 # - INSTANCE: default-debian-9-2018-3-py2 # - INSTANCE: default-ubuntu-1604-2018-3-py2 - # INSTANCE: default-centos-7-2018-3-py2 - # INSTANCE: default-fedora-29-2018-3-py2 + - INSTANCE: default-centos-7-2018-3-py2 + # - INSTANCE: default-fedora-29-2018-3-py2 - INSTANCE: default-opensuse-leap-15-2018-3-py2 - - INSTANCE: default-amazonlinux-2-2018-3-py2 + # - INSTANCE: default-amazonlinux-2-2018-3-py2 + # - INSTANCE: default-arch-base-latest-2018-3-py2 # - INSTANCE: default-debian-8-2017-7-py2 # - INSTANCE: default-ubuntu-1604-2017-7-py2 - # INSTANCE: default-centos-6-2017-7-py2 + # - INSTANCE: default-centos-6-2017-7-py2 # - INSTANCE: default-fedora-29-2017-7-py2 # - INSTANCE: default-opensuse-leap-15-2017-7-py2 - # - INSTANCE: default-amazonlinux-2-2017-7-py2 + - INSTANCE: default-amazonlinux-2-2017-7-py2 + # - INSTANCE: default-arch-base-latest-2017-7-py2 script: - bin/kitchen verify ${INSTANCE} diff --git a/FORMULA b/FORMULA new file mode 100644 index 0000000..6f5efcc --- /dev/null +++ b/FORMULA @@ -0,0 +1,9 @@ +name: lvm +os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS +os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS +version: 0.1.0 +release: 1 +minimum_version: 2017.7 +summary: lvm formula +description: Formula to install and configure Linux logical volume management (LVM2) +top_level_dir: template diff --git a/docs/CONTRIBUTING.rst b/docs/CONTRIBUTING.rst new file mode 100644 index 0000000..b7da8f4 --- /dev/null +++ b/docs/CONTRIBUTING.rst @@ -0,0 +1,159 @@ +.. _contributing: + +How to contribute +================= + +This document will eventually outline all aspects of guidance to make your contributing experience a fruitful and enjoyable one. +What it already contains is information about *commit message formatting* and how that directly affects the numerous automated processes that are used for this repo. +It also covers how to contribute to this *formula's documentation*. + +.. contents:: **Table of Contents** + +Overview +-------- + +Submitting a pull request is more than just code! +To achieve a quality product, the *tests* and *documentation* need to be updated as well. +An excellent pull request will include these in the changes, wherever relevant. + +Commit message formatting +------------------------- + +Since every type of change requires making Git commits, +we will start by covering the importance of ensuring that all of your commit +messages are in the correct format. + +Automation of multiple processes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This formula uses `semantic-release `_ for automating numerous processes such as bumping the version number appropriately, creating new tags/releases and updating the changelog. +The entire process relies on the structure of commit messages to determine the version bump, which is then used for the rest of the automation. + +Full details are available in the upstream docs regarding the `Angular Commit Message Conventions `_. +The key factor is that the first line of the commit message must follow this format: + +.. code-block:: + + type(scope): subject + + +* E.g. ``docs(contributing): add commit message formatting instructions``. + +Besides the version bump, the changelog and release notes are formatted accordingly. +So based on the example above: + +.. + + .. raw:: html + +

Documentation

+ + * **contributing:** add commit message formatting instructions + + +* The ``type`` translates into a ``Documentation`` sub-heading. +* The ``(scope):`` will be shown in bold text without the brackets. +* The ``subject`` follows the ``scope`` as standard text. + +Linting commit messages in Travis CI +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This formula uses `commitlint `_ for checking commit messages during CI testing. +This ensures that they are in accordance with the ``semantic-release`` settings. + +For more details about the default settings, refer back to the ``commitlint`` `reference rules `_. + +Relationship between commit type and version bump +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This formula applies some customisations to the defaults, as outlined in the table below, +based upon the `type `_ of the commit: + +.. list-table:: + :name: commit-type-vs-version-bump + :header-rows: 1 + :stub-columns: 0 + :widths: 1,2,3,1,1 + + * - Type + - Heading + - Description + - Bump (default) + - Bump (custom) + * - ``build`` + - Build System + - Changes related to the build system + - – + - + * - ``chore`` + - – + - Changes to the build process or auxiliary tools and libraries such as + documentation generation + - – + - + * - ``ci`` + - Continuous Integration + - Changes to the continuous integration configuration + - – + - + * - ``docs`` + - Documentation + - Documentation only changes + - – + - 0.0.1 + * - ``feat`` + - Features + - A new feature + - 0.1.0 + - + * - ``fix`` + - Bug Fixes + - A bug fix + - 0.0.1 + - + * - ``perf`` + - Performance Improvements + - A code change that improves performance + - 0.0.1 + - + * - ``refactor`` + - Code Refactoring + - A code change that neither fixes a bug nor adds a feature + - – + - 0.0.1 + * - ``revert`` + - Reverts + - A commit used to revert a previous commit + - – + - 0.0.1 + * - ``style`` + - Styles + - Changes that do not affect the meaning of the code (white-space, + formatting, missing semi-colons, etc.) + - – + - 0.0.1 + * - ``test`` + - Tests + - Adding missing or correcting existing tests + - – + - 0.0.1 + +Use ``BREAKING CHANGE`` to trigger a ``major`` version change +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Adding ``BREAKING CHANGE`` to the footer of the extended description of the commit message will **always** trigger a ``major`` version change, no matter which type has been used. +This will be appended to the changelog and release notes as well. +To preserve good formatting of these notes, the following format is prescribed: + +* ``BREAKING CHANGE: .`` + +An example of that: + +.. code-block:: git + + ... + + BREAKING CHANGE: With the removal of all of the `.sls` files under + `template package`, this formula no longer supports the installation of + packages. + diff --git a/README.rst b/docs/README.rst similarity index 74% rename from README.rst rename to docs/README.rst index e932e56..0b2ab74 100644 --- a/README.rst +++ b/docs/README.rst @@ -1,7 +1,19 @@ -=========== +.. _readme: + lvm-formula =========== +|img_travis| |img_sr| + +.. |img_travis| image:: https://travis-ci.com/saltstack-formulas/lvm-formula.svg?branch=master + :alt: Travis CI Build Status + :scale: 100% + :target: https://travis-ci.com/saltstack-formulas/lvm-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 + Linux logical volume management (LVM2) state API. note:: The `lvm.conf(5)` is indirectly managed via LVM profiles. @@ -9,49 +21,87 @@ note:: The `lvm.conf(5)` is indirectly managed via LVM profiles. note:: See the full `Salt Formulas installation and usage instructions `_. +.. contents:: **Table of Contents** + :depth: 1 + +General notes +------------- + +See the full `SaltStack Formulas installation and usage instructions +`_. + +If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section +`_. + +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 `_. + +See `Formula Versioning Section `_ for more details. + +Todo +^^^^ +- global filter support is important +- test some advanced LV/RAID scenarios +- file systems mngt + +Good pillar data +^^^^^^^^^^^^^^^^ +Bad configuration causes problems. Sanity check pillar data when troubleshooting "``unable to``" state failures. + +OS families +^^^^^^^^^^^ +All Linux distributions supported. + +Contributing to this repo +------------------------- + +**Commit message formatting is significant!!** + +Please see :ref:`How to contribute ` for more details. + Available Meta states -====================== +--------------------- .. contents:: :local: ``lvm`` --------- +^^^^^^^ Meta-state to run all states in sequence: 'install', 'profiles', 'files', 'pv', 'vg', and 'lv'. ``lvm.profiles`` --------------- +^^^^^^^^^^^^^^^^ Meta-state to manage lvm profiles in sequence: 'remove', followed by 'create'. ``lvm.files`` ------------ +^^^^^^^^^^^^^ Meta-state to run loopback file device states in sequence: 'remove', followed by 'create'. Included by `lvm.pv` state. ``lvm.pv`` ------------ +^^^^^^^^^^ Meta-state to run physical volume (PV) states in sequence: 'remove', 'change', 'resize', 'move', and finally 'create'. ``lvm.vg`` --------------- +^^^^^^^^^^ Meta-state to run all volume group states in sequence: 'cfgbackup', 'import', 'remove', 'change' 'reduce', 'extend', 'split', 'merge', 'rename', 'create', 'export' & 'cfgrestore'. ``lvm.lv`` -------------- +^^^^^^^^^^ Meta-state to run all logical volume states in sequence: Order 'remove', 'change', 'reduce', 'extend', 'rename', 'create', 'convert', and 'create' again. Available substates -=================== +------------------- .. contents:: :local: ``lvm.clean`` ------------- +^^^^^^^^^^^^^ Remove lvm2 software. ``lvm.profiles.clean`` ----------------------- +^^^^^^^^^^^^^^^^^^^^^^ Remove custom lvm profile(s):: profiles: @@ -59,19 +109,19 @@ Remove custom lvm profile(s):: - sillyprofile ``lvm.install`` ------------ +^^^^^^^^^^^^^^^ Install lvm2 package. -``lvm.config (depreciated)`` ----------- +``lvm.config (deprecated)`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ Configure PVs, VGs and LVs using legacy pillar data (backwards compatibility only). ``lvm.clean`` ------------- +^^^^^^^^^^^^^ Remove lvm2 software. ``lvm.profiles.clean`` ----------------------- +^^^^^^^^^^^^^^^^^^^^^^ Remove custom lvm profile(s):: profiles: @@ -79,7 +129,7 @@ Remove custom lvm profile(s):: - sillyprofile ``lvm.profiles.create`` ----------------------- +^^^^^^^^^^^^^^^^^^^^^^^ Create custom lvm profile(s):: lvm: @@ -92,11 +142,11 @@ Create custom lvm profile(s):: ``lvm.files.clean`` ------------------- +^^^^^^^^^^^^^^^^^^^ Remove LVM backing files from the file system. ``lvm.files.create`` ------------------- +^^^^^^^^^^^^^^^^^^^^ LVM Loopback HOW-TO support. Creates backing files (in /tmp by defaults) and loopback devices per pillars:: lvm: @@ -126,7 +176,7 @@ LVM Loopback HOW-TO support. Creates backing files (in /tmp by defaults) and loo ``lvm.pv.clean`` --------------- +^^^^^^^^^^^^^^^^ Remove physical volumes (PVs):: remove: @@ -141,7 +191,7 @@ Remove physical volumes (PVs):: /dev/sdf: ``lvm.pv.change`` --------------- +^^^^^^^^^^^^^^^^^ Change attributes of physical volume(s) (PVs):: pv: @@ -154,7 +204,7 @@ Change attributes of physical volume(s) (PVs):: debug: 1 ``lvm.pv.resize`` --------------- +^^^^^^^^^^^^^^^^^ Resize disk(s) or partition(s) in use by LVM2:: pv: @@ -165,7 +215,7 @@ Resize disk(s) or partition(s) in use by LVM2:: ``lvm.pv.move`` --------------- +^^^^^^^^^^^^^^^ Move allocated physical extents (PEs) from Source PV to other PV(s):: pv: @@ -177,7 +227,7 @@ Move allocated physical extents (PEs) from Source PV to other PV(s):: noudevsync: True ``lvm.pv.create`` --------------- +^^^^^^^^^^^^^^^^^ Initialize disk(s) or partition(s) for use by LVM:: pv: @@ -199,7 +249,7 @@ Initialize disk(s) or partition(s) for use by LVM:: ``lvm.vg.cfgbackup`` -------------------- +^^^^^^^^^^^^^^^^^^^^ Backup the metadata of your volume groups:: vg: @@ -211,7 +261,7 @@ Backup the metadata of your volume groups:: readonly: True ``lvm.vg.import`` --------------- +^^^^^^^^^^^^^^^^^ Make volume groups known to the system:: vg: @@ -221,7 +271,7 @@ Make volume groups known to the system:: verbose: True ``lvm.vg.clean`` --------------- +^^^^^^^^^^^^^^^^ Remove volume group(s):: vg: @@ -231,7 +281,7 @@ Remove volume group(s):: noudevsync: True ``lvm.vg.change`` --------------- +^^^^^^^^^^^^^^^^^ Change attributes of volume group(s):: vg: @@ -245,7 +295,7 @@ Change attributes of volume group(s):: ``lvm.vg.reduce`` --------------- +^^^^^^^^^^^^^^^^^ Remove one or more unused physical volumes from a volume group:: vg: @@ -257,7 +307,7 @@ Remove one or more unused physical volumes from a volume group:: removemissing: True ``lvm.vg.extend`` --------------- +^^^^^^^^^^^^^^^^^ Add physical volumes to a volume group(s):: vg: @@ -270,7 +320,7 @@ Add physical volumes to a volume group(s):: ``lvm.vg.split`` --------------- +^^^^^^^^^^^^^^^^ Split volume group(s) into two:: vg: @@ -285,7 +335,7 @@ Split volume group(s) into two:: maxlogicalvolumes: 0 ``lvm.vg.merge`` --------------- +^^^^^^^^^^^^^^^^ Merge two volume groups:: vg: @@ -294,7 +344,7 @@ Merge two volume groups:: withvg: vg001 ``lvm.vg.rename`` --------------- +^^^^^^^^^^^^^^^^^ Rename volume group(s):: vg: @@ -303,7 +353,7 @@ Rename volume group(s):: newname: vg002old ``lvm.vg.create`` --------------- +^^^^^^^^^^^^^^^^^ Create volume group(s):: vg: @@ -324,7 +374,7 @@ Create volume group(s):: - /dev/sdf ``lvm.vg.export`` --------------- +^^^^^^^^^^^^^^^^^ Make volume groups unknown to the system:: vg: @@ -335,7 +385,7 @@ Make volume groups unknown to the system:: commandprofile: command_profile_template ``lvm.vg.cfgrestore`` -------------------- +^^^^^^^^^^^^^^^^^^^^^ Restore the metadata of VG(s) from text backup files produced by ``lvm.vg.cfgbackup`` state:: vg: @@ -349,7 +399,7 @@ Restore the metadata of VG(s) from text backup files produced by ``lvm.vg.cfgbac ``lvm.lv.clean`` ---------------- +^^^^^^^^^^^^^^^^ Remove LV(s):: lv: @@ -378,7 +428,7 @@ Remove LV(s):: force: True ``lvm.lv.change`` ----------------- +^^^^^^^^^^^^^^^^^ Change attributes of logical volume(s):: lv: @@ -391,7 +441,7 @@ Change attributes of logical volume(s):: deltag: 'badlvs' ``lvm.lv.reduce`` ---------------- +^^^^^^^^^^^^^^^^^ Reduce size of logical volume(s):: lv: @@ -404,7 +454,7 @@ Reduce size of logical volume(s):: size: -20MiB ``lvm.lv.extend`` ----------------- +^^^^^^^^^^^^^^^^^ Extend size of logical volume(s):: lv: @@ -417,7 +467,7 @@ Extend size of logical volume(s):: - /dev/sdf ``lvm.lv.rename`` -------------- +^^^^^^^^^^^^^^^^^ Rename LV(s):: lv: @@ -427,7 +477,7 @@ Rename LV(s):: newname: lvolvo ``lvm.lv.create`` ----------------- +^^^^^^^^^^^^^^^^^ Create logical volume(s) in existing volume group(s):: lv: @@ -463,7 +513,7 @@ Note:: Thin provisioning needs two `create` states to run (`create`, `convert`, ``lvm.lv.convert`` ----------------- +^^^^^^^^^^^^^^^^^^ Change LV type and other utilities:: lv: @@ -494,17 +544,50 @@ Change LV type and other utilities:: Note:: Thin provisioning needs two `create` states to run (`create`, `convert`, and `create`). -Todo -======= -- global filter support is important -- test some advanced LV/RAID scenarios -- file systems mngt +Testing +------- -Good Pillar data -================= -Bad conf(5)iguration causes problems. Sanity check pillar data when troubleshooting "``unable to``" state failures. +.. contents:: + :local: -OS families -================= -All Linux distributions supported. +Linux testing is done with ``kitchen-salt``. + +Requirements +^^^^^^^^^^^^ + +* Ruby +* Docker + +.. code-block:: bash + + $ gem install bundler + $ bundle install + $ bin/kitchen test [platform] + +Where ``[platform]`` is the platform name defined in ``kitchen.yml``, +e.g. ``debian-9-2019-2-py3``. + +``bin/kitchen converge`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Creates the docker instance and runs the ``template`` main state, ready for testing. + +``bin/kitchen verify`` +^^^^^^^^^^^^^^^^^^^^^^ + +Runs the ``inspec`` tests on the actual instance. + +``bin/kitchen destroy`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Removes the docker instance. + +``bin/kitchen test`` +^^^^^^^^^^^^^^^^^^^^ + +Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``. + +``bin/kitchen login`` +^^^^^^^^^^^^^^^^^^^^^ +Gives you SSH access to the instance for manual testing. diff --git a/kitchen.yml b/kitchen.yml index be76fcc..2f65a53 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -53,6 +53,13 @@ platforms: provision_command: - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com - sh bootstrap-salt.sh -XdPbfrq -x python2 git develop + - name: arch-base-latest-develop-py2 + driver: + image: netmanagers/salt-develop-py2:arch-base-latest + provision_command: + - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com + - sh bootstrap-salt.sh -XdPbfrq -x python2 git develop + run_command: /usr/lib/systemd/systemd ## SALT `2019.2` - name: debian-9-2019-2-py3 @@ -78,6 +85,10 @@ platforms: - name: amazonlinux-2-2019-2-py2 driver: image: netmanagers/salt-2019.2-py2:amazonlinux-2 + - name: arch-base-latest-2019-2-py2 + driver: + image: netmanagers/salt-2019.2-py2:arch-base-latest + run_command: /usr/lib/systemd/systemd ## SALT `2018.3` - name: debian-9-2018-3-py2 @@ -103,6 +114,10 @@ platforms: - name: amazonlinux-2-2018-3-py2 driver: image: netmanagers/salt-2018.3-py2:amazonlinux-2 + - name: arch-base-latest-2018-3-py2 + driver: + image: netmanagers/salt-2018.3-py2:arch-base-latest + run_command: /usr/lib/systemd/systemd ## SALT `2017.7` - name: debian-8-2017-7-py2 @@ -129,10 +144,14 @@ platforms: - name: amazonlinux-2-2017-7-py2 driver: image: netmanagers/salt-2017.7-py2:amazonlinux-2 + - name: arch-base-latest-2017-7-py2 + driver: + image: netmanagers/salt-2017.7-py2:arch-base-latest + run_command: /usr/lib/systemd/systemd provisioner: name: salt_solo - log_level: info + log_level: debug salt_install: none require_chef: false formula: lvm @@ -151,10 +170,6 @@ verifier: suites: - name: default provisioner: - dependencies: - - name: lvm - repo: git - source: https://github.com/saltstack-formulas/lvm-formula.git state_top: base: '*': diff --git a/pre-commit_semantic-release.sh b/pre-commit_semantic-release.sh new file mode 100755 index 0000000..9d34d74 --- /dev/null +++ b/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 .. diff --git a/release-rules.js b/release-rules.js new file mode 100644 index 0000000..c63c850 --- /dev/null +++ b/release-rules.js @@ -0,0 +1,18 @@ +// No release is triggered for the types commented out below. +// Commits using these types will be incorporated into the next release. +// +// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. +module.exports = [ + {breaking: true, release: 'major'}, + // {type: 'build', release: 'patch'}, + // {type: 'chore', release: 'patch'}, + // {type: 'ci', release: 'patch'}, + {type: 'docs', release: 'patch'}, + {type: 'feat', release: 'minor'}, + {type: 'fix', release: 'patch'}, + {type: 'perf', release: 'patch'}, + {type: 'refactor', release: 'patch'}, + {type: 'revert', release: 'patch'}, + {type: 'style', release: 'patch'}, + {type: 'test', release: 'patch'}, +]; diff --git a/release.config.js b/release.config.js new file mode 100644 index 0000000..afa0cb1 --- /dev/null +++ b/release.config.js @@ -0,0 +1,106 @@ +module.exports = { + branch: 'master', + plugins: [ + ['@semantic-release/commit-analyzer', { + preset: 'angular', + releaseRules: './release-rules.js', + }], + '@semantic-release/release-notes-generator', + ['@semantic-release/changelog', { + changelogFile: 'CHANGELOG.md', + changelogTitle: '# Changelog', + }], + ['@semantic-release/exec', { + prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}', + }], + ['@semantic-release/git', { + assets: ['*.md', 'docs/*.rst', 'FORMULA'], + }], + '@semantic-release/github', + ], + generateNotes: { + preset: 'angular', + writerOpts: { + // Required due to upstream bug preventing all types being displayed. + // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317 + // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410 + transform: (commit, context) => { + const issues = [] + + commit.notes.forEach(note => { + note.title = `BREAKING CHANGES` + }) + + // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. + if (commit.type === `feat`) { + commit.type = `Features` + } else if (commit.type === `fix`) { + commit.type = `Bug Fixes` + } else if (commit.type === `perf`) { + commit.type = `Performance Improvements` + } else if (commit.type === `revert`) { + commit.type = `Reverts` + } else if (commit.type === `docs`) { + commit.type = `Documentation` + } else if (commit.type === `style`) { + commit.type = `Styles` + } else if (commit.type === `refactor`) { + commit.type = `Code Refactoring` + } else if (commit.type === `test`) { + commit.type = `Tests` + } else if (commit.type === `build`) { + commit.type = `Build System` + // } else if (commit.type === `chore`) { + // commit.type = `Maintenance` + } else if (commit.type === `ci`) { + commit.type = `Continuous Integration` + } else { + return + } + + if (commit.scope === `*`) { + commit.scope = `` + } + + if (typeof commit.hash === `string`) { + commit.hash = commit.hash.substring(0, 7) + } + + if (typeof commit.subject === `string`) { + let url = context.repository + ? `${context.host}/${context.owner}/${context.repository}` + : context.repoUrl + if (url) { + url = `${url}/issues/` + // Issue URLs. + commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { + issues.push(issue) + return `[#${issue}](${url}${issue})` + }) + } + if (context.host) { + // User URLs. + commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => { + if (username.includes('/')) { + return `@${username}` + } + + return `[@${username}](${context.host}/${username})` + }) + } + } + + // remove references that already appear in the subject + commit.references = commit.references.filter(reference => { + if (issues.indexOf(reference.issue) === -1) { + return true + } + + return false + }) + + return commit + }, + }, + }, +}; diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml index e15862a..c1c38ec 100644 --- a/test/integration/default/inspec.yml +++ b/test/integration/default/inspec.yml @@ -15,3 +15,4 @@ supports: - platform-name: suse - platform-name: freebsd - platform-name: amazon + - platform-name: arch