forked from boozallen/sdp-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
131 lines (107 loc) · 3.39 KB
/
Justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
coverage := "true"
image := "mkdocs-local"
#########################
# Misc Recipes
#########################
# Print recipes
help:
just --list --unsorted
# Cleanup the docs and target directory
clean:
docker rm -f local-docs
rm -f site
./gradlew clean
# Create a library
create libName:
mkdir -p libraries/{{libName}}/{steps,src,resources,test}
LIB={{libName}} envsubst < resources/docs/README.template.md > libraries/{{libName}}/README.md
###################
# Code Recipes
###################
# Run unit tests
test class="*":
#!/usr/bin/env bash
set -euxo pipefail
coverage=$([[ {{coverage}} == "true" ]] && echo "jacocoTestReport" || echo "")
./gradlew test --tests '{{class}}' $coverage
# Uses npm-groovy-lint to lint the libraries
lint-code:
docker run --rm \
-u "$(id -u):$(id -g)" \
-w=/tmp \
-v "$PWD":/tmp \
nvuillam/npm-groovy-lint -p ./libraries -f **/*.groovy -i "**/test/*,docker/**" -o json
########################
# Documentation Recipes
########################
# Build the docs container image
buildImage:
docker build resources/docs -t {{image}}
# Build the documentation
build:
docker run --rm -v $(pwd):/docs {{image}} build
# serve the docs locally for development
serve: buildImage
docker run --rm -p 8000:8000 -v $(pwd):/docs {{image}} serve -a 0.0.0.0:8000 --watch-theme
# Lint the documentation
lint-docs: lint-prose lint-markdown
# use Vale to lint the prose of the documentation
lint-prose:
docker run --rm -v $(pwd):/app -w /app jdkato/vale docs libraries
# use markdownlit to lint the docs
lint-markdown:
docker run -v $(pwd):/app -w /app davidanson/markdownlint-cli2:0.3.1 "docs/**/*.md" "libraries/**/*.md"
# update current docs
update-docs: buildImage
#!/usr/bin/env bash
version=$(./gradlew -q printVersion)
docker run --rm \
-v ~/.git-credentials:/root/.git-credentials \
-v $(pwd):/docs \
-w /docs \
--entrypoint=mike \
{{image}} deploy --push --update-aliases $version latest
echo "INFO - Published version '$version' to GitHub Pages"
######################
release version:
#!/usr/bin/env bash
# make sure release is done from main
branch=$(git branch --show-current)
if [[ ! "${branch}" == "main" ]]; then
echo "You can only cut a release from the 'main' branch."
echo "Currently on branch '${branch}'"
exit 1
fi
# cut a release branch
git checkout -B release/{{version}}
# bump the version in relevant places
git commit -m "bump version to {{version}}"
git push --set-upstream origin release/{{version}}
# push a tag for this release
git tag {{version}}
git push origin refs/tags/{{version}}
# push the docs for this release
docker run --rm \
-v $(pwd):/docs \
-v ~/.gitconfig:/root/.gitconfig \
-v ~/.git-credentials:/root/.git-credentials \
--entrypoint mike \
{{image}} deploy --push --update-aliases {{version}} latest
docker run --rm \
-v $(pwd):/docs \
-v ~/.gitconfig:/root/.gitconfig \
-v ~/.git-credentials:/root/.git-credentials \
--entrypoint mike \
{{image}} set-default -p latest
# go back to main
git checkout main
delete-release version:
git push origin --delete release/{{version}}
git tag -d {{version}}
git push --delete origin {{version}}
docker run --rm \
-v $(pwd):/docs \
-v ~/.gitconfig:/root/.gitconfig \
-v ~/.git-credentials:/root/.git-credentials \
--entrypoint mike \
{{image}} delete -p -f {{version}}