-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
123 lines (93 loc) · 3.13 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
SHELL := bash
ifeq ($(OS),)
OS := $(shell uname -s)
endif
.DEFAULT_GOAL := build
.DELETE_ON_ERROR:
.SHELLFLAGS := -eu -o pipefail -c
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --warn-undefined-variables
DOTNET ?= dotnet
SED ?= sed
.PHONY: help
help:
@$(SED) -e "/^[a-zA-Z0-9_\-]*:.*##/!d" -e "s/:.*##\s*/:/" ${MAKEFILE_LIST} | sort | column -c 2 -s : -t
CONFIGURATION ?= Debug
BUILD := $(DOTNET) build --nologo --no-restore -c ${CONFIGURATION}
RESTORE := $(DOTNET) restore --nologo
TEST := $(DOTNET) test --nologo --no-build -c ${CONFIGURATION}
build_dir := build
framework := $(shell $(SED) -nr "s|^[[:blank:]]*<TargetFramework>(.*)</TargetFramework>[[:blank:]]*$$|\1|p" Shippo/Shippo.csproj)
cs_files := $(shell find . -name "*.cs" -not -path "*/obj/*")
csproj_files := $(wildcard */*.csproj)
dlls := \
Shippo/bin/${CONFIGURATION}/${framework}/Shippo.dll \
ShippoTests/bin/${CONFIGURATION}/${framework}/ShippoTests.dll
packages_lock_files := $(wildcard */packages.lock.json)
project_assets_files := \
Shippo/obj/project.assets.json \
ShippoTests/obj/project.assets.json
source_files := \
${cs_files} \
${csproj_files} \
global.json \
Shippo.sln
${packages_lock_files}: ${csproj_files}
$(RESTORE) --use-lock-file
@touch -c ${packages_lock_files}
${project_assets_files}: ${csproj_files} ${packages_lock_files}
$(RESTORE) --locked-mode
@touch -c ${project_assets_files}
${dlls}: ${packages_lock_files} ${project_assets_files} ${source_files}
$(BUILD)
@touch -c ${dlls}
.PHONY: build
build: ${dlls} ## build the library and tests dll's (default)
.PHONY: clean
clean: ## remove all build artifacts and temp directories/files
rm -fr Shippo/bin Shippo/obj
rm -fr ShippoTests/bin ShippoTests/obj ShippoTests/TestResults
rm -fr .speakeasy/temp
rm -fr ${build_dir}
.PHONY: update-lock-files
update-lock-files: ${packages_lock_files} ## update lock files
.PHONY: test
test: build ## run tests
ifndef SHIPPO_TOKEN
@echo "Note: some tests require a valid SHIPPO_TOKEN-- \`export SHIPPO_TOKEN=<API_TOKEN>\`"
endif
$(TEST)
.PHONY: ci-check
ci-check: build ## run tests (used by CI)
$(TEST) --logger html
api_spec := ${build_dir}/public-api.yaml
.PHONY: api-spec
api-spec: ${api_spec} ## download the public api spec
${api_spec}:
@mkdir -p $(@D)
curl -s https://docs.goshippo.com/spec/shippoapi/$(notdir ${api_spec}) > ${api_spec}
ifeq (${OS},Linux)
.PHONY: speakeasy-install
speakeasy-install: ## install speakeasy
curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh
else ifeq ($(OS),Darwin)
.PHONY: dotnet-install
dotnet-install: ## install dotnet
brew install dotnet@6
.PHONY: speakeasy-install
speakeasy-install:
brew install speakeasy-api/homebrew-tap/speakeasy
endif
.PHONY: speakeasy-auth
speakeasy-auth: ## authenticates the CLI for use with the Speakeasy Platform
speakeasy auth login
.PHONY: speakeasy-generate-sdk
speakeasy-generate-sdk: ${api_spec} ## regenerate client SDK package
SPEAKEASY_FORCE_GENERATION=true \
speakeasy generate sdk \
-l csharp \
-s ${api_spec} \
-o .
.PHONY: speakeasy-run
speakeasy-run: ## run the workflow(s) defined in your `.speakeasy/workflow.yaml` file
speakeasy run