-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
104 lines (86 loc) · 3.4 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
API_VERSION=$(shell cat api_version)
SDK_VERSION=$(shell cat sdk_version)
USER_ID=$(shell id -u)
GROUP_ID=$(shell id -g)
OPENAPI_IMAGE=openapitools/openapi-generator-cli:v6.0.1
PWD=$(shell pwd)
all: help
.PHONY: help
help:
@echo "help:"
@echo "- make gen : regenerate SDK"
@echo "- make test : run all tests"
.PNONY: openapi-generator-help
openapi-generator-help:
docker run --rm openapitools/openapi-generator-cli$(OPENAPI_GEN_VERSION) config-help -g rust
.PHONY: gen
gen: clean osc-api/outscale.yaml
rm -rf .sdk || true
mkdir .sdk
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMAGE) generate -i /sdk/osc-api/outscale.yaml -g rust -c /sdk/gen.yml -o /sdk/.sdk --additional-properties=packageVersion=$(SDK_VERSION)
# Set default user agent including sdk version using reproductible sed.
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMAGE) sed -i "s/ *user_agent: Some.*/ user_agent: Some(\"osc\-sdk\-rust\/$(SDK_VERSION)\".to_owned()),/" /sdk/.sdk/src/apis/configuration.rs
# Set outscale as author
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMAGE) sed -i "s/OpenAPI Generator team and contributors/Outscale SAS <[email protected]>/g" /sdk/.sdk/Cargo.toml
# Set rust version, licensing, homepage, description, ...
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMAGE) sed -i "s/edition = \"2018\"/edition = \"2021\"\nlicense = \"BSD-3-Clause\"\ndescription = \"Outscale API SDK\"\nrepository = \"https:\/\/github.com\/outscale\/osc-sdk-rust\/\"/" /sdk/.sdk/Cargo.toml
# Add dev-dependencies (used by examples)
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMAGE) sed -i "s/\[dev-dependencies\]/\[dev-dependencies\]\nrand = \"0.8.5\"/" /sdk/.sdk/Cargo.toml
docker run -v $(PWD):/sdk --rm $(OPENAPI_IMAGE) chown -R $(USER_ID).$(GROUP_ID) /sdk/.sdk
rm -rf .sdk/git_push.sh
mv .sdk/README.md .sdk/docs/README.md
mv .sdk/* .
rm -rf .sdk
cargo fmt
# Apply additional Outscale features or fixes which are not included in generation
git apply .patches/*
cargo fmt
osc-api/outscale.yaml:
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:
rm -rf .sdk osc-api Cargo.toml docs src || true
.PHONY: test
test: build-test reuse-test examples-test regen-test
@echo all tests OK
.PHONY: build-test
build-test:
cargo build --all-targets
.PHONY: reuse-test
reuse-test:
docker run --rm --volume $(PWD):/data fsfe/reuse:0.11.1 lint
.PHONY: examples-test
examples-test:
cargo run --example volume
cargo run --example region
cargo run --example keypair
cargo run --example config_file
# try to regen, should not have any difference
.PHONY: regen-test
regen-test: gen
git add Cargo.toml docs src
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