Skip to content

Commit

Permalink
Merge pull request #275 from myii/feat/replace-Travis-CI-with-GitLab-CI
Browse files Browse the repository at this point in the history
feat: replace Travis CI with GitLab CI
  • Loading branch information
myii authored Dec 17, 2020
2 parents 561c2c8 + e8deac3 commit b4b0900
Show file tree
Hide file tree
Showing 22 changed files with 1,155 additions and 285 deletions.
83 changes: 83 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
###############################################################################
# Define all YAML node anchors
###############################################################################
.node_anchors:
# `only` (also used for `except` where applicable)
only_branch_master_parent_repo: &only_branch_master_parent_repo
- 'master@myii/ssf-formula'
# `stage`
stage_lint: &stage_lint 'lint'
stage_release: &stage_release 'release'
# `image`
image_commitlint: &image_commitlint 'myii/ssf-commitlint:11'
image_precommit: &image_precommit
name: 'myii/ssf-pre-commit:2.9.2'
entrypoint: ['/bin/bash', '-c']
image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14'

###############################################################################
# Define stages and global variables
###############################################################################
stages:
- *stage_lint
- *stage_release
variables:
DOCKER_DRIVER: 'overlay2'

###############################################################################
# `lint` stage: `commitlint` & `pre-commit`
###############################################################################
commitlint:
stage: *stage_lint
image: *image_commitlint
script:
# Add `upstream` remote to get access to `upstream/master`
- 'git remote add upstream ${CI_PROJECT_URL}.git'
- 'git fetch --all'
# Set default commit hashes for `--from` and `--to`
- 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"'
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
# `coqbot` adds a merge commit to test PRs on top of the latest commit in
# the repo; amend this merge commit message to avoid failure
- |
if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \
&& [ "${CI_COMMIT_BRANCH}" != "master" ]; then
git commit --amend -m \
'chore: reword coqbot merge commit message for commitlint'
export COMMITLINT_TO=HEAD
fi
# Run `commitlint`
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'

pre-commit:
stage: *stage_lint
image: *image_precommit
# https://pre-commit.com/#gitlab-ci-example
variables:
PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit'
cache:
key: '${CI_JOB_NAME}'
paths:
- '${PRE_COMMIT_HOME}'
script:
- 'pre-commit run --all-files --color always --verbose'

###############################################################################
# `release` stage: `semantic-release`
###############################################################################
semantic-release:
only: *only_branch_master_parent_repo
stage: *stage_release
image: *image_semanticrelease
variables:
MAINTAINER_TOKEN: '${GH_TOKEN}'
script:
# Update `AUTHORS.md`
- '${HOME}/go/bin/maintainer contributor'
# Run `semantic-release`
- 'semantic-release'
100 changes: 0 additions & 100 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ extends: 'default'
# 4. All Jinja templates under `ssf/files/` (result in `yamllint` syntax errors)
# Not disabling via. `*.yml` since we may end up with non-Jinja YAML files here
ignore: |
.cache/
node_modules/
test/**/states/**/*.sls
.kitchen/
ssf/files/default/.cirrus.yml
ssf/files/default/.gitlab-ci.yml
ssf/files/default/.pre-commit-config.yaml
ssf/files/default/.rubocop.yml
ssf/files/default/.salt-lint
Expand Down
19 changes: 17 additions & 2 deletions docs/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The entire process relies on the structure of commit messages to determine the v
Full details are available in the upstream docs regarding the `Angular Commit Message Conventions <https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines>`_.
The key factor is that the first line of the commit message must follow this format:

.. code-block::
.. code-block:: console
type(scope): subject
Expand All @@ -55,6 +55,22 @@ So based on the example above:
* The ``(scope):`` will be shown in bold text without the brackets.
* The ``subject`` follows the ``scope`` as standard text.

pre-commit
^^^^^^^^^^

`pre-commit <https://pre-commit.com/>`_ is configured for this formula, which you may
optionally use to ease the steps involved in submitting your changes, including
checking the formatting of your commit messages.

First install the ``pre-commit`` package manager locally using the appropriate
`method <https://pre-commit.com/#installation>`_, then run ``bin/install-hooks`` in the
formula's root directory and now ``pre-commit`` will run automatically on each
``git commit``. ::

$ bin/install-hooks
pre-commit installed at .git/hooks/pre-commit
pre-commit installed at .git/hooks/commit-msg

Linting commit messages in Travis CI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -156,4 +172,3 @@ An example of that:
BREAKING CHANGE: With the removal of all of the `.sls` files under
`template package`, this formula no longer supports the installation of
packages.
6 changes: 3 additions & 3 deletions docs/TOFS_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Example: NTP before applying TOFS

Let's work with the NTP example. A basic formula that follows the `design guidelines <http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_ has the following files and directories tree:

.. code-block::
.. code-block:: console
/srv/saltstack/salt-formulas/ntp-saltstack-formula/
ntp/
Expand Down Expand Up @@ -226,7 +226,7 @@ We can make different templates coexist for different minions, classified by any

If we decide that we want ``os_family`` as switch, then we could provide the formula template variants for both the ``RedHat`` and ``Debian`` families.

.. code-block::
.. code-block:: console
/srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/files/
default/
Expand Down Expand Up @@ -449,7 +449,7 @@ Using sub-directories for ``components``

If your formula is composed of several components, you may prefer to provides files under sub-directories, like in the `systemd-formula <https://github.com/saltstack-formulas/systemd-formula>`_.

.. code-block::
.. code-block:: console
/srv/saltstack/systemd-formula/
systemd/
Expand Down
1 change: 1 addition & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ ssf:
- inspec/README.md
- .gitignore
- .cirrus.yml
- .gitlab-ci.yml
- .pre-commit-config.yaml
- .rstcheck.cfg
- .rubocop.yml
Expand Down
2 changes: 1 addition & 1 deletion pre-commit_semantic-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA
###############################################################################

# Install `m2r`
sudo -H pip install m2r
pip3 install m2r

# Copy and then convert the `.md` docs
cp ./*.md docs/
Expand Down
1 change: 1 addition & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
branch: 'master',
repositoryUrl: 'https://github.com/myii/ssf-formula',
plugins: [
['@semantic-release/commit-analyzer', {
preset: 'angular',
Expand Down
5 changes: 4 additions & 1 deletion ssf/config/formulas.sls
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ prepare-git-branch-for-{{ formula }}:
{#- Or if the file is `libsaltcli.jinja` and `use_libsaltcli` is `False` #}
{#- Likewise, if running the state for TOFS files when `use_tofs` is `False` #}
{#- Also remove the local `CONTRIBUTING` file to use the org-level file instead #}
{#- Furthermore, remove `.travis.yml` for the `ssf-formula` #}
{%- if (semrel_file == '.cirrus.yml' and not use_cirrus_ci) or
(semrel_file == 'formula/libsaltcli.jinja' and not use_libsaltcli) or
(semrel_file in ['docs/TOFS_pattern.rst', 'formula/libtofs.jinja'] and not use_tofs) or
(semrel_file in ['docs/CONTRIBUTING.rst'] and formula not in ['.github', 'ssf-formula'])
(semrel_file in ['docs/CONTRIBUTING.rst'] and formula not in ['.github', 'ssf-formula']) or
(semrel_file in ['.travis.yml'] and formula in ['ssf-formula'])
%}
{%- set add_or_rm = ['rm', 'remove', 'absent'] %}
{%- endif %}
Expand Down Expand Up @@ -134,6 +136,7 @@ prepare-git-branch-for-{{ formula }}:
owner: {{ owner }}
formula: {{ formula }}
codeowners: {{ context.codeowners | yaml }}
gitlab: {{ context.git.gitlab | yaml }}
inspec_suites_kitchen: {{ inspec_suites_kitchen | yaml }}
inspec_suites_matrix: {{ context.inspec_suites_matrix | yaml }}
kitchen: {{ context.kitchen | yaml }}
Expand Down
Loading

0 comments on commit b4b0900

Please sign in to comment.