Skip to content

Commit

Permalink
Merge pull request #35 from libsv/chore/releaser_mergify
Browse files Browse the repository at this point in the history
updating pipeline to auto release on tag. adding mergify config
  • Loading branch information
theflyingcodr authored Aug 18, 2021
2 parents 64e734d + e9a3861 commit 34deb08
Show file tree
Hide file tree
Showing 3 changed files with 295 additions and 30 deletions.
247 changes: 247 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
pull_request_rules:

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

- name: Automatic Merge for Dependabot Minor Version Pull Requests
conditions:
- -draft
- author~=^dependabot(|-preview)\[bot\]$
- check-success='build (1.14.x, ubuntu-latest)'
- check-success='build (1.15.x, ubuntu-latest)'
- check-success='build (1.16.x, ubuntu-latest)'
- check-success='build (1.14.x, macos-latest)'
- check-success='build (1.15.x, macos-latest)'
- check-success='build (1.16.x, macos-latest)'
- check-success='lint (1.15.x, ubuntu-latest)'
- check-success='lint (1.16.x, ubuntu-latest)'
- check-success='lint (1.15.x, macos-latest)'
- check-success='lint (1.16.x, macos-latest)'
- check-success='Analyze (go)'
- title~=^Bump [^\s]+ from ([\d]+)\..+ to \1\.
actions:
review:
type: APPROVE
message: Automatically approving dependabot pull request
merge:
method: merge
- name: Alert on major version detection
conditions:
- author~=^dependabot(|-preview)\[bot\]$
- check-success='build (1.14.x, ubuntu-latest)'
- check-success='build (1.15.x, ubuntu-latest)'
- check-success='build (1.16.x, ubuntu-latest)'
- check-success='build (1.14.x, macos-latest)'
- check-success='build (1.15.x, macos-latest)'
- check-success='build (1.16.x, macos-latest)'
- check-success='lint (1.15.x, ubuntu-latest)'
- check-success='lint (1.16.x, ubuntu-latest)'
- check-success='lint (1.15.x, macos-latest)'
- check-success='lint (1.16.x, macos-latest)'
- check-success='Analyze (go)'
- -title~=^Bump [^\s]+ from ([\d]+)\..+ to \1\.
actions:
comment:
message: "⚠️ @theflyingcodr @jadwahab: 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='build (1.14.x, ubuntu-latest)'
- check-success='build (1.15.x, ubuntu-latest)'
- check-success='build (1.16.x, ubuntu-latest)'
- check-success='build (1.14.x, macos-latest)'
- check-success='build (1.15.x, macos-latest)'
- check-success='build (1.16.x, macos-latest)'
- check-success='lint (1.15.x, ubuntu-latest)'
- check-success='lint (1.16.x, ubuntu-latest)'
- check-success='lint (1.15.x, macos-latest)'
- check-success='lint (1.16.x, macos-latest)'
- check-success='Analyze (go)'
- label!=work-in-progress
- -draft
actions:
merge:
method: merge

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

- name: Auto-Assign Author
conditions:
- "#assignee=0"
actions:
assign:
users: [ "@{{author}}" ]

# ===============================================================================
# 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."
label:
add:
- conflict
- name: Alert on tests failure for automerge
conditions:
- label=automerge
- status-failure=commit
actions:
comment:
message: "🆘 @{{author}}: unable to merge due to CI failure."

- name: remove conflict label if not needed
conditions:
- -conflict
actions:
label:
remove:
- conflict

# ===============================================================================
# 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
# - enhancement: an improvement to an existing feature
# - 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: Enhancement label
conditions:
- "head~=(?i)^enhancement?" # if the PR branch starts with enhancement/
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"]

# ===============================================================================
# STALE BRANCHES
# ===============================================================================

- name: Close stale pull request
conditions:
- base=master
- -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.
# ===============================================================================
# BRANCHES
# ===============================================================================

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

#- name: automatic update for PR marked as “Ready-to-Go“
# conditions:
# - -conflict # skip PRs with conflicts
# - -draft # filter-out GH draft PRs
# - label="Ready-to-Go"
# actions:
# update:

# ===============================================================================
# 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 %}
75 changes: 45 additions & 30 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,58 @@
name: run-go-tests

env:
GO111MODULE: on
name: Go

on:
pull_request:
branches:
- "*"
push:
branches:
- "*"
schedule:
- cron: '1 4 * * *'
tags:
- '*'
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
golangci:
strategy:
matrix:
go-version: [ 1.15.x,1.16.x, ]
os: [ ubuntu-latest ]
go-version: [1.15.x,1.16.x]
os: [macos-latest, ubuntu-latest]
name: lint
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: latest
build:
strategy:
matrix:
go-version: [ 1.14.x, 1.15.x, 1.16.x ]
os: [ macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
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: make test-ci

- name: Tests
run: make test-unit
- name: Update code coverage
run: bash <(curl -s https://codecov.io/bash)
run: bash <(curl -s https://codecov.io/bash)
- name: Build
run: go build -v ./...
release:
needs: [golangci,build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: release
uses: goreleaser/goreleaser-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ test: ## Runs vet, lint and ALL tests
@echo "running tests..."
@go test ./... -v

test-unit:
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic

test-short: ## Runs vet, lint and tests (excludes integration tests)
@$(MAKE) lint
@echo "running tests (short)..."
Expand Down

0 comments on commit 34deb08

Please sign in to comment.