Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (124 loc) · 4.99 KB
/
Copy pathMakefile
File metadata and controls
141 lines (124 loc) · 4.99 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
SOURCE_DIRECTORY := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
ARTIFACT_PATH := $(SOURCE_DIRECTORY)artifacts
DOCS_PATH := $(SOURCE_DIRECTORY)docs
CONFIGURATION ?= Release
ADDITIONAL_ARGS ?= -p:ContinuousIntegrationBuild=true
NUGET_SOURCE ?= "https://api.nuget.org/v3/index.json"
NUGET_API_KEY ?= ""
DOCKER_IMAGE_NAME ?= "polytype-docker-build"
DOCKER_CMD ?= make pack
VERSION_FILE = $(SOURCE_DIRECTORY)version.json
VERSION ?=
clean:
dotnet clean --configuration $(CONFIGURATION)
rm -rf $(ARTIFACT_PATH)/*
rm -rf $(DOCS_PATH)/api
restore:
dotnet tool restore
dotnet restore
build: restore
dotnet build --no-restore --configuration $(CONFIGURATION) $(ADDITIONAL_ARGS)
test-clr: build
dotnet test \
--configuration $(CONFIGURATION) \
--no-build \
$(ADDITIONAL_ARGS) \
-p:SkipTUnitTestRuns=true \
--report-trx \
--coverage \
--coverage-output-format cobertura \
--crashdump \
--hangdump \
--hangdump-timeout 10m \
--results-directory $(ARTIFACT_PATH)/testResults
test-aot: build
dotnet publish $(SOURCE_DIRECTORY)/tests/PolyType.Tests.NativeAOT/PolyType.Tests.NativeAOT.csproj \
$(ADDITIONAL_ARGS) \
-o $(ARTIFACT_PATH)/native-aot-tests
$(ARTIFACT_PATH)/native-aot-tests/PolyType.Tests.NativeAOT
# Publishes the canonical Native AOT scenario used to track app size and
# compares the published binary's file size against the per-platform baseline
# committed at tests/SizeTrackingApp.AOT/aot-size-baselines.json. The tool
# prints an agent-parseable "AOT-SIZE-RESULT" block to stdout - a contributor
# can read each CI leg's log and copy the per-RID size_bytes values into the
# baselines file to refresh every platform from one CI run.
test-aot-size:
dotnet publish $(SOURCE_DIRECTORY)/tests/SizeTrackingApp.AOT/SizeTrackingApp.AOT.csproj \
--configuration $(CONFIGURATION) \
$(ADDITIONAL_ARGS) \
-o $(ARTIFACT_PATH)/size-tracking-app
dotnet run --project $(SOURCE_DIRECTORY)/eng/AotSizeCheck/AotSizeCheck.csproj -- check \
--baselines $(SOURCE_DIRECTORY)/tests/SizeTrackingApp.AOT/aot-size-baselines.json \
--publish-dir $(ARTIFACT_PATH)/size-tracking-app \
--app-name SizeTrackingApp.AOT
# Refreshes the baseline entry for the current platform's RID only.
# Use this for local single-platform updates; to update every platform at
# once, read the AOT-SIZE-RESULT block from each leg of a CI run and merge
# the size_bytes values into aot-size-baselines.json by hand.
update-aot-size-baseline:
dotnet publish $(SOURCE_DIRECTORY)/tests/SizeTrackingApp.AOT/SizeTrackingApp.AOT.csproj \
--configuration $(CONFIGURATION) \
$(ADDITIONAL_ARGS) \
-o $(ARTIFACT_PATH)/size-tracking-app
dotnet run --project $(SOURCE_DIRECTORY)/eng/AotSizeCheck/AotSizeCheck.csproj -- update \
--baselines $(SOURCE_DIRECTORY)/tests/SizeTrackingApp.AOT/aot-size-baselines.json \
--publish-dir $(ARTIFACT_PATH)/size-tracking-app \
--app-name SizeTrackingApp.AOT
test-source-package: build
dotnet run --project $(SOURCE_DIRECTORY)/eng/SourcePackageTests/SourcePackageTests.csproj \
--configuration $(CONFIGURATION) -- "$(SOURCE_DIRECTORY)" "$(CONFIGURATION)" $(NUGET_SOURCE)
test: test-clr test-aot test-source-package
pack: build
dotnet pack --no-restore --configuration Release $(ADDITIONAL_ARGS)
push:
dotnet nuget push $(ARTIFACT_PATH)/*.nupkg -s $(NUGET_SOURCE) -k $(NUGET_API_KEY)
generate-docs: restore
dotnet build -c Release
dotnet docfx $(DOCS_PATH)/docfx.json --warningsAsErrors true
serve-docs: generate-docs
dotnet docfx serve $(ARTIFACT_PATH)/_site --port 8080
# Explicit continuations support macOS's bundled GNU Make 3.81.
release: restore
set -e; \
cd "$(SOURCE_DIRECTORY)"; \
changes=$$(git -C "$(SOURCE_DIRECTORY)" status --porcelain --untracked-files=all -- . ':(exclude)version.json'); \
if [ -n "$$changes" ]; then \
echo "repo contains uncommitted changes outside version.json" >&2; \
exit 1; \
fi; \
if [ ! -f "$(VERSION_FILE)" ]; then \
echo "version file does not exist: $(VERSION_FILE)" >&2; \
exit 1; \
fi; \
version="$(VERSION)"; \
if [ -z "$$version" ]; then \
if ! command -v jq > /dev/null 2>&1; then \
echo "jq is required when VERSION is not specified" >&2; \
exit 1; \
elif ! version=$$(jq -er '.version | select(type == "string" and length > 0)' "$(VERSION_FILE)"); then \
echo "could not read a nonempty version string from $(VERSION_FILE)" >&2; \
exit 1; \
fi; \
fi; \
dotnet nbgv set-version "$$version" --project "$(SOURCE_DIRECTORY)"; \
git commit -m "Bump version to $$version"; \
dotnet nbgv tag; \
git push; \
git push --tags; \
gh_args=""; \
case "$${version%%+*}" in \
*-*) gh_args="--prerelease" ;; \
esac; \
if [ -f latest-release-notes.md ]; then \
gh_args="$$gh_args --notes-file latest-release-notes.md"; \
fi; \
tag=$$(git describe --tags --abbrev=0); \
gh release create "$$tag" --generate-notes --verify-tag $$gh_args
docker-build: clean
docker build -t $(DOCKER_IMAGE_NAME) .
docker run --rm -t \
-v $(ARTIFACT_PATH):/repo/artifacts \
$(DOCKER_IMAGE_NAME) \
$(DOCKER_CMD)
docker rmi -f $(DOCKER_IMAGE_NAME)
.DEFAULT_GOAL := test