Skip to content

Commit 9d20a6d

Browse files
grevychgerardo-reyes-s1
authored andcommitted
feat: brnchswppr initial version
1 parent 6ffdee9 commit 9d20a6d

18 files changed

+2787
-1
lines changed

.circleci/config.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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+
check-initial-tag:
92+
docker:
93+
- image: cimg/base:stable
94+
steps:
95+
- checkout
96+
- run:
97+
name: Check initial tag v0.0.0
98+
command: make check-initial-tag
99+
100+
101+
workflows:
102+
release-version:
103+
jobs:
104+
- setup-commitlint:
105+
filters:
106+
branches:
107+
ignore: /.*/
108+
tags:
109+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
110+
- lint-commit:
111+
requires:
112+
- setup-commitlint
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+
- test:
120+
# Only run this job on git tag pushes
121+
filters:
122+
branches:
123+
ignore: /.*/
124+
tags:
125+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
126+
- check-initial-tag:
127+
# Only run this job on git tag pushes
128+
filters:
129+
branches:
130+
ignore: /.*/
131+
tags:
132+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
133+
- release:
134+
# Only run this job on git tag pushes
135+
requires:
136+
- lint-commit
137+
- test
138+
- check-initial-tag
139+
filters:
140+
branches:
141+
ignore: /.*/
142+
tags:
143+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
144+
145+
branch:
146+
jobs:
147+
- setup-commitlint
148+
- lint-commit:
149+
requires:
150+
- setup-commitlint
151+
- test:
152+
filters:
153+
branches:
154+
ignore: main
155+
tags:
156+
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
PATH := $(PATH):$(PWD)/bin
2+
3+
4+
.PHONY: build test integration-test setup-repo clean check-initial-tag helpt
5+
6+
7+
check-initial-tag:
8+
chmod u+x ./scripts/check-initial-tag.sh
9+
./scripts/check-initial-tag.sh
10+
11+
build:
12+
mkdir -p ./bin
13+
go build -o ./bin/brnchswppr ./cmd/branchswapper.go
14+
15+
setup-repo:
16+
chmod u+x ./scripts/setup-repo.sh
17+
./scripts/setup-repo.sh
18+
19+
test:
20+
go test -v -tags brnchswppr_test ./...
21+
22+
integration-test: build setup-repo
23+
export PATH
24+
chmod u+x ./scripts/test.sh
25+
./scripts/test.sh
26+
27+
clean:
28+
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)