Skip to content

Instantly share code, notes, and snippets.

@wwmoraes
Last active April 27, 2024 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwmoraes/75dc66767a9f487c8235c5423027f69c to your computer and use it in GitHub Desktop.
Save wwmoraes/75dc66767a9f487c8235c5423027f69c to your computer and use it in GitHub Desktop.
repository template
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[.vscode/*.json]
insert_final_newline = false
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab
[*.mk]
indent_style = tab
[*.go]
indent_style = tab
[go.mod]
indent_style = tab
[.git*]
indent_style = tab
# yaml-language-server: $schema=https://json.schemastore.org/lefthook.json
assert_lefthook_installed: true
remotes:
- git_url: https://github.com/wwmoraes/lefthook-configs
configs:
- golang.yaml
commit-msg:
commands:
# commitlint:
# run: /usr/bin/env true
trailers:
run: git interpret-trailers --trailer "sign" --trim-empty "{1}" | sponge "{1}"
pre-push:
piped: true
commands:
configure:
priority: 10
run: lefthook run lint
env:
LEFTHOOK_QUIET: meta,success
lint:
priority: 20
run: lefthook run lint
env:
LEFTHOOK_QUIET: meta,success
configure:
commands:
golang-mod:
run: go mod tidy
glob: "{**/*.go,go.mod}"
stage_fixed: true
tags: golang
vale-sync:
run: vale sync
glob: .vale.ini
lint:
parallel: true
commands:
typos:
run: typos --force-exclude {staged_files}
exclude: .*\.(jpg|png)$
checkmake:
run: checkmake {staged_files}
glob: Makefile
editorconfig-checker:
run: editorconfig-checker {staged_files}
exclude: .*\.(jpg|png)$
vale:
run: vale {staged_files}
exclude: (\.styles)/.*
stylelint:
run: stylelint -f compact {staged_files}
glob: "**/*.{sass,scss}"
tags: css
gofumpt:
run: gofumpt -l -w {staged_files}
glob: "**/*.go"
stage_fixed: true
tags: golang
golangci-lint:
run: golangci-lint run
glob: "**/*.go"
tags: golang
## See https://pre-commit.com for more information
## See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
args:
- --assume-in-merge
- id: check-vcs-permalinks
- id: check-yaml
args: [--allow-multiple-documents]
- id: detect-private-key
# - id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
# - id: no-commit-to-branch
- id: trailing-whitespace
- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
hooks:
- id: check-json5
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.4.0
hooks:
- id: editorconfig-checker
exclude: vscode/.config/Code/User/globalStorage/.*
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.1
hooks:
- id: markdownlint
- repo: https://github.com/hadolint/hadolint
rev: v2.10.0
hooks:
- id: hadolint
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-beta.5
hooks:
- id: golangci-lint-repo-mod
name: golangci-lint
- id: go-mod-tidy
name: go mod tidy
- id: go-build-repo-mod
name: go build
- id: go-test-repo-mod
name: go test
ci:
skip:
- hadolint
- golangci-lint-repo-mod
- go-mod-tidy
- go-build-repo-mod
- go-test-repo-mod

${TITLE}

${DESCRIPTION}

Status GitHub Issues GitHub Pull Requests

pre-commit.ci status Maintainability Test Coverage

License FOSSA Status CII Best Practices

Docker Image Size (latest semver) Docker Image Version (latest semver) Docker Pulls


📝 Table of Contents

🧐 About

Write about 1-2 paragraphs describing the purpose of your project.

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

What things you need to install the software and how to install them.

Give examples

Installing

A step by step series of examples that tell you how to get a development env running.

Say what the step will be

Give the example

And repeat

until finished

End with an example of getting some data out of the system or using it for a little demo.

🔧 Running the tests

Explain how to run the automated tests for this system.

Break down into end to end tests

Explain what these tests test and why

Give an example

And coding style tests

Explain what these tests test and why

Give an example

🎈 Usage

Add notes about how to use the system.

🚀 Deployment

Add additional notes about how to deploy this on a live system.

🔧 Built Using

🧑‍💻 Authors

🎉 Acknowledgements

  • Hat tip to anyone whose code was used
  • Inspiration
  • References

Contributor Covenant Code of Conduct

Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, 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.

Our Standards

Examples of behavior that contributes to creating a positive environment include:

  • Using welcoming and inclusive language
  • Being respectful of differing viewpoints and experiences
  • Gracefully accepting constructive criticism
  • Focusing on what is best for the community
  • Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

  • The use of sexualized language or imagery and unwelcome sexual attention or advances
  • Trolling, insulting/derogatory comments, and personal or political attacks
  • Public or private harassment
  • Publishing others' private information, such as a physical or electronic address, without explicit permission
  • Other conduct which could reasonably be considered inappropriate in a professional setting

Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers 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, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at github@artero.dev. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
  2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
  3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is SemVer.
  4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.

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. 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 project community.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 2.0, available at 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.

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

name about title labels assignees
Bug report
Create a report to help us improve

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Device information:

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

name about title labels assignees
Feature request
Suggest an idea for this project

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

MIT License
Copyright (c) ${YEAR} ${NAME}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Changes

Non-breaking

  • feat - adds functionality for the user
  • fix - fixes an issue for the user
  • docs - changes to the documentation
  • style - formatting, missing semi colons, etc
  • refactor - refactoring production code, eg. renaming a variable
  • test - adding missing tests, refactoring tests
  • chore - configuration of lint, IDE, issue template, etc

Breaking

  • feat! - adds functionality for the user, but changes existing functionality
  • fix! - fixes an issue for the user, but changes existing functionality
  • chore! - updating yarn/lerna scripts, etc

Changelog

{{changelog}}

Security Guidelines

How security is managed on this project

Contributors take security seriously and wants to ensure that we maintain a secure environment for our customers and that we also provide secure solutions for the open source community. To help us achieve these goals, please note the following before using this software:

  • Review the software license to understand the contributor's obligations in terms of warranties and suitability for purpose
  • For any questions or concerns about security, you can create an issue or report a vulnerability
  • We request that you work with our security team and opt for responsible disclosure using the guidelines below
  • All security related issues and pull requests you make should be tagged with "security" for easy identification
  • Please monitor this repository and update your environment in a timely manner as we release patches and updates

Responsibly Disclosing Security Bugs

If you find a security bug in this repository, please work with contributors following responsible disclosure principles and these guidelines:

  • Do not submit a normal issue or pull request in our public repository, instead report it directly.
  • We will review your submission and may follow up for additional details
  • If you have a patch, we will review it and approve it privately; once approved for release you can submit it as a pull request publicly in the repository (we give credit where credit is due)
  • We will keep you informed during our investigation, feel free to check in for a status update
  • We will release the fix and publicly disclose the issue as soon as possible, but want to ensure we due properly due diligence before releasing
  • Please do not publicly blog or post about the security issue until after we have updated the public repo so that other downstream users have an opportunity to patch

Contact / Misc

If you have any questions, please reach out directly by creating an issue.

#!/usr/bin/env bash
set -Eeuo pipefail
TOOLS=(git sed envsubst sponge)
for TOOL in "${TOOLS[@]}"; do
if ! _=$(type -p "${TOOL}" &> /dev/null); then
echo "${TOOL} not available"
exit 1
fi
done
if [ $# -ne 1 ]; then
echo "usage: ${0} <project-dir>"
exit 1
fi
DIR=$(dirname "$1/.")
ISSUE_TEMPLATE_DIR="${DIR}/.github/ISSUE_TEMPLATE"
PULL_REQUEST_TEMPLATE_DIR="${DIR}/.github/PULL_REQUEST_TEMPLATE"
test -d "${DIR}" || mkdir -p "${DIR}"
test -d "${DIR}/.git" || git -C "${DIR}" init -q
GIST_BASE_URL=https://gist.github.com/wwmoraes/75dc66767a9f487c8235c5423027f69c/raw
FILES_ONCE=(
"README.md"
".pre-commit-config.yaml"
".lefthook.yaml"
)
FILES_ALWAYS=(
"CODE_OF_CONDUCT.md"
"CONTRIBUTING.md"
"SECURITY.md"
"LICENSE"
".editorconfig"
)
FILES_REMOVE=(
".pre-commit-config.yaml"
)
ISSUE_TEMPLATES=(
"ISSUE_TEMPLATE_BUG.md"
"ISSUE_TEMPLATE_FEATURE_REQUEST.md"
)
PULL_REQUEST_TEMPLATES=(
"PULL_REQUEST_TEMPLATE_SEMANTIC.md"
)
GIT_USERNAME=$(git -C "${DIR}" config user.name 2>/dev/null || echo unknown)
#GIT_USEREMAIL=$(git -C "${DIR}" config user.email 2>/dev/null || echo unknown)
GIT_REMOTE=$(git -C "${DIR}" remote 2>/dev/null || echo origin)
GIT_REMOTE_URL=$(git -C "${DIR}" remote get-url "${GIT_REMOTE}" 2>/dev/null || echo unknown-remote)
: "${YEAR:=$(date -u +"%Y")}"
: "${NAME:=${GIT_USERNAME}}"
: "${HOST:=$(echo "${GIT_REMOTE_URL}" | sed -E "s#[a-z]+@([^:]+):([^/]+)/(.*)(\.git)|https?://([^/]+)/([^/]+)/(.*)(\.git)#\1\5#")}"
: "${OWNER:=$(echo "${GIT_REMOTE_URL}" | sed -E "s#[a-z]+@([^:]+):([^/]+)/(.*)(\.git)|https?://([^/]+)/([^/]+)/(.*)(\.git)#\2\6#")}"
: "${TITLE:=$(echo "${GIT_REMOTE_URL}" | sed -E "s#[a-z]+@([^:]+):([^/]+)/(.*)(\.git)|https?://([^/]+)/([^/]+)/(.*)(\.git)#\3\7#")}"
: "${REPOSITORY:=${OWNER}/${TITLE}}"
: "${DESCRIPTION:=$(cat "${DIR}/.git/description")}"
: "${CII_PROJECT_ID:=0}"
CC_BADGE_TOKEN=$(curl -fsSL "https://api.codeclimate.com/v1/repos?github_slug=${REPOSITORY}" | jq -r ".data[0].attributes.badge_token" || echo "")
export YEAR NAME HOST OWNER TITLE REPOSITORY DESCRIPTION CII_PROJECT_ID CC_BADGE_TOKEN
# shellcheck disable=SC2016
SHELL_FORMAT='${YEAR} ${NAME} ${HOST} ${OWNER} ${TITLE} ${REPOSITORY} ${DESCRIPTION} ${CII_PROJECT_ID} ${CC_BADGE_TOKEN}'
fetch() {
printf "[\e[1;35m%s\e[0m] fetching into \e[1;36m%s\e[0m\n" "${1}" "${2}"
curl -fsSL "${GIST_BASE_URL}/${1}" | envsubst "${SHELL_FORMAT}" | sponge "${2}"
}
fetch_once() {
test -f "${2}" && {
printf "[\e[1;35m%s\e[0m] skipping - file already exists at \e[1;36m%s\e[0m\n" "${1}" "${2}"
return
}
fetch "${1}" "${2}"
}
remove() {
printf "[\e[1;31m%s\e[0m] removing\e[0m\n" "${1}"
rm "${1}"
}
for FILE in "${FILES_ONCE[@]}"; do
fetch_once "${FILE}" "${DIR}/${FILE}"
done
for FILE in "${FILES_ALWAYS[@]}"; do
fetch "${FILE}" "${DIR}/${FILE}"
done
for FILE in "${FILES_REMOVE[@]}"; do
remove "${FILE}"
done
mkdir -p "${ISSUE_TEMPLATE_DIR}"
for FILE in "${ISSUE_TEMPLATES[@]}"; do
fetch "${FILE}" "${ISSUE_TEMPLATE_DIR}/${FILE##ISSUE_TEMPLATE_}"
done
mkdir -p "${PULL_REQUEST_TEMPLATE_DIR}"
for FILE in "${PULL_REQUEST_TEMPLATES[@]}"; do
fetch "${FILE}" "${PULL_REQUEST_TEMPLATE_DIR}/${FILE##PULL_REQUEST_TEMPLATE_}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment