Skip to content

Commit 34deb08

Browse files
Merge pull request #35 from libsv/chore/releaser_mergify
updating pipeline to auto release on tag. adding mergify config
2 parents 64e734d + e9a3861 commit 34deb08

File tree

3 files changed

+295
-30
lines changed

3 files changed

+295
-30
lines changed

.github/mergify.yml

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
pull_request_rules:
2+
3+
# ===============================================================================
4+
# DEPENDABOT
5+
# ===============================================================================
6+
7+
- name: Automatic Merge for Dependabot Minor Version Pull Requests
8+
conditions:
9+
- -draft
10+
- author~=^dependabot(|-preview)\[bot\]$
11+
- check-success='build (1.14.x, ubuntu-latest)'
12+
- check-success='build (1.15.x, ubuntu-latest)'
13+
- check-success='build (1.16.x, ubuntu-latest)'
14+
- check-success='build (1.14.x, macos-latest)'
15+
- check-success='build (1.15.x, macos-latest)'
16+
- check-success='build (1.16.x, macos-latest)'
17+
- check-success='lint (1.15.x, ubuntu-latest)'
18+
- check-success='lint (1.16.x, ubuntu-latest)'
19+
- check-success='lint (1.15.x, macos-latest)'
20+
- check-success='lint (1.16.x, macos-latest)'
21+
- check-success='Analyze (go)'
22+
- title~=^Bump [^\s]+ from ([\d]+)\..+ to \1\.
23+
actions:
24+
review:
25+
type: APPROVE
26+
message: Automatically approving dependabot pull request
27+
merge:
28+
method: merge
29+
- name: Alert on major version detection
30+
conditions:
31+
- author~=^dependabot(|-preview)\[bot\]$
32+
- check-success='build (1.14.x, ubuntu-latest)'
33+
- check-success='build (1.15.x, ubuntu-latest)'
34+
- check-success='build (1.16.x, ubuntu-latest)'
35+
- check-success='build (1.14.x, macos-latest)'
36+
- check-success='build (1.15.x, macos-latest)'
37+
- check-success='build (1.16.x, macos-latest)'
38+
- check-success='lint (1.15.x, ubuntu-latest)'
39+
- check-success='lint (1.16.x, ubuntu-latest)'
40+
- check-success='lint (1.15.x, macos-latest)'
41+
- check-success='lint (1.16.x, macos-latest)'
42+
- check-success='Analyze (go)'
43+
- -title~=^Bump [^\s]+ from ([\d]+)\..+ to \1\.
44+
actions:
45+
comment:
46+
message: "⚠️ @theflyingcodr @jadwahab: this is a major version bump and requires your attention"
47+
48+
49+
# ===============================================================================
50+
# AUTOMATIC MERGE (APPROVALS)
51+
# ===============================================================================
52+
53+
- name: Automatic Merge ⬇️ on Approval ✔
54+
conditions:
55+
- "#approved-reviews-by>=1"
56+
- check-success='build (1.14.x, ubuntu-latest)'
57+
- check-success='build (1.15.x, ubuntu-latest)'
58+
- check-success='build (1.16.x, ubuntu-latest)'
59+
- check-success='build (1.14.x, macos-latest)'
60+
- check-success='build (1.15.x, macos-latest)'
61+
- check-success='build (1.16.x, macos-latest)'
62+
- check-success='lint (1.15.x, ubuntu-latest)'
63+
- check-success='lint (1.16.x, ubuntu-latest)'
64+
- check-success='lint (1.15.x, macos-latest)'
65+
- check-success='lint (1.16.x, macos-latest)'
66+
- check-success='Analyze (go)'
67+
- label!=work-in-progress
68+
- -draft
69+
actions:
70+
merge:
71+
method: merge
72+
73+
# ===============================================================================
74+
# AUTHOR
75+
# ===============================================================================
76+
77+
- name: Auto-Assign Author
78+
conditions:
79+
- "#assignee=0"
80+
actions:
81+
assign:
82+
users: [ "@{{author}}" ]
83+
84+
# ===============================================================================
85+
# ALERTS
86+
# ===============================================================================
87+
88+
- name: Notify on merge
89+
conditions:
90+
- merged
91+
- label=automerge
92+
actions:
93+
comment:
94+
message: "✅ @{{author}}: **{{title}}** has been merged successfully."
95+
- name: Alert on merge conflict
96+
conditions:
97+
- conflict
98+
- label=automerge
99+
actions:
100+
comment:
101+
message: "🆘 @{{author}}: `{{head}}` has conflicts with `{{base}}` that must be resolved."
102+
label:
103+
add:
104+
- conflict
105+
- name: Alert on tests failure for automerge
106+
conditions:
107+
- label=automerge
108+
- status-failure=commit
109+
actions:
110+
comment:
111+
message: "🆘 @{{author}}: unable to merge due to CI failure."
112+
113+
- name: remove conflict label if not needed
114+
conditions:
115+
- -conflict
116+
actions:
117+
label:
118+
remove:
119+
- conflict
120+
121+
# ===============================================================================
122+
# LABELS
123+
# ===============================================================================
124+
# Automatically add labels when PRs match certain patterns
125+
#
126+
# NOTE:
127+
# - single quotes for regex to avoid accidental escapes
128+
# - Mergify leverages Python regular expressions to match rules.
129+
#
130+
# Semantic commit messages
131+
# - chore: updating grunt tasks etc.; no production code change
132+
# - docs: changes to the documentation
133+
# - feat: feature or story
134+
# - enhancement: an improvement to an existing feature
135+
# - feat: new feature for the user, not a new feature for build script
136+
# - fix: bug fix for the user, not a fix to a build script
137+
# - idea: general idea or suggestion
138+
# - test: test related changes
139+
# ===============================================================================
140+
141+
- name: Hotfix label
142+
conditions:
143+
- "head~=(?i)^hotfix" # if the PR branch starts with hotfix/
144+
actions:
145+
label:
146+
add: ["hot-fix"]
147+
- name: Bug / Fix label
148+
conditions:
149+
- "head~=(?i)^(bug)?fix" # if the PR branch starts with (bug)?fix/
150+
actions:
151+
label:
152+
add: [ "bug-P3" ]
153+
- name: Documentation label
154+
conditions:
155+
- "head~=(?i)^docs" # if the PR branch starts with docs/
156+
actions:
157+
label:
158+
add: [ "documentation" ]
159+
- name: Feature label
160+
conditions:
161+
- "head~=(?i)^feat(ure)?" # if the PR branch starts with feat(ure)?/
162+
actions:
163+
label:
164+
add: ["feature"]
165+
- name: Enhancement label
166+
conditions:
167+
- "head~=(?i)^enhancement?" # if the PR branch starts with enhancement/
168+
actions:
169+
label:
170+
add: ["feature"]
171+
- name: Chore label
172+
conditions:
173+
- "head~=(?i)^chore" # if the PR branch starts with chore/
174+
actions:
175+
label:
176+
add: ["update"]
177+
- name: Question label
178+
conditions:
179+
- "head~=(?i)^question" # if the PR branch starts with question/
180+
actions:
181+
label:
182+
add: ["question"]
183+
- name: Test label
184+
conditions:
185+
- "head~=(?i)^test" # if the PR branch starts with test/
186+
actions:
187+
label:
188+
add: ["test"]
189+
- name: Idea label
190+
conditions:
191+
- "head~=(?i)^idea" # if the PR branch starts with idea/
192+
actions:
193+
label:
194+
add: ["idea"]
195+
196+
# ===============================================================================
197+
# STALE BRANCHES
198+
# ===============================================================================
199+
200+
- name: Close stale pull request
201+
conditions:
202+
- base=master
203+
- -closed
204+
- updated-at<21 days ago
205+
actions:
206+
close:
207+
message: |
208+
This pull request looks stale. Feel free to reopen it if you think it's a mistake.
209+
# ===============================================================================
210+
# BRANCHES
211+
# ===============================================================================
212+
213+
- name: Delete head branch after merge
214+
conditions:
215+
- merged
216+
actions:
217+
delete_head_branch:
218+
219+
#- name: automatic update for PR marked as “Ready-to-Go“
220+
# conditions:
221+
# - -conflict # skip PRs with conflicts
222+
# - -draft # filter-out GH draft PRs
223+
# - label="Ready-to-Go"
224+
# actions:
225+
# update:
226+
227+
# ===============================================================================
228+
# CONVENTION
229+
# ===============================================================================
230+
# https://www.conventionalcommits.org/en/v1.0.0/
231+
# Premium feature only
232+
233+
#- name: Conventional Commit
234+
# conditions:
235+
# - "title~=^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\\(.+\\))?:"
236+
# actions:
237+
# post_check:
238+
# title: |
239+
# {% if check_succeed %}
240+
# Title follows Conventional Commit
241+
# {% else %}
242+
# Title does not follow Conventional Commit
243+
# {% endif %}
244+
# summary: |
245+
# {% if not check_succeed %}
246+
# Your pull request title must follow [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/).
247+
# {% endif %}

.github/workflows/run-tests.yml

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,58 @@
1-
name: run-go-tests
2-
3-
env:
4-
GO111MODULE: on
1+
name: Go
52

63
on:
7-
pull_request:
8-
branches:
9-
- "*"
104
push:
11-
branches:
12-
- "*"
13-
schedule:
14-
- cron: '1 4 * * *'
5+
tags:
6+
- '*'
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
1510

1611
jobs:
17-
test:
12+
golangci:
1813
strategy:
1914
matrix:
20-
go-version: [ 1.15.x,1.16.x, ]
21-
os: [ ubuntu-latest ]
15+
go-version: [1.15.x,1.16.x]
16+
os: [macos-latest, ubuntu-latest]
17+
name: lint
2218
runs-on: ${{ matrix.os }}
2319
steps:
24-
- name: Install Go
20+
- uses: actions/checkout@v2
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v2
23+
with:
24+
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
25+
version: latest
26+
build:
27+
strategy:
28+
matrix:
29+
go-version: [ 1.14.x, 1.15.x, 1.16.x ]
30+
os: [ macos-latest, ubuntu-latest ]
31+
runs-on: ${{ matrix.os }}
32+
steps:
33+
- uses: actions/checkout@v2
34+
35+
- name: Set up Go ${{ matrix.go-version }}
2536
uses: actions/setup-go@v2
2637
with:
2738
go-version: ${{ matrix.go-version }}
28-
- name: Checkout code
29-
uses: actions/checkout@v2
30-
- uses: actions/cache@v2
31-
with:
32-
path: |
33-
~/go/pkg/mod # Module download cache
34-
~/.cache/go-build # Build cache (Linux)
35-
~/Library/Caches/go-build # Build cache (Mac)
36-
'%LocalAppData%\go-build' # Build cache (Windows)
37-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
38-
restore-keys: |
39-
${{ runner.os }}-go-
40-
- name: Run linter and tests
41-
run: make test-ci
39+
40+
- name: Tests
41+
run: make test-unit
4242
- name: Update code coverage
43-
run: bash <(curl -s https://codecov.io/bash)
43+
run: bash <(curl -s https://codecov.io/bash)
44+
- name: Build
45+
run: go build -v ./...
46+
release:
47+
needs: [golangci,build]
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v2
51+
- name: release
52+
uses: goreleaser/goreleaser-action@v2
53+
if: startsWith(github.ref, 'refs/tags/')
54+
with:
55+
version: latest
56+
args: release --rm-dist
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.make/go.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ test: ## Runs vet, lint and ALL tests
5757
@echo "running tests..."
5858
@go test ./... -v
5959

60+
test-unit:
61+
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic
62+
6063
test-short: ## Runs vet, lint and tests (excludes integration tests)
6164
@$(MAKE) lint
6265
@echo "running tests (short)..."

0 commit comments

Comments
 (0)