Skip to content

Commit

Permalink
chore: standardise CI
Browse files Browse the repository at this point in the history
  • Loading branch information
WheresAlice committed Dec 5, 2021
1 parent ae238ee commit 0a2fd5e
Show file tree
Hide file tree
Showing 10 changed files with 818 additions and 21 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Expand Up @@ -6,9 +6,17 @@ updates:
directory: /
schedule:
interval: weekly
day: "friday"
labels:
- "chore"
open-pull-requests-limit: 10

# Manage Go package versions.
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
day: "friday"
labels:
- "chore"
open-pull-requests-limit: 10
54 changes: 54 additions & 0 deletions .github/labels.yml
@@ -0,0 +1,54 @@
- color: 0075ca
description: "Improvements or additions to documentation"
name: "documentation"
- color: b23128
description: "Highest rated bug or issue, affects all"
name: "bug-P1"
- color: de3d32
description: "Medium rated bug, affects a few"
name: "bug-P2"
- color: f44336
description: "Lowest rated bug, affects nearly none or low-impact"
name: "bug-P3"
- color: 0e8a16
description: "Any new significant addition"
name: "feature"
- color: b60205
description: "Urgent or important fix/patch"
name: "hot-fix"
- color: cccccc
description: "Any idea, suggestion"
name: "idea"
- color: d4c5f9
description: "Experimental - can break!"
name: "prototype"
- color: cc317c
description: "Any question or concern"
name: "question"
- color: c2e0c6
description: "Unit tests, mocking, integration testing"
name: "test"
- color: fbca04
description: "Anything GUI related"
name: "ui-ux"
- color: 006b75
description: "Simple updates or version bumps"
name: "chore"
- color: 006b75
description: "Dependency updates"
name: "dependencies"
- color: 006b75
description: "General updates"
name: "update"
- color: FFA500
description: "Any significant refactoring"
name: "refactor"
- color: FEF2C0
description: "Used for automatic merging"
name: "automerge"
- color: FBCA04
description: "Used for denoting a WIP, stops auto-merge"
name: "work-in-progress"
- color: c2e0c6
description: "Old, unused, stale"
name: "stale"
210 changes: 207 additions & 3 deletions .github/mergify.yml
@@ -1,8 +1,212 @@
pull_request_rules:
- name: automatic merge for Dependabot pull requests

# ===============================================================================
# DEPENDABOT
# ===============================================================================

- name: Automatic Merge for Dependabot Minor Version Pull Requests
conditions:
- -draft
- author~=^dependabot(|-preview)\[bot\]$
- check-success=Test
- check-success='test (1.16.x, ubuntu-latest)'
- check-success='test (1.17.x, ubuntu-latest)'
- title~=bump [^\s]+ from ([\d]+)\..+ to \1\.
actions:
review:
type: APPROVE
message: Automatically approving dependabot pull request
merge:
method: merge
method: rebase
- name: Alert on major version detection
conditions:
- author~=^dependabot(|-preview)\[bot\]$
- check-success='test (1.16.x, ubuntu-latest)'
- check-success='test (1.17.x, ubuntu-latest)'
- -title~=bump [^\s]+ from ([\d]+)\..+ to \1\.
actions:
comment:
message: "⚠️ @wheresalice: this is a major version bump and requires your attention"

# ===============================================================================
# AUTOMATIC MERGE (APPROVALS)
# ===============================================================================

- name: Automatic Merge ⬇️ on Approval ✔
conditions:
- "#approved-reviews-by>=1"
- check-success='test (1.16.x, ubuntu-latest)'
- check-success='test (1.17.x, ubuntu-latest)'
- label!=work-in-progress
- -draft
actions:
merge:
method: rebase

# ===============================================================================
# AUTHOR
# ===============================================================================

- name: Auto-Assign Author
conditions:
- "#assignee=0"
actions:
assign:
users: ["wheresalice"]

# ===============================================================================
# ALERTS
# ===============================================================================

- name: Notify on merge
conditions:
- merged
- label=automerge
actions:
comment:
message: "✅ @{{author}}: **{{title}}** has been merged successfully."
- name: Alert on merge conflict
conditions:
- conflict
- label=automerge
actions:
comment:
message: "🆘 @{{author}}: `{{head}}` has conflicts with `{{base}}` that must be resolved."
- name: Alert on tests failure for automerge
conditions:
- label=automerge
- status-failure=commit
actions:
comment:
message: "🆘 @{{author}}: unable to merge due to CI failure."

# ===============================================================================
# LABELS
# ===============================================================================
# Automatically add labels when PRs match certain patterns
#
# NOTE:
# - single quotes for regex to avoid accidental escapes
# - Mergify leverages Python regular expressions to match rules.
#
# Semantic commit messages
# - chore: updating grunt tasks etc.; no production code change
# - docs: changes to the documentation
# - feat: feature or story
# - feat: new feature for the user, not a new feature for build script
# - fix: bug fix for the user, not a fix to a build script
# - idea: general idea or suggestion
# - test: test related changes
# ===============================================================================

- name: Hotfix label
conditions:
- "head~=(?i)^hotfix" # if the PR branch starts with hotfix/
actions:
label:
add: ["hot-fix"]
- name: Bug / Fix label
conditions:
- "head~=(?i)^(bug)?fix" # if the PR branch starts with (bug)?fix/
actions:
label:
add: ["bug-P3"]
- name: Documentation label
conditions:
- "head~=(?i)^docs" # if the PR branch starts with docs/
actions:
label:
add: ["documentation"]
- name: Feature label
conditions:
- "head~=(?i)^feat(ure)?" # if the PR branch starts with feat(ure)?/
actions:
label:
add: ["feature"]
- name: Chore label
conditions:
- "head~=(?i)^chore" # if the PR branch starts with chore/
actions:
label:
add: ["update"]
- name: Question label
conditions:
- "head~=(?i)^question" # if the PR branch starts with question/
actions:
label:
add: ["question"]
- name: Test label
conditions:
- "head~=(?i)^test" # if the PR branch starts with test/
actions:
label:
add: ["test"]
- name: Idea label
conditions:
- "head~=(?i)^idea" # if the PR branch starts with idea/
actions:
label:
add: ["idea"]

# ===============================================================================
# CONTRIBUTORS
# ===============================================================================

- name: Welcome New Contributors
conditions:
- and:
- author!=dependabot[bot]
- author!=mergify[bot]
- author!=allcontributors[bot]
- author!=wheresalice
actions:
comment:
message: |
Welcome to our open-source project! 💘
# ===============================================================================
# STALE BRANCHES
# ===============================================================================

- name: Close stale pull request
conditions:
- base=main
- -closed
- updated-at<21 days ago
actions:
close:
message: |
This pull request looks stale. Feel free to reopen it if you think it's a mistake.
label:
add: ["stale"]

# ===============================================================================
# BRANCHES
# ===============================================================================

- name: Delete head branch after merge
conditions:
- merged
actions:
delete_head_branch:

# ===============================================================================
# CONVENTION
# ===============================================================================
# https://www.conventionalcommits.org/en/v1.0.0/
# Premium feature only

#- name: Conventional Commit
# conditions:
# - "title~=^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\\(.+\\))?:"
# actions:
# post_check:
# title: |
# {% if check_succeed %}
# Title follows Conventional Commit
# {% else %}
# Title does not follow Conventional Commit
# {% endif %}
# summary: |
# {% if not check_succeed %}
# Your pull request title must follow [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/).
# {% endif %}
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,34 @@
# From: https://goreleaser.com/ci/actions/#usage
name: release

env:
GO111MODULE: on

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2.1.4
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.8.0
with:
distribution: goreleaser
version: latest
args: release --rm-dist --debug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/run-tests.yml
@@ -0,0 +1,55 @@
# See more at: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
name: run-go-tests

env:
GO111MODULE: on

on:
pull_request:
branches:
- "*"
push:
branches:
- "*"
# schedule:
# - cron: '1 4 * * *'

jobs:
asknancy:
name: Ask Nancy (check dependencies)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2.4.0
- name: Write go list
run: go list -json -m all > go.list
- name: Ask Nancy
uses: sonatype-nexus-community/nancy-github-action@v1.0.2
# continue-on-error: true
test:
needs: [asknancy]
strategy:
matrix:
go-version: [1.16.x, 1.17.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go ${{ matrix.go-version }}
uses: actions/setup-go@v2.1.4
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2.4.0
- name: Cache code
uses: actions/cache@v2.1.7
with:
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
'%LocalAppData%\go-build' # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run linter and tests
run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic

0 comments on commit 0a2fd5e

Please sign in to comment.