forked from PotionApps/potionx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEarthfile
135 lines (117 loc) · 4.41 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
all:
BUILD +all-test
BUILD +all-integration-test
BUILD +test-forms
BUILD +test-templates
all-frontend:
BUILD +test-forms
BUILD +test-templates
all-test:
BUILD --build-arg ELIXIR=1.11.3 --build-arg OTP=23.2.5 -P +test
test:
FROM +setup-test
RUN apk add --no-progress --update docker docker-compose
RUN apk add postgresql-client inotify-tools
RUN MIX_ENV=test mix deps.compile
COPY --dir config lib priv test ./
COPY ./docker-compose.yml ./docker-compose.yml
ENV DATABASE_URL="ecto://postgres:postgres@localhost/potionx_test"
WITH DOCKER
# Start docker compose
# In parallel start compiling tests
# Check for DB to be up x 3
# Run the database tests
RUN docker-compose up -d & \
while ! pg_isready --host=localhost --port=5432 --quiet; do sleep 1; done; \
mix test && \
MIX_ENV=test mix clean && \
REDIS_URL="redis://localhost:6379/" mix test
END
all-integration-test:
BUILD --build-arg ELIXIR=1.11.3 --build-arg OTP=23.2.5 +integration-test
integration-test:
FROM +setup-test
RUN apk add --no-progress --update docker docker-compose
# Install tooling needed to check if the DBs are actually up when performing integration tests
RUN apk add postgresql-client inotify-tools
# Integration test deps
COPY ./docker-compose.yml ./integration_test/docker-compose.yml
RUN mix local.hex --force
RUN mix local.rebar --force
RUN mkdir -p packages/templates
COPY packages/templates/package* packages/templates
WORKDIR packages/templates
RUN npm install
WORKDIR /src
COPY --dir config packages lib test priv /src
ENV DATABASE_URL="ecto://postgres:postgres@localhost/potionx_test"
RUN MIX_ENV="test" mix compile
WORKDIR /src/integration_test
# Compile phoenix
# COPY --dir config` installer lib test priv /src
# Compiling here improves caching, but slows down GHA speed
# Removing until this feature exists https://github.com/earthly/earthly/issues/574
# RUN MIX_ENV=test mix deps.compile
# RUN npm install '/src/packages/templates'
WITH DOCKER
# Start docker compose
# In parallel start compiling tests
# Check for DB to be up x 3
# Run the database tests
RUN docker-compose up -d & \
while ! pg_isready --host=localhost --port=5432 --quiet; do sleep 1; done; \
node ../packages/templates/cli/cli.mjs project --appName=alpha --localDbPassword=postgres --localDbUser=postgres \
[email protected] --installDeps --runMigrations --potionxDep='path: "../.."' && \
cd alpha && \
mix phx.gen.context Files File files name:string data:map date:utc_datetime test:uuid is_deleted:boolean && \
mix potionx.gen.gql_for_model Files File --no-frontend && \
REDIS_URL="redis://localhost:6379/" mix test && \
cd ./frontend/admin && \
npm run build
END
test-forms:
FROM node:14.16.0-alpine3.12
WORKDIR /src
RUN mkdir -p packages/forms
# Copy package.json + lockfile separatelly to improve caching (JS changes don't trigger `npm install` anymore)
COPY packages/forms/package* packages/forms
WORKDIR packages/forms
RUN npm install
COPY packages/forms/ .
RUN npm test
test-templates:
FROM node:14.16.0-alpine3.12
WORKDIR /src
RUN mkdir -p packages/templates
# Copy package.json + lockfile separatelly to improve caching (JS changes don't trigger `npm install` anymore)
COPY packages/templates/package* packages/templates
WORKDIR packages/templates
RUN npm install
COPY packages/templates/ .
RUN npm test
test-ui:
FROM node:14.16.0-alpine3.12
WORKDIR /src
RUN mkdir -p packages/ui
# Copy package.json + lockfile separatelly to improve caching (JS changes don't trigger `npm install` anymore)
COPY packages/ui/package* packages/ui
WORKDIR packages/ui
RUN npm install
COPY packages/ui/ .
RUN npm test
setup-base:
ARG ELIXIR=1.11.3
ARG OTP=23.2.5
FROM hexpm/elixir:$ELIXIR-erlang-$OTP-alpine-3.13.1
RUN apk add --no-progress --update bash git build-base npm nodejs
ENV ELIXIR_ASSERT_TIMEOUT=10000
WORKDIR /src
setup-test:
FROM +setup-base
COPY mix.exs .
COPY mix.lock .
COPY .formatter.exs .
COPY package.json .
RUN mix local.rebar --force
RUN mix local.hex --force
RUN mix deps.get