certego / .github

CI repo for Certego DevOps
https://www.certego.net
5 stars 0 forks source link
ci-cd devops

CI

Certego

.github

This repository contains CI workflows for Certego projects. It also contains the recommended configurations for linters and formatters.

βš™οΈ CI components

πŸ”΄ Pull request automation

Automatically executed on every PR. Manages tests and lints stuff. To customize for your project.

πŸ”΄ Release

Automatically executed on every closed PR to the master branch that matches the regex ^[0-9]+\.[0-9]+\.[0-9]+$ . Manages release stuff. To customize for your project.

⇩

🟑 Reusable workflows

They receive input props and call actions.

⇩

🟒 Composite actions

They execute commands (linters, tests,...)

CI features

Actually CI actions commands implement this features:

Other CI features:

This repository also contains configurations for:

🧰 Action configurations (linters, formatters, docs, coverage...)

See here


πŸ“– How to use

Add this repository to your project using git subtree command:

git subtree add --squash --prefix .github https://github.com/certego/.github.git main  && rm -rf .github/{.github,README.md}

Customize options of Pull request automation
Customize linters in configurations folder
Customize dependabot.
Customize CHANGELOG

Update the subtree every time a new release of this repository is rolled. Pay attention,be careful to not lose your changes.

git subtree pull --squash --prefix .github https://github.com/certego/.github  main && rm -rf .github/{.github,README.md}

Note: DO NOT squash the commits in which you added/pulled subtree, otherwise git-subtree-dir info in git log will be lost

Configure your project to use CI following below instructions.

Python

CI automatically installs and calls code analyzers this way:

pylint --rcfile=.github/configurations/python_linters/.pylintrc
bandit -c .github/configurations/python_linters/.bandit.yaml
flake8 --config .github/configurations/python_linters/.flake8
black --config .github/configurations/python_linters/.black
isort --settings-path .github/configurations/python_linters/.isort.cfg --profile black --filter-files --skip venv

For local installation and customization, see here

(Opt.) Pre-commit

Add pre-commit to your python requirements. Configure this configuration file in your .github dir. From root of your project install:

pre-commit install -c .github/.pre-commit-config.yaml

Pre-commit will add hook .git/hooks/pre-commit for you.

Node.js

Add to package.json these scripts (configure paths), CI automatically installs and calls them:

"config": {
    "eslint": ".github/configurations/node_linters/eslint/.eslintrc.json",
    "stylelint": ".github/configurations/node_linters/stylelint/.stylelintrc.json",
    "prettier": ".github/configurations/node_linters/prettier/.prettierrc.js"
},
"scripts": {
    "test": "TZ=UTC jest ./tests --silent",
    "test-coverage": "npm test -- --coverage=true",
    "lint-config-install": "cd $(dirname $npm_package_config_eslint) && npm i",
    "lint": "eslint -c $npm_package_config_eslint 'src/**/*.{js,jsx}' 'tests/**/*.{js,jsx}'",
    "lint-fix": "npm run lint -- --fix",
    "lint-scss-config-install": "cd $(dirname $npm_package_config_stylelint) && npm i",
    "lint-scss": "stylelint --config $npm_package_config_stylelint 'src/scss/**/*.{css,scss}'",
    "lint-scss-fix": "npm run lint-scss -- --fix",
    "formatter": "prettier --config $npm_package_config_prettier 'src/**/*.{js,jsx}' 'tests/**/*.{js,jsx}' 'src/scss/**/*.{css,scss}' --check",
    "formatter-fix": "npm run formatter -- --write"
},

For local installation and customization see here.

(Opt.) Pre-commit

To enable pre-commit add this to your package.json (configure paths, prettier is optional). Note: starting point of husky install must be same directory as .git

    "scripts": {
        "prepare": "cd ./ && husky install .github/.husky"
    },
    "lint_staged": {
        "*.{js,jsx}": ["eslint -c .github/configurations/node_linters/eslint/.eslintrc.json"] //, "prettier --config .github/configurations/node_linters/prettier/.prettierrc.js"],
        "*.{css,scss}": ["stylelint --config .github/configurations/node_linters/stylelint/.stylelintrc.json"] // , "prettier --config .github/configurations/node_linters/prettier/.prettierrc.js"]
    },

Then execute this command:

npm i -D husky lint-staged && npm run prepare

πŸ”§ Development

To contribute to this repository, please see here