-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathEarthfile
135 lines (105 loc) · 4.3 KB
/
Earthfile
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
VERSION 0.8
IMPORT ../catalyst-gateway AS catalyst-gateway
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.33 AS flutter-ci
# repo-catalyst-voices - Creates artifacts of all configuration files,
# packages and folders related to catalyst_voices frontend.
repo-catalyst-voices:
FROM scratch
WORKDIR /repo
COPY --dir . .
SAVE ARTIFACT /repo repo
# Copy all the necessary files and running bootstrap
builder:
DO flutter-ci+SETUP
COPY +repo-catalyst-voices/repo .
DO flutter-ci+BOOTSTRAP
# Creates filtered OpenAPI spec
# Takes json file from openapi-filter from /packages/internal/catalyst_voices_repositories
filter-openapi:
FROM node:18
WORKDIR /packages/internal/catalyst_voices_repositories
COPY catalyst-gateway+build/doc/cat-gateway-api.json openapi/cat-gateway-api.json
COPY packages/internal/catalyst_voices_repositories/openapi-filters.json openapi-filters.json
RUN npm install -g openapi-format
RUN openapi-format openapi/cat-gateway-api.json -o openapi/filtered-openapi.json --filterFile openapi-filters.json --verbose
RUN rm openapi/cat-gateway-api.json
SAVE ARTIFACT openapi/filtered-openapi.json
# Generates flutter code.
# Generates codes for Catalyst Gateway OpenAPI, Voices Localization and
# VoicesAssets and other packages that depend on code-generator.
# It accepts [save_locally] ARG that when true place the artifacts in the
# proper folders
# It accepts [filter_openapi] ARG that when true filter the openapi spec
# using filters from /packages/internal/catalyst_voices_repositories/openapi-filters.json
code-generator:
ARG save_locally=false
ARG filter_openapi=true
FROM +builder
LET gen_code_path = lib/generated/api
LET local_gen_code_path = packages/internal/catalyst_voices_repositories/lib/generated/api/
RUN melos l10n
RUN melos build_runner
IF [ $save_locally = true ]
RUN find . \( -name "*.g.dart" -o -name "*.freezed.dart" -o -name "*.chopper.dart" -o -name "*.swagger.dart" -o -name "*.openapi.dart" -o -name "*.gen.dart" -o -name "catalyst_voices_localizations*.dart" -o -name "cat_gateway.*.swagger.*" \)
FOR generated_file IN $(find . \( -name "*.g.dart" -o -name "*.freezed.dart" -o -name "*.chopper.dart" -o -name "*.swagger.dart" -o -name "*.openapi.dart" -o -name "*.gen.dart" -o -name "catalyst_voices_localizations*.dart" -o -name "cat_gateway_api.*.swagger.*" \))
SAVE ARTIFACT $generated_file AS LOCAL $generated_file
END
ELSE
SAVE ARTIFACT .
END
WORKDIR packages/internal/catalyst_voices_repositories
IF [ $filter_openapi = true ]
COPY +filter-openapi/filtered-openapi.json openapi/cat-gateway.json
ELSE
COPY catalyst-gateway+build/doc/cat-gateway-api.json openapi/cat-gateway.json
END
DO flutter-ci+OPENAPI_CODE_GEN \
--SAVE_LOCALLY=$save_locally \
--GEN_CODE_PATH=$gen_code_path \
--LOCAL_GEN_CODE_PATH=$local_gen_code_path
# restore current working directory to the root of the project
WORKDIR /frontend
# Runs static analysis on the code.
check-static-analysis:
FROM +code-generator
DO flutter-ci+ANALYZE
# Runs code formatting checks.
check-code-formatting:
FROM +builder
DO flutter-ci+FORMAT
# Runs dry-run publish to verify that publishable packages can be published.
check-package-publishing:
FROM +builder
DO flutter-ci+PUBLISH_DRY_RUN
# Runs the license checks for Catalyst Voices.
check-license:
FROM +builder
RUN melos run license-check
# Run unit tests
test-unit:
FROM +code-generator
DO flutter-ci+UNIT_TESTS
# Build web version of Catalyst Voices
build-web:
FROM +code-generator
ARG RUN_ON_PR=true
ARG SENTRY_DSN
ARG WORKDIR=/frontend/apps/voices
IF [ $RUN_ON_PR = true ]
DO flutter-ci+BUILD_WEB --WORKDIR=$WORKDIR --BUILD_MODE='--profile' --TARGET=lib/configs/main_web.dart
ELSE
DO flutter-ci+BUILD_WEB --WORKDIR=$WORKDIR --TARGET=lib/configs/main_web.dart --SENTRY_DSN=$SENTRY_DSN
SAVE ARTIFACT web
END
package:
FROM nginx:alpine3.20-slim
ARG tag='latest'
COPY +build-web/web /app
COPY ./nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
SAVE IMAGE voices-frontend:$tag
docker:
FROM +package
ARG container="voices"
ARG tag="latest"
SAVE IMAGE ${container}:${tag}