From 3748681ee78dfdbe8992b18409f1b656a33d408b Mon Sep 17 00:00:00 2001 From: lotyp Date: Mon, 22 Apr 2024 00:52:44 +0300 Subject: [PATCH] feat: default health files and basic CI workflows --- .editorconfig | 20 ++++ .github/.commitlint.config.mjs | 44 +++++++++ .github/.cz.config.js | 65 +++++++++++++ .github/.release-please-config.json | 72 +++++++++++++++ .github/.release-please-manifest.json | 3 + .github/CODEOWNERS | 3 + .github/CODE_OF_CONDUCT.md | 128 ++++++++++++++++++++++++++ .github/FUNDING.yml | 5 + .github/labeler.yml | 20 ++++ .github/workflows/apply-labels.yml | 25 +++++ .github/workflows/create-release.yml | 27 ++++++ .github/workflows/integrate.yml | 50 ++++++++++ .pre-commit-config.yaml | 26 ++++++ .yamllint.yaml | 54 +++++++++++ Makefile | 92 ++++++++++++++++++ renovate.json | 7 ++ 16 files changed, 641 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/.commitlint.config.mjs create mode 100644 .github/.cz.config.js create mode 100644 .github/.release-please-config.json create mode 100644 .github/.release-please-manifest.json create mode 100644 .github/CODEOWNERS create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/FUNDING.yml create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/apply-labels.yml create mode 100644 .github/workflows/create-release.yml create mode 100644 .github/workflows/integrate.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .yamllint.yaml create mode 100644 Makefile create mode 100644 renovate.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9a20762 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*{.yml,.yaml}] +indent_style = space +indent_size = 2 + +[*.json] +indent_style = space +indent_size = 4 diff --git a/.github/.commitlint.config.mjs b/.github/.commitlint.config.mjs new file mode 100644 index 0000000..49f1f95 --- /dev/null +++ b/.github/.commitlint.config.mjs @@ -0,0 +1,44 @@ +// More info: https://github.com/wayofdev/npm-shareable-configs/blob/master/packages/commitlint-config/src/index.js +const automaticCommitPattern = /^chore\(release\):.*\[skip ci]/ + +export default { + extends: ['@commitlint/config-conventional'], + /* + This resolves a linting conflict between commitlint's body-max-line-length + due to @semantic-release/git putting release notes in the commit body + https://github.com/semantic-release/git/issues/331 + */ + ignores: [(commitMessage) => automaticCommitPattern.test(commitMessage)], + rules: { + 'body-leading-blank': [1, 'always'], + 'body-max-line-length': [2, 'always', 120], + 'footer-leading-blank': [1, 'always'], + 'footer-max-line-length': [2, 'always', 120], + 'header-max-length': [2, 'always', 100], + 'scope-case': [2, 'always', 'lower-case'], + 'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], + 'type-enum': [ + 2, + 'always', + [ + 'feat', // New feature + 'fix', // Bug fix + 'perf', // Performance improvement + 'docs', // Documentation changes + 'style', // Code style update (formatting, missing semi colons, etc) + 'deps', // Dependency updates + 'refactor', // Code refactoring + 'ci', // Continuous integration changes + 'test', // Adding missing tests + 'revert', // Revert to a previous commit + 'build', // Changes that affect the build system + 'chore', // Other changes that don't modify src or test files + 'security', // Security improvements + ], + ], + }, +} diff --git a/.github/.cz.config.js b/.github/.cz.config.js new file mode 100644 index 0000000..5f951c6 --- /dev/null +++ b/.github/.cz.config.js @@ -0,0 +1,65 @@ +// @see https://cz-git.qbb.sh/config/#configure-template +module.exports = { + alias: { fd: 'docs: fix typos' }, + messages: { + type: 'Select the type of change that you\'re committing:', + scope: 'Denote the SCOPE of this change (optional):', + customScope: 'Denote the SCOPE of this change:', + subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n', + body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n', + breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n', + footerPrefixesSelect: 'Select the ISSUES type of changeList by this change (optional):', + customFooterPrefix: 'Input ISSUES prefix:', + footer: 'List any ISSUES by this change. E.g.: #31, #34:\n', + generatingByAI: 'Generating your AI commit subject...', + generatedSelectByAI: 'Select suitable subject by AI generated:', + confirmCommit: 'Are you sure you want to proceed with the commit above?' + }, + types: [ + { value: 'feat', name: 'feat: A new feature', emoji: ':sparkles:' }, + { value: 'fix', name: 'fix: A bug fix', emoji: ':bug:' }, + { value: 'perf', name: 'perf: A code change that improves performance', emoji: ':zap:' }, + { value: 'docs', name: 'docs: Documentation only changes', emoji: ':memo:' }, + { value: 'style', name: 'style: Changes that do not affect the meaning of the code', emoji: ':lipstick:' }, + { value: 'deps', name: 'deps: A dependency update', emoji: ':package:' }, + { value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature', emoji: ':recycle:' }, + { value: 'ci', name: 'ci: Changes to our CI configuration files and scripts', emoji: ':ferris_wheel:' }, + { value: 'test', name: 'test: Adding missing tests or correcting existing tests', emoji: ':white_check_mark:' }, + { value: 'revert', name: 'revert: Reverts a previous commit', emoji: ':rewind:' }, + { value: 'build', name: 'build: Changes that affect the build system or external dependencies', emoji: ':package:' }, + { value: 'chore', name: 'chore: Other changes that don\'t modify src or test files', emoji: ':hammer:' }, + { value: 'security', name: 'security: A code change that fixes a security issue', emoji: ':lock:' } + ], + useEmoji: false, + emojiAlign: 'center', + useAI: false, + aiNumber: 1, + themeColorCode: '', + scopes: [], + allowCustomScopes: true, + allowEmptyScopes: true, + customScopesAlign: 'bottom', + customScopesAlias: 'custom', + emptyScopesAlias: 'empty', + upperCaseSubject: false, + markBreakingChangeMode: false, + allowBreakingChanges: ['feat', 'fix'], + breaklineNumber: 100, + breaklineChar: '|', + skipQuestions: [], + issuePrefixes: [{ value: 'closed', name: 'closed: ISSUES has been processed' }], + customIssuePrefixAlign: 'top', + emptyIssuePrefixAlias: 'skip', + customIssuePrefixAlias: 'custom', + allowCustomIssuePrefix: true, + allowEmptyIssuePrefix: true, + confirmColorize: true, + maxHeaderLength: Infinity, + maxSubjectLength: Infinity, + minSubjectLength: 0, + scopeOverrides: undefined, + defaultBody: '', + defaultIssues: '', + defaultScope: '', + defaultSubject: '' +} diff --git a/.github/.release-please-config.json b/.github/.release-please-config.json new file mode 100644 index 0000000..c4f1e72 --- /dev/null +++ b/.github/.release-please-config.json @@ -0,0 +1,72 @@ +{ + "release-type": "node", + "packages": { + ".": { + "package-name": ".github", + "changelog-path": "/CHANGELOG.md" + } + }, + "include-component-in-tag": false, + "changelog-sections": [ + { + "type": "feat", + "section": "Features", + "hidden": false + }, + { + "type": "fix", + "section": "Bug Fixes", + "hidden": false + }, + { + "type": "perf", + "section": "Performance Improvements", + "hidden": false + }, + { + "type": "docs", + "section": "Documentation", + "hidden": false + }, + { + "type": "deps", + "section": "Dependencies", + "hidden": false + }, + { + "type": "refactor", + "section": "Code Refactoring", + "hidden": false + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System", + "hidden": true + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + }, + { + "type": "chore", + "section": "Miscellaneous", + "hidden": true + }, + { + "type": "style", + "section": "Styles", + "hidden": true + }, + { + "type": "revert", + "section": "Reverts", + "hidden": true + } + ] +} diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 0000000..1772e6f --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.0.0" +} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..98af7f9 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners + +* @lotyp diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..f01cff3 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[the@wayof.dev](mailto:the@wayof.dev). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html). + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at +[https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..1d7f6ba --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,5 @@ +--- + +github: wayofdev + +... diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..e5d4038 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,20 @@ +--- + +# this file is for the labeler workflow job +# Documentation https://github.com/marketplace/actions/labeler + +"type: bug": + - head-branch: ['^bug', '^fix', 'bug', 'fix'] + +"type: enhancement": + - head-branch: ['^feature', '^feat', 'feature'] + +"type: documentation": + - changed-files: + - any-glob-to-any-file: ['assets/**/*', '.github/*', './*.md'] + +"type: maintenance": + - changed-files: + - any-glob-to-any-file: ['tests/**/*', '.github/workflows/*'] + +... diff --git a/.github/workflows/apply-labels.yml b/.github/workflows/apply-labels.yml new file mode 100644 index 0000000..d84e66e --- /dev/null +++ b/.github/workflows/apply-labels.yml @@ -0,0 +1,25 @@ +--- + +# This workflow will triage pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler/blob/master/README.md + +on: # yamllint disable-line rule:truthy + pull_request: + types: + - opened + +name: 🏷️ Add labels + +jobs: + label: + uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@v3.0.0 + with: + os: ubuntu-latest + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + +... diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..e1245aa --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,27 @@ +--- + +# https://github.com/wayofdev/gh-actions/blob/master/.github/workflows/create-release.yml +# https://github.com/google-github-actions/release-please-action#release-types-supported +# https://github.com/googleapis/release-please/blob/main/docs/customizing.md + +on: # yamllint disable-line rule:truthy + push: + branches: + - master + +name: 📦 Create release + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: 🎉 Create release + uses: google-github-actions/release-please-action@v4 + id: release + with: + token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} + config-file: .github/.release-please-config.json + manifest-file: .github/.release-please-manifest.json + target-branch: master + +... diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml new file mode 100644 index 0000000..79b1911 --- /dev/null +++ b/.github/workflows/integrate.yml @@ -0,0 +1,50 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + +name: 🔍 Continuous integration + +jobs: + commit-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: commit-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + permissions: + contents: read + pull-requests: read + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.1 + + # See: https://github.com/wagoid/commitlint-github-action + - name: 🧐 Lint commits using "commitlint" + uses: wagoid/commitlint-github-action@v6.0.1 + with: + configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs + failOnWarnings: false + failOnErrors: true + helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' + + coding-standards: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.1 + + - name: 🧐 Lint YAML files + uses: ibiqlik/action-yamllint@v3.1.1 + with: + config_file: .yamllint.yaml + file_or_dir: '.' + strict: true + +... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a9a5d3a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +--- + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files + - id: fix-encoding-pragma + + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.24.0 + hooks: + - id: commitizen + stages: + - commit-msg + + - repo: https://github.com/mpalmer/action-validator + rev: v0.6.0 + hooks: + - id: action-validator + stages: + - commit-msg + +... diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..e0222d9 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,54 @@ +--- + +extends: default + +ignore: | + assets/ + +rules: + braces: + # Defaults + # min-spaces-inside: 0 + # max-spaces-inside: 0 + + # Keep 0 min-spaces to not error on empty {} collection definitions + min-spaces-inside: 0 + + # Allow one space inside braces to improve code readability + max-spaces-inside: 1 + + brackets: + # Defaults + # min-spaces-inside: 0 + # max-spaces-inside: 0 + + # Keep 0 min-spaces to not error on empty [] collection definitions + min-spaces-inside: 0 + + # Allow one space inside braces to improve code readability + max-spaces-inside: 1 + + colons: + # Defaults + # min-spaces-before: 0 + # max-spaces-after: 1 + + # Allow multiple spaces after a colon to allow indentation of YAML + # dictionary values + max-spaces-after: -1 + + commas: + # Defaults + # max-spaces-after: 1 + + # Allow multiple spaces after a comma to allow indentation of YAML + # dictionary values + max-spaces-after: -1 + + comments: + require-starting-space: true + min-spaces-from-content: 1 + + line-length: disable + +... diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..53d60c1 --- /dev/null +++ b/Makefile @@ -0,0 +1,92 @@ +# Docker binary to use, when executing docker tasks +DOCKER ?= docker + +YAML_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \ + -v $(shell pwd):/data \ + cytopia/yamllint:latest \ + -f colored . + +ACTION_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \ + -v $(shell pwd):/repo \ + --workdir /repo \ + rhysd/actionlint:latest \ + -color + +# +# Self documenting Makefile code +# ------------------------------------------------------------------------------------ +ifneq ($(TERM),) + BLACK := $(shell tput setaf 0) + RED := $(shell tput setaf 1) + GREEN := $(shell tput setaf 2) + YELLOW := $(shell tput setaf 3) + LIGHTPURPLE := $(shell tput setaf 4) + PURPLE := $(shell tput setaf 5) + BLUE := $(shell tput setaf 6) + WHITE := $(shell tput setaf 7) + RST := $(shell tput sgr0) +else + BLACK := "" + RED := "" + GREEN := "" + YELLOW := "" + LIGHTPURPLE := "" + PURPLE := "" + BLUE := "" + WHITE := "" + RST := "" +endif +MAKE_LOGFILE = /tmp/wayofdev-dot-github.log +MAKE_CMD_COLOR := $(BLUE) + +default: all + +help: ## Show this menu + @echo 'Management commands for package:' + @echo 'Usage:' + @echo ' ${MAKE_CMD_COLOR}make${RST} Installs pre-commit hooks and does linting' + @grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}' + @echo + @echo ' 📑 Logs are stored in $(MAKE_LOGFILE)' + @echo + @echo ' 📦 Package .github (https://github.com/wayofdev/.github)' + @echo ' 🤠 Author Andrij Orlenko (https://github.com/lotyp)' + @echo ' 🏢 ${YELLOW}Org wayofdev (https://github.com/wayofdev)${RST}' + @echo +.PHONY: help + +.EXPORT_ALL_VARIABLES: + +# +# Default action +# Defines default command when `make` is executed without additional parameters +# ------------------------------------------------------------------------------------ +all: hooks lint +.PHONY: all + +# +# Code Quality, Git, Linting +# ------------------------------------------------------------------------------------ +hooks: ## Install git hooks from pre-commit-config + pre-commit install + pre-commit install --hook-type commit-msg + pre-commit autoupdate +.PHONY: hooks + +lint: lint-yaml lint-actions ## Lint all files +.PHONY: lint + +lint-yaml: ## Lint all yaml files + @$(YAML_LINT_RUNNER) +.PHONY: lint-yaml + +lint-actions: ## Lint all github actions + @$(ACTION_LINT_RUNNER) +.PHONY: lint-actions + +# +# Release +# ------------------------------------------------------------------------------------ +commit: + czg commit --config="./.github/.cz.config.js" +.PHONY: commit diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..0c17a5e --- /dev/null +++ b/renovate.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base"], + "prHourlyLimit": 0, + "automerge": true, + "platformAutomerge": true +}