Skip to content

Commit 5e3ee25

Browse files
feat: brnchswppr initial version
1 parent 6ffdee9 commit 5e3ee25

17 files changed

+2760
-1
lines changed

.circleci/config.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
version: 2.1
2+
orbs:
3+
go: circleci/[email protected]
4+
commitlint: conventional-changelog/[email protected]
5+
6+
parameters:
7+
rebuild_cache:
8+
type: boolean
9+
default: false
10+
11+
# Extra contexts to expose to all jobs below
12+
contexts: &contexts
13+
- aws-credentials
14+
- ghaccesstoken
15+
- docker-registry
16+
- npm-credentials
17+
- vault-dev
18+
- confluence
19+
- circleci-credentials
20+
- tray-webhooks
21+
22+
# Configuration to pass to test and cache jobs
23+
cfg: &cfg
24+
context: *contexts
25+
26+
# Branches used for releasing code, pre-release or not
27+
release_branches: &release_branches
28+
- "main"
29+
30+
executors:
31+
commitlint-executor:
32+
docker:
33+
- image: cimg/node:current
34+
working_directory: ~/project
35+
36+
jobs:
37+
test:
38+
executor:
39+
name: go/default # Use the default executor from the orb
40+
tag: "1.22.2" # Specify a version tag
41+
steps:
42+
- checkout # checkout source code
43+
- go/load-cache # Load cached Go modules.
44+
- go/mod-download # Run 'go mod download'.
45+
- go/save-cache # Save Go modules to cache.
46+
- run:
47+
name: Run unit tests
48+
command: make test
49+
- run:
50+
name: Run integration tests
51+
command: make integration-test
52+
release:
53+
docker:
54+
- image: cimg/go:1.20
55+
steps:
56+
- run: curl -sL https://git.io/autotag-install | sudo sh -s -- -b /usr/bin
57+
- checkout
58+
- run: autotag --scheme=conventional
59+
- run: curl -sfL https://goreleaser.com/static/run | bash
60+
setup-commitlint:
61+
executor: commitlint-executor
62+
steps:
63+
- checkout
64+
- restore_cache:
65+
key: lock-{{ checksum "package-lock.json" }}
66+
- run:
67+
name: Install dependencies
68+
command: npm install
69+
- save_cache:
70+
key: lock-{{ checksum "package-lock.json" }}
71+
paths:
72+
- node_modules
73+
- persist_to_workspace:
74+
root: ~/project
75+
paths:
76+
- node_modules
77+
lint-commit:
78+
executor: commitlint-executor
79+
steps:
80+
- checkout
81+
- attach_workspace:
82+
at: ~/project
83+
- run:
84+
name: Define environment variable with latest commit's message
85+
command: |
86+
echo 'export COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")' >> $BASH_ENV
87+
source $BASH_ENV
88+
- run:
89+
name: Lint commit message
90+
command: echo "$COMMIT_MESSAGE" | npx commitlint
91+
92+
93+
94+
workflows:
95+
main:
96+
jobs:
97+
- setup-commitlint:
98+
filters:
99+
branches:
100+
ignore: /.*/
101+
tags:
102+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
103+
- lint-commit:
104+
requires:
105+
- setup-commitlint
106+
# Only run this job on git tag pushes
107+
filters:
108+
branches:
109+
ignore: /.*/
110+
tags:
111+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
112+
- test:
113+
# Only run this job on git tag pushes
114+
filters:
115+
branches:
116+
ignore: /.*/
117+
tags:
118+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
119+
- release:
120+
# Only run this job on git tag pushes
121+
requires:
122+
- lint-commit
123+
- test
124+
filters:
125+
branches:
126+
ignore: /.*/
127+
tags:
128+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
129+
130+
open_branch:
131+
jobs:
132+
- setup-commitlint
133+
- lint-commit:
134+
requires:
135+
- setup-commitlint
136+
- test:
137+
filters:
138+
branches:
139+
ignore: main
140+
tags:
141+
ignore: /.*/

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@
1717
# Dependency directories (remove the comment below to include it)
1818
# vendor/
1919

20+
# node
21+
node_modules/
22+
2023
# Go workspace file
2124
go.work
2225
go.work.sum
2326

2427
# env file
2528
.env
29+
30+
# binaries
31+
bin/
32+
33+
# dev-tools
34+
.tool-versions
35+
.branchswap

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
PATH := $(PATH):$(PWD)/bin
2+
3+
4+
.PHONY: build test integration-test setup-repo clean
5+
6+
7+
build:
8+
mkdir -p ./bin
9+
go build -o ./bin/brnchswppr ./cmd/branchswapper.go
10+
11+
setup-repo:
12+
chmod u+x ./scripts/setup-repo.sh
13+
./scripts/setup-repo.sh
14+
15+
test:
16+
go test -v -tags brnchswppr_test ./...
17+
18+
integration-test: build setup-repo
19+
export PATH
20+
chmod u+x ./scripts/test.sh
21+
./scripts/test.sh
22+
23+
clean:
24+
rm -rf ./tests || true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# branch-swap
1+
# branchswapper

0 commit comments

Comments
 (0)