-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
189 lines (171 loc) · 8.54 KB
/
Makefile
File metadata and controls
189 lines (171 loc) · 8.54 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
.PHONY: build generate generate-mgmt generate-auth clean test examples help
# Default target
.DEFAULT_GOAL := build
# Management API OpenAPI spec file location
MGMT_OPENAPI_SPEC := $(GODESCOPE)/managementservice/pkg/managementservice/proto/v1/doc/management.openapi.yaml
# Management API Kiota generation parameters
MGMT_KIOTA_LANG := CSharp
MGMT_KIOTA_CLASS := DescopeMgmtKiotaClient
MGMT_KIOTA_NAMESPACE := Descope.Mgmt
MGMT_KIOTA_OUTPUT := ./Descope/Generated/Mgmt
# Exclude paths are defined in the command itself, to allow supporting multiple excludes
# Auth API OpenAPI spec file location
AUTH_OPENAPI_SPEC := $(GODESCOPE)/onetimeservice/pkg/onetimeservice/proto/v1/doc/onetime.openapi.yaml
# Auth API Kiota generation parameters
AUTH_KIOTA_LANG := CSharp
AUTH_KIOTA_CLASS := DescopeAuthKiotaClient
AUTH_KIOTA_NAMESPACE := Descope.Auth
AUTH_KIOTA_OUTPUT := ./Descope/Generated/Auth
AUTH_KIOTA_INCLUDE_PATHS := /v1/auth/**
AUTH_KIOTA_EXCLUDE_PATHS := /v1/auth/validate # not intended for direct SDK use, instead the SDK validates session JWTs internally with cached keys
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
build: generate dotnet-build ## Regenerate Kiota files and rebuild C# DLLs (default)
generate: check-kiota generate-mgmt generate-auth post-process-obsolete ## Regenerate all Kiota client files
check-kiota: ## Check if Kiota is installed, install if not found
@echo "Checking for Kiota..."
@which kiota > /dev/null 2>&1 || { \
echo "Kiota not found. Installing..."; \
dotnet tool install --global Microsoft.OpenApi.Kiota; \
}
@echo "Kiota is available."
generate-mgmt: ## Regenerate Management API Kiota client files from OpenAPI spec
@echo "Checking for Management API OpenAPI spec file..."
@if [ ! -f "$(MGMT_OPENAPI_SPEC)" ]; then \
echo "ERROR: Management API OpenAPI spec file not found at: $(MGMT_OPENAPI_SPEC)"; \
exit 1; \
fi
@echo "Management API OpenAPI spec found: $(MGMT_OPENAPI_SPEC)"
@echo "Generating Management API Kiota client files..."
kiota generate -l $(MGMT_KIOTA_LANG) -c $(MGMT_KIOTA_CLASS) -n $(MGMT_KIOTA_NAMESPACE) -d $(MGMT_OPENAPI_SPEC) -o $(MGMT_KIOTA_OUTPUT) \
--exclude-path /scim/** \
--exclude-path /v1/mgmt/user/history \
--exclude-path /v1/mgmt/accesskey/import \
--exclude-path /v1/mgmt/accesskey/delete/batch \
--exclude-path /v1/mgmt/accesskey/activate/batch \
--exclude-path /v1/mgmt/accesskey/deactivate/batch \
--exclude-path /v1/mgmt/authz/re/deleteresourcesrelations \
--exclude-path /v1/mgmt/connector/useraudit/set \
--exclude-path /v1/mgmt/inboundapp/** \
--exclude-path /v1/mgmt/infra \
--exclude-path /v1/mgmt/localization/** \
--exclude-path /v1/mgmt/mcp/** \
--exclude-path /v1/mgmt/outbound/app/create/bydcrpreset \
--exclude-path /v1/mgmt/outbound/app/create/bytemplate \
--exclude-path /v1/mgmt/outbound/app/tenant/token \
--exclude-path /v1/mgmt/outbound/app/tenant/token/latest \
--exclude-path /v1/mgmt/outbound/app/user/token \
--exclude-path /v1/mgmt/outbound/app/user/token/latest \
--exclude-path /v1/mgmt/outbound/apps-with-user-token \
--exclude-path /v1/mgmt/outbound/token \
--exclude-path /v1/mgmt/outbound/user/tokens \
--exclude-path /v1/mgmt/project/clone/async \
--exclude-path /v1/mgmt/project/clone/async/** \
--exclude-path /v1/mgmt/project/export \
--exclude-path /v1/mgmt/project/import \
--exclude-path /v1/mgmt/project/signkey/** \
--exclude-path /v1/mgmt/role/delete/batch \
--exclude-path /v1/mgmt/tenant/adminlinks/sso/authenticated \
--exclude-path /v1/mgmt/tenant/adminlinks/sso/send \
--exclude-path /v1/mgmt/tenant/sso-user-remove \
--exclude-path /v1/mgmt/thirdparty/app/delete/batch \
--exclude-path /v1/mgmt/token/clientassertion \
--exclude-path /v1/mgmt/user/customattribute/** \
--exclude-path /v1/mgmt/user/customattributes \
--exclude-path /v1/mgmt/user/search \
--exclude-path /v2/mgmt/sso/settings/all \
--exclude-path /v2/mgmt/tenant/adminlinks/sso/generate \
--exclude-path /v2/mgmt/theme/** \
--exclude-path /v2/mgmt/user/update/role/add \
--clean-output
@echo "Management API Kiota generation complete."
generate-auth: ## Regenerate Auth API Kiota client files from OpenAPI spec
@echo "Checking for Auth API OpenAPI spec file..."
@if [ ! -f "$(AUTH_OPENAPI_SPEC)" ]; then \
echo "ERROR: Auth API OpenAPI spec file not found at: $(AUTH_OPENAPI_SPEC)"; \
exit 1; \
fi
@echo "Auth API OpenAPI spec found: $(AUTH_OPENAPI_SPEC)"
@echo "Generating Auth API Kiota client files..."
kiota generate -l $(AUTH_KIOTA_LANG) -c $(AUTH_KIOTA_CLASS) -n $(AUTH_KIOTA_NAMESPACE) -d $(AUTH_OPENAPI_SPEC) -o $(AUTH_KIOTA_OUTPUT) --include-path $(AUTH_KIOTA_INCLUDE_PATHS) --exclude-path $(AUTH_KIOTA_EXCLUDE_PATHS) --clean-output
@echo "Auth API Kiota generation complete."
dotnet-build: ## Build the C# project
@echo "Building C# project..."
cd Descope && dotnet build
@echo "Build complete."
test: ## Run tests for all target frameworks (net6.0, net8.0, net9.0, net10.0)
@echo "Checking for required .NET SDK versions..."
@for version in 6.0 8.0 9.0 10.0; do \
if ! dotnet --list-sdks | grep -q "^$$version"; then \
echo "ERROR: .NET SDK $$version is not installed. Please install it first from: https://dotnet.microsoft.com/en-us/download/dotnet"; \
exit 1; \
fi; \
done
@echo "All required .NET SDK versions found."
@echo ""
@echo "Running unit tests for all target frameworks..."
@echo ""
@echo "=== Testing net6.0 ==="
@cd Descope.Test && dotnet test --framework net6.0 --logger "console;verbosity=normal" || (echo "net6.0 tests FAILED" && exit 1)
@echo ""
@echo "=== Testing net8.0 ==="
@cd Descope.Test && dotnet test --framework net8.0 --logger "console;verbosity=normal" || (echo "net8.0 tests FAILED" && exit 1)
@echo ""
@echo "=== Testing net9.0 ==="
@cd Descope.Test && dotnet test --framework net9.0 --logger "console;verbosity=normal" || (echo "net9.0 tests FAILED" && exit 1)
@echo ""
@echo "=== Testing net10.0 ==="
@cd Descope.Test && dotnet test --framework net10.0 --logger "console;verbosity=normal" || (echo "net10.0 tests FAILED" && exit 1)
@echo ""
@echo "All framework tests complete."
test-quick: ## Run tests for default framework only (faster)
@echo "Running unit tests (quick)..."
cd Descope.Test && dotnet test --framework net8.0
@echo "Quick tests complete."
cover: ## Run tests for default framework with coverage report - can be viewed in VSCode using Coverage Gutters extension
@echo "Cleaning previous test results..."
@rm -rf Descope.Test/TestResults 2>/dev/null || true
@echo "Checking for ReportGenerator..."
@dotnet tool list -g | grep -q dotnet-reportgenerator-globaltool || { \
echo "ReportGenerator not found. Installing..."; \
dotnet tool install -g dotnet-reportgenerator-globaltool; \
}
@echo "Running unit tests with coverage..."
cd Descope.Test && dotnet test --framework net8.0 --collect:"XPlat Code Coverage" --results-directory ./TestResults
@echo ""
@echo "Coverage Summary:"
@reportgenerator -reports:"Descope.Test/TestResults/**/coverage.cobertura.xml" -reporttypes:"TextSummary" -targetdir:"." 2>/dev/null || true
@cat Summary.txt 2>/dev/null && rm -f Summary.txt || echo "Coverage report not generated"
@echo ""
@echo "Full coverage report available in Descope.Test/TestResults/"
examples: ## Run both example applications (TODO: remove after testing)
@echo "Running InstanceExample..."
cd Examples/InstanceExample && dotnet run
@echo ""
@echo "Running ServiceExample..."
cd Examples/ServiceExample && dotnet run
@echo "Examples complete."
post-process-obsolete: ## Apply post-processing obsolete annotations to Kiota generated method we want to mark as obsolete
@echo "Applying post-processing annotations from Obsolete.csv..."
@if [ ! -f "Obsolete.csv" ]; then \
echo "ERROR: Obsolete.csv not found, cannot perform post-processing"; \
exit 1; \
fi
@tail -n +2 Obsolete.csv | while IFS=, read -r filepath method replacement; do \
if [ -f "$$filepath" ]; then \
echo "Processing $$filepath: marking $$method as obsolete (use $$replacement)..."; \
awk -v method="$$method" -v replacement="$$replacement" \
'/'"$$method"'/ { print " [Obsolete(\"Use " replacement " instead\")]"; } {print}' \
"$$filepath" > "$$filepath.tmp" && mv "$$filepath.tmp" "$$filepath"; \
else \
echo "ERROR: File not found: $$filepath" && exit 1; \
fi; \
done
@echo "Post-processing complete."
clean: ## Clean build artifacts
@echo "Cleaning build artifacts..."
cd Descope && dotnet clean
@echo "Clean complete."