From f9d2bb11314f7983d9c153ddde2ce18574e5a29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 2 Jul 2020 10:55:55 +0200 Subject: [PATCH 1/2] Enhancement: Add integrate workflow --- .editorconfig | 14 ++++ .github/CONTRIBUTING.md | 47 +++++++++++++ .github/dependabot.yml | 15 ++++ .github/settings.yml | 8 +++ .github/workflows/integrate.yaml | 115 +++++++++++++++++++++++++++++++ .yamllint.yaml | 64 +++++++++++++++++ Makefile | 10 +++ README.md | 14 ++++ 8 files changed, 287 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/integrate.yaml create mode 100644 .yamllint.yaml create mode 100644 Makefile diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7122a7a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{yaml,yml}] +indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..89d8088 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,47 @@ +# CONTRIBUTING + +We are using [GitHub Actions](https://github.com/features/actions) as a continuous integration system. + +For details, take a look at the following workflow configuration files: + +- [`workflows/integrate.yaml`](workflows/integrate.yaml) + +## Coding Standards + +We are using [`yamllint`](https://github.com/adrienverge/yamllint) to enforce coding standards in YAML files. + +If you do not have `yamllint` installed yet, run + +```sh +$ brew install yamllint +``` + +to install `yamllint`. + +Run + +```sh +$ make coding-standards +``` + +to detect coding standard violations. + +## Extra lazy? + +Run + +```sh +$ make +``` + +to detect coding standard violations! + +## Help + +:bulb: Run + +```sh +$ make help +``` + +to display a list of available targets with corresponding descriptions. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9475dfc --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 + +updates: + - commit-message: + include: "scope" + prefix: "github-actions" + directory: "/" + labels: + - "dependency" + open-pull-requests-limit: 10 + package-ecosystem: "github-actions" + schedule: + interval: "daily" diff --git a/.github/settings.yml b/.github/settings.yml index 496b216..9b33e60 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -12,6 +12,10 @@ branches: dismiss_stale_reviews: true require_code_owner_reviews: true required_approving_review_count: 1 + required_status_checks: + contexts: + - "Coding Standards" + strict: false restrictions: # https://docs.github.com/en/rest/reference/repos#list-branches--parameters @@ -40,6 +44,10 @@ labels: color: "0e8a16" description: "" + - name: "merge" + color: "6f42c1" + description: "" + - name: "question" color: "cc317c" description: "" diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml new file mode 100644 index 0000000..1df0a4c --- /dev/null +++ b/.github/workflows/integrate.yaml @@ -0,0 +1,115 @@ +# https://docs.github.com/en/actions + +name: "Integrate" + +on: # yamllint disable-line rule:truthy + pull_request: null + push: + branches: + - "main" + +jobs: + coding-standards: + name: "Coding Standards" + + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2.3.1" + + - name: "Lint YAML files" + uses: "ibiqlik/action-yamllint@v1" + with: + config_file: ".yamllint.yaml" + file_or_dir: "." + strict: true + + merge: + name: "Merge" + + runs-on: "ubuntu-latest" + + needs: + - "coding-standards" + + if: > + github.event_name == 'pull_request' && + github.event.pull_request.draft == false && ( + github.event.action == 'opened' || + github.event.action == 'reopened' || + github.event.action == 'synchronize' + ) && ( + (github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'github-actions(deps)')) || + (github.actor == 'localheinz' && contains(github.event.pull_request.labels.*.name, 'merge')) + ) + + steps: + - name: "Request review from @ergebnis-bot" + uses: "actions/github-script@v2" + with: + github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" + script: | + const pullRequest = context.payload.pull_request + const repository = context.repo + + const reviewers = [ + "ergebnis-bot", + ] + + await github.pulls.createReviewRequest({ + owner: repository.owner, + pull_number: pullRequest.number, + repo: repository.repo, + reviewers: reviewers, + }) + + - name: "Assign @ergebnis-bot" + uses: "actions/github-script@v2" + with: + github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" + script: | + const pullRequest = context.payload.pull_request + const repository = context.repo + + const reviewers = [ + "ergebnis-bot", + ] + + await github.issues.addAssignees({ + assignees: reviewers, + issue_number: pullRequest.number, + owner: repository.owner, + repo: repository.repo, + }) + + - name: "Approve pull request" + uses: "actions/github-script@v2" + if: "github.actor != 'ergebnis-bot'" + with: + github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" + script: | + const pullRequest = context.payload.pull_request + const repository = context.repo + + await github.pulls.createReview({ + event: "APPROVE", + owner: repository.owner, + pull_number: pullRequest.number, + repo: repository.repo, + }) + + - name: "Merge pull request" + uses: "actions/github-script@v2" + with: + github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" + script: | + const pullRequest = context.payload.pull_request + const repository = context.repo + + await github.pulls.merge({ + merge_method: "merge", + owner: repository.owner, + pull_number: pullRequest.number, + repo: repository.repo, + }) diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..2c9e3b6 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,64 @@ +extends: "default" + +ignore: | + .notes/ + +rules: + braces: + max-spaces-inside-empty: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: 0 + min-spaces-inside: 1 + brackets: + max-spaces-inside-empty: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 0 + min-spaces-inside: 0 + colons: + max-spaces-after: 1 + max-spaces-before: 0 + commas: + max-spaces-after: 1 + max-spaces-before: 0 + min-spaces-after: 1 + comments: + ignore-shebangs: true + min-spaces-from-content: 1 + require-starting-space: true + comments-indentation: "enable" + document-end: + present: false + document-start: + present: false + indentation: + check-multi-line-strings: false + indent-sequences: true + spaces: 2 + empty-lines: + max-end: 0 + max-start: 0 + max: 1 + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true + hyphens: + max-spaces-after: 2 + key-duplicates: "enable" + key-ordering: "disable" + line-length: "disable" + new-line-at-end-of-file: "enable" + new-lines: + type: "unix" + octal-values: + forbid-implicit-octal: true + quoted-strings: + quote-type: "double" + trailing-spaces: "enable" + truthy: + allowed-values: + - "false" + - "true" + +yaml-files: + - "*.yaml" + - "*.yml" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..31881a0 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +.PHONY: it +it: coding-standards ## Runs the coding-standards target + +.PHONY: coding-standards +coding-standards: ## Lints YAML files with yamllint + yamllint -c .yamllint.yaml --strict . + +.PHONY: help +help: ## Displays this list of targets with descriptions + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/README.md b/README.md index f83e491..4342d71 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,19 @@ # .github +[![Integrate](https://github.com/ergebnis/.github/workflows/Integrate/badge.svg?branch=main)](https://github.com/ergebnis/.github/actions) + Provides community health files for the [@ergebnis](https://github.com/ergebnis) organization. :bulb: Also see [GitHub Docs: Creating a default community health file](https://docs.github.com/en/github/building-a-strong-community/creating-a-default-community-health-file). + +## Contributing + +Please have a look at [`CONTRIBUTING.md`](.github/CONTRIBUTING.md). + +## Code of Conduct + +Please have a look at [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md). + +## Curious what I am building? + +:mailbox_with_mail: [Subscribe to my list](https://localheinz.com/projects/), and I will occasionally send you an email to let you know what I am working on. From c60474c8542d8cb99e916c9ca888767e20513b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 2 Jul 2020 11:04:33 +0200 Subject: [PATCH 2/2] Fix: Quote strings --- FUNDING.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FUNDING.yml b/FUNDING.yml index a484b8f..0f40d05 100644 --- a/FUNDING.yml +++ b/FUNDING.yml @@ -1,6 +1,6 @@ custom: - - https://cottonbureau.com/people/andreas-moller - - https://paypal.me/localheinz - - https://www.amazon.de/hz/wishlist/ls/2NCHMSJ4BC1OW - - https://www.buymeacoffee.com/localheinz -github: localheinz + - "https://cottonbureau.com/people/andreas-moller" + - "https://paypal.me/localheinz" + - "https://www.amazon.de/hz/wishlist/ls/2NCHMSJ4BC1OW" + - "https://www.buymeacoffee.com/localheinz" +github: "localheinz"