-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
229 lines (192 loc) · 8.59 KB
/
Makefile
File metadata and controls
229 lines (192 loc) · 8.59 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
.PHONY: all env install clean clean-chrome icons build-android build-android-release build-ios-dev build-ios build-ios-release update-version firebase-config build-web test start-platform stop-platform test-integration test-integration-smoke test-playwright coverage run-devserver build-docker-local build-docker run-docker stop-docker restart-docker publish
SHELL := /usr/bin/env bash
TAG_VERSION ?= latest
PLATFORM ?= arm64
DOCKER_TAG_VERSION := $(subst +,_,$(TAG_VERSION))
DOCKER_CACHE_DIR ?= .docker-cache
ENVIRONMENT ?= dev-local
HEADLESS ?= true
INTEGRATION_TARGET ?= integration_test/full_test.dart
INTEGRATION_EMAIL_SUFFIX ?= integration-$(USER)
ifeq ($(ENVIRONMENT),prod)
ENVIRONMENT_PREFIX :=
else
ENVIRONMENT_PREFIX := $(ENVIRONMENT).
endif
ifeq ($(ENVIRONMENT),dev-local)
PROJECT_API_HOST ?= http://localhost:8000
else
PROJECT_API_HOST ?= https://api.$(ENVIRONMENT_PREFIX)heliumedu.com
endif
RELEASE_ARGS :=
ifdef RELEASE_VERSION
RELEASE_ARGS += --dart-define=RELEASE_VERSION=$(RELEASE_VERSION)
endif
ifdef SENTRY_DIST
RELEASE_ARGS += --dart-define=SENTRY_DIST=$(SENTRY_DIST)
endif
ifndef RELEASE_VERSION
RELEASE_ARGS += --dart-define=PROJECT_API_HOST=$(PROJECT_API_HOST)
endif
RUN_ARGS :=
ifneq ($(HEADLESS),false)
RUN_ARGS += -d web-server
endif
RUN_ARGS += --dart-define=PROJECT_API_HOST=$(PROJECT_API_HOST)
ifdef LOG_LEVEL
RUN_ARGS += --dart-define=LOG_LEVEL=$(LOG_LEVEL)
endif
ifdef PORT
RUN_ARGS += --web-port=$(PORT)
else
RUN_ARGS += --web-port=8080
endif
DRIVE_ARGS := --driver=test_driver/integration_test.dart -d web-server --web-port=8080 --browser-name=chrome --profile --dart-define=ENVIRONMENT=$(ENVIRONMENT)
DRIVE_ARGS += --web-browser-flag="--user-data-dir=/tmp/chrome_test_profile"
ifeq ($(HEADLESS),true)
DRIVE_ARGS += --headless
else
DRIVE_ARGS += --no-headless
endif
DRIVE_ARGS += --dart-define=PROJECT_API_HOST=$(PROJECT_API_HOST)
ifdef LOG_LEVEL
DRIVE_ARGS += --dart-define=LOG_LEVEL=$(LOG_LEVEL)
endif
ifdef AWS_INTEGRATION_S3_ACCESS_KEY_ID
DRIVE_ARGS += --dart-define=AWS_INTEGRATION_S3_ACCESS_KEY_ID=$(AWS_INTEGRATION_S3_ACCESS_KEY_ID)
endif
ifdef AWS_INTEGRATION_S3_SECRET_ACCESS_KEY
DRIVE_ARGS += --dart-define=AWS_INTEGRATION_S3_SECRET_ACCESS_KEY=$(AWS_INTEGRATION_S3_SECRET_ACCESS_KEY)
endif
ifdef INTEGRATION_LOG_LEVEL
DRIVE_ARGS += --dart-define=INTEGRATION_LOG_LEVEL=$(INTEGRATION_LOG_LEVEL)
endif
ifdef INTEGRATION_EMAIL_SUFFIX
DRIVE_ARGS += --dart-define=INTEGRATION_EMAIL_SUFFIX=$(INTEGRATION_EMAIL_SUFFIX)
endif
ifdef EMAIL_POLL_TIMEOUT_MINUTES
DRIVE_ARGS += --dart-define=EMAIL_POLL_TIMEOUT_MINUTES=$(EMAIL_POLL_TIMEOUT_MINUTES)
endif
ifdef RELEASE_VERSION
DRIVE_ARGS += --dart-define=RELEASE_VERSION=$(RELEASE_VERSION)
endif
ifdef SENTRY_DIST
DRIVE_ARGS += --dart-define=SENTRY_DIST=$(SENTRY_DIST)
endif
all: build-docker-local run-docker
env:
cp -n .env.example .env | true
install: env
flutter pub get
clean:
flutter clean
clean-chrome:
@echo "Killing stale Chrome and chromedriver processes ..."
@pkill -f chromedriver || true
@pkill -f "Chrome.*--remote-debugging" || true
@pkill -f "Google Chrome for Testing" || true
@sleep 1
@echo "Done"
build-android: install
flutter build apk --debug
build-android-release: install
flutter build appbundle --release --obfuscate --split-debug-info=build/symbols $(RELEASE_ARGS)
build-ios-dev: install
flutter build ios
build-ios: install
flutter build ios --debug --no-codesign
build-ios-release: install
flutter build ipa --release --export-options-plist=ios/ExportOptions.plist --obfuscate --split-debug-info=build/symbols $(RELEASE_ARGS)
build-web: install
flutter build web --release --source-maps --no-tree-shake-icons --pwa-strategy=none $(RELEASE_ARGS)
cp -r web/.well-known build/web/
rm -f build/web/.last_build_id
$(MAKE) update-version
icons:
flutter pub run flutter_launcher_icons
cp web/icons/Icon-192.png web/favicon.png
update-version:
dart bin/update_version.dart
firebase-config:
flutterfire config --project=helium-edu --yes
test: install
flutter analyze --no-pub --no-fatal-infos --no-fatal-warnings
flutter test --no-pub --coverage
start-platform:
@if curl -sf http://localhost:8000/status/ > /dev/null 2>&1; then \
echo "Platform already running"; \
else \
echo "Starting platform ..."; \
curl -fsSL "https://raw.githubusercontent.com/HeliumEdu/platform/main/bin/start-platform.sh?$$(date +%s)" | bash; \
fi
@if [ -n "$$PLATFORM_EMAIL_HOST_USER" ] && [ -n "$$PLATFORM_EMAIL_HOST_PASSWORD" ]; then \
WORK_DIR=$${TMPDIR:-/tmp}/helium-platform; \
if grep -q '<SMTP_USERNAME>' "$$WORK_DIR/.env" 2>/dev/null; then \
echo "Injecting SMTP credentials and restarting API ..."; \
sed -i.bak "s/<SMTP_USERNAME>/$$PLATFORM_EMAIL_HOST_USER/" $$WORK_DIR/.env; \
sed -i.bak "s/<SMTP_PASSWORD>/$$PLATFORM_EMAIL_HOST_PASSWORD/" $$WORK_DIR/.env; \
cd $$WORK_DIR && docker compose up -d api worker; \
fi; \
fi
stop-platform:
@curl -fsSL "https://raw.githubusercontent.com/HeliumEdu/platform/main/bin/stop-platform.sh?$$(date +%s)" | bash
test-integration:
ifeq ($(ENVIRONMENT),dev-local)
@$(MAKE) start-platform
endif
@chromedriver --port=4444 & CHROME_PID=$$!; sleep 2 && flutter drive --target=$(INTEGRATION_TARGET) $(DRIVE_ARGS); TEST_EXIT=$$?; \
kill $$CHROME_PID 2>/dev/null || true; \
exit $$TEST_EXIT
test-integration-smoke:
@chromedriver --port=4444 & CHROME_PID=$$!; sleep 2 && flutter drive --target=integration_test/smoke_test.dart $(DRIVE_ARGS); TEST_EXIT=$$?; kill $$CHROME_PID 2>/dev/null || true; exit $$TEST_EXIT
test-playwright:
cd playwright && python3 -m pip install -r requirements.txt -q && python3 -m playwright install chromium && python3 -m pytest -v --screenshot=only-on-failure --output=screenshots
coverage:
dart pub global activate test_cov_console
lcov -o coverage/lcov.info --remove coverage/lcov.info 'lib/config/*' 'lib/utils/app_globals.dart' 'lib/utils/app_style.dart' 'lib/utils/color_helpers.dart' 'lib/data/models/*' 'lib/data/repositories/*' 'lib/presentation/core/*' 'lib/presentation/navigation/*' 'lib/presentation/ui/*' 'lib/presentation/features/auth/views/*' 'lib/presentation/features/courses/dialogs/*' 'lib/presentation/features/courses/views/*' 'lib/presentation/features/courses/widgets/*' 'lib/presentation/features/grades/dialogs/*' 'lib/presentation/features/grades/views/*' 'lib/presentation/features/planner/dialogs/*' 'lib/presentation/features/planner/views/*' 'lib/presentation/features/planner/widgets/*' 'lib/presentation/features/resources/dialogs/*' 'lib/presentation/features/resources/views/*' 'lib/presentation/features/resources/widgets/*' 'lib/presentation/features/settings/dialogs/*' 'lib/presentation/features/settings/views/*' 'lib/presentation/features/shared/widgets/*'
dart pub global run test_cov_console
run-devserver: install
ifeq ($(USE_NGROK),true)
$(eval RUN_ARGS += --release)
@( \
python3 -m pip install pyngrok; \
ngrok start heliumedu --log stdout & \
)
endif
flutter run $(RUN_ARGS)
SENTRY_ENVIRONMENT ?= $(ENVIRONMENT)
FLUTTER_VERSION := $(shell tr -d '[:space:]' < .flutter-version)
build-docker-local: build-web
docker build \
--target frontend_web_local \
-t helium/frontend-web:$(PLATFORM)-latest \
-t helium/frontend-web:$(PLATFORM)-$(DOCKER_TAG_VERSION) \
.
build-docker:
mkdir -p $(DOCKER_CACHE_DIR)
docker buildx build \
--target frontend_web \
--build-arg FLUTTER_VERSION=$(FLUTTER_VERSION) \
--build-arg RELEASE_VERSION=$(RELEASE_VERSION) \
--build-arg SENTRY_DIST=$(SENTRY_DIST) \
--build-arg SENTRY_ENVIRONMENT=$(SENTRY_ENVIRONMENT) \
--cache-from=type=local,src=$(DOCKER_CACHE_DIR) \
--cache-to=type=local,dest=$(DOCKER_CACHE_DIR),mode=max \
-t helium/frontend-web:$(PLATFORM)-latest \
-t helium/frontend-web:$(PLATFORM)-$(DOCKER_TAG_VERSION) \
--platform=linux/$(PLATFORM) \
--load .
run-docker:
docker compose up -d
stop-docker:
docker compose stop
restart-docker: stop-docker run-docker
publish: build-docker
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/heliumedu
docker tag helium/frontend-web:$(PLATFORM)-$(DOCKER_TAG_VERSION) public.ecr.aws/heliumedu/helium/frontend-web:$(PLATFORM)-$(DOCKER_TAG_VERSION)
docker push public.ecr.aws/heliumedu/helium/frontend-web:$(PLATFORM)-$(DOCKER_TAG_VERSION)
docker tag helium/frontend-web:$(PLATFORM)-$(DOCKER_TAG_VERSION) public.ecr.aws/heliumedu/helium/frontend-web:$(PLATFORM)-latest
docker push public.ecr.aws/heliumedu/helium/frontend-web:$(PLATFORM)-latest
docker create --name frontend-web helium/frontend-web:$(PLATFORM)-$(DOCKER_TAG_VERSION)
docker cp frontend-web:/app build
aws s3 sync build "s3://heliumedu/helium/frontend-web/$(TAG_VERSION)"