-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
160 lines (139 loc) · 4.25 KB
/
Makefile
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
API_VERSION=$(shell cat api_version)
SDK_VERSION=$(shell cat sdk_version)
USER_ID=$(shell id -u)
GROUP_ID=$(shell id -g)
OPENAPI_IMG=outscale/openapi-generator:ts-fetch-aws-v4
SHELL := /bin/bash
all: help
.PHONY: help
help:
@echo "help:"
@echo "- make gen : regenerate SDK"
@echo "- make test : run all tests"
.PHONY: gen
gen: clean osc-generate
.PNONY: openapi-generator-help
openapi-generator-help:
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMG) config-help -g typescript-fetch
.PHONY: osc-generate
osc-generate: osc-api/outscale.yaml
@echo start generating SDK...
rm -rf .sdk || true
mkdir .sdk
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMG) generate -i /sdk/osc-api/outscale.yaml -g typescript-fetch -c /sdk/gen.yml -o /sdk/.sdk --additional-properties=npmVersion=$(SDK_VERSION)
# Set sdk version using reproductible sed.
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMG) sed -i "s/\"version\".*/\"version\": \"$(SDK_VERSION)\",/" /sdk/package.json
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMG) chown -R $(USER_ID).$(GROUP_ID) /sdk/.sdk
mv .sdk/src ./
(cd src && git apply ../.osc-patches/*)
# Set User-agent version
sed -i "s/##SDK_VERSION##/$(SDK_VERSION)/" src/runtime.ts
@echo SDK generated
@echo testing SDK build...
@source ~/.nvm/nvm.sh; \
echo "nvm --version:"; \
nvm --version; \
echo "nvm install..."; \
nvm install; \
echo "nvm use..."; \
nvm use; \
echo "npm version..."; \
npm version; \
echo "npm install..."; \
npm install --local
osc-api/outscale.yaml:
@echo getting osc-api description...
git clone https://github.com/outscale/osc-api-deploy.git osc-api && cd osc-api && git checkout -b $(API_VERSION) $(API_VERSION)
.PHONY: clean
clean:
@echo cleaning build artifacts...
rm -rf .sdk osc-api src node_modules dist || true
.PHONY: test
test: reuse-test examples-test regen-test
@echo all tests OK...
.PHONY: reuse-test
reuse-test:
@echo testing licensing with reuse...
docker run --rm --volume $(PWD):/data fsfe/reuse:0.11.1 lint
.PHONY: examples-test
examples-test: example-web-vms example-node-volumes example-node-create-volumes
@echo examples are OK
.PHONY: example-web-vms
example-web-vms:
@echo testing examples/web-vms example...
@source ~/.nvm/nvm.sh; \
cd examples/web-vms; \
echo "nvm --version:"; \
nvm --version; \
echo "nvm install..."; \
nvm install 20.5.1; \
echo "nvm use..."; \
nvm use 20.5.1; \
echo "npm version:"; \
npm version; \
echo "npm install..."; \
npm install --local --install-links
.PHONY: example-node-create-volumes
example-node-create-volumes:
@echo testing examples/node-create-volume example...
@source ~/.nvm/nvm.sh; \
cd examples/node-create-volume; \
echo "nvm version:"; \
nvm --version; \
echo "nvm install..."; \
nvm install 20.5.1; \
echo "nvm use..."; \
nvm use 20.5.1; \
echo "npm version:"; \
npm version; \
echo "npm install..."; \
npm install --local --install-links; \
echo "running node example..."; \
node --trace-warnings ./src/index.js > /dev/null
.PHONY: example-node-volumes
example-node-volumes:
@echo testing examples/node-volumes example...
@source ~/.nvm/nvm.sh; \
cd examples/node-volumes; \
echo "nvm version:"; \
nvm --version; \
echo "nvm install..."; \
nvm install 20.5.1; \
echo "nvm use..."; \
nvm use 20.5.1; \
echo "npm version:"; \
npm version; \
echo "npm install..."; \
npm install --local --install-links; \
echo "running node example..."; \
node ./src/index.js > /dev/null
# try to regen, should not have any difference
.PHONY: regen-test
regen-test: gen
@echo SDK regeneration test...
git add src dist
git diff --cached -s --exit-code
git diff -s --exit-code
# Used by bot to auto-release
# GH_TOKEN and SSH_PRIVATE_KEY are needed
.PHONY: auto-release
auto-release: auto-release-cleanup osc-api-check release-check-duplicate release-build release-push release-pr
@echo OK
.PHONY: auto-release-cleanup
auto-release-cleanup:
rm -rf .auto-release-abort || true
.PHONY: osc-api-check
osc-api-check:
bash .github/scripts/osc-api-check.sh
.PHONY: release-check-duplicate
release-check-duplicate:
bash .github/scripts/release-check-duplicate.sh
.PHONY: release-build
release-build:
bash .github/scripts/release-build.sh
.PHONY: release-push
release-push:
bash .github/scripts/release-push.sh
.PHONY: release-pr
release-pr:
bash .github/scripts/release-pr.sh