Skip to content

Commit e88b4c4

Browse files
committed
Fix credo dialyzer errors
1 parent f15b790 commit e88b4c4

70 files changed

Lines changed: 694 additions & 597 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/master.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jobs:
3737

3838
- uses: erlef/setup-beam@v1
3939
with:
40-
otp-version: '25.0.3'
41-
elixir-version: '1.13.4'
40+
otp-version: '25.2'
41+
elixir-version: '1.14.3'
4242

4343
- uses: actions/cache@v2
4444
with:
@@ -127,8 +127,10 @@ jobs:
127127
- name: Login to Docker Hub
128128
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
129129

130-
- run: make docker-build-app
131-
- run: make docker-push-app
130+
- run: make docker-build-codebattle
131+
- run: make docker-push-codebattle
132+
- run: make docker-build-runner
133+
- run: make docker-push-runner
132134

133135
- name: Notify Rollbar of deploy finish
134136
uses: rollbar/[email protected]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ kubeconfig.yml
5757

5858
stats.json
5959
*.hcl
60+
services/app/priv/plts/*.plt
61+
services/app/priv/plts/*.plt.hash

Makefile

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,43 @@ ansible-vault-edit-production:
3737
release:
3838
make -C services/app release
3939

40-
docker-build-app:
41-
docker pull codebattle/app:compile-stage || true
42-
docker pull codebattle/app:latest || true
40+
docker-build-codebattle:
41+
docker pull codebattle/codebattle:compile-stage || true
42+
docker pull codebattle/codebattle:latest || true
4343
docker build --target compile-image \
44-
--cache-from=codebattle/app:compile-stage \
45-
--file services/app/Dockerfile \
46-
--tag codebattle/app:compile-stage services/app
44+
--cache-from=codebattle/codebattle:compile-stage \
45+
--file services/app/Dockerfile.codebattle \
46+
--tag codebattle/codebattle:compile-stage services/app
4747
docker build --target runtime-image \
48-
--cache-from=codebattle/app:compile-stage \
49-
--cache-from=codebattle/app:latest \
50-
--file services/app/Dockerfile \
51-
--tag codebattle/app:latest services/app
52-
53-
docker-push-app:
54-
docker push codebattle/app:compile-stage
55-
docker push codebattle/app:latest
48+
--cache-from=codebattle/codebattle:compile-stage \
49+
--cache-from=codebattle/codebattle:latest \
50+
--file services/app/Dockerfile.codebattle \
51+
--tag codebattle/codebattle:latest services/app
52+
53+
docker-push-codebattle:
54+
docker push codebattle/codebattle:compile-stage
55+
docker push codebattle/codebattle:latest
56+
57+
docker-build-runner:
58+
docker pull codebattle/runner:compile-stage || true
59+
docker pull codebattle/runner:latest || true
60+
docker build --target compile-image \
61+
--cache-from=codebattle/runner:compile-stage \
62+
--file services/app/Dockerfile.runner \
63+
--tag codebattle/runner:compile-stage services/app
64+
docker build --target runtime-image \
65+
--cache-from=codebattle/runner:compile-stage \
66+
--cache-from=codebattle/runner:latest \
67+
--file services/app/Dockerfile.runner \
68+
--tag codebattle/runner:latest services/app
69+
70+
docker-push-runner:
71+
docker push codebattle/runner:compile-stage
72+
docker push codebattle/runner:latest
73+
74+
docker-build-nginx:
75+
docker build --file services/nginx/Dockerfile --tag codebattle/nginx services/nginx
76+
77+
docker-push-nginx:
78+
docker push codebattle/nginx:latest
79+

services/app/.credo.exs

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
%{
2+
configs: [
3+
%{
4+
name: "default",
5+
files: %{
6+
included: [
7+
"apps/*/lib/",
8+
"apps/*/src/",
9+
"apps/*/test/",
10+
"apps/*/web/"
11+
],
12+
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
13+
},
14+
plugins: [],
15+
requires: [],
16+
strict: false,
17+
parse_timeout: 5000,
18+
color: true,
19+
checks: %{
20+
enabled: [
21+
#
22+
## Consistency Checks
23+
#
24+
{Credo.Check.Consistency.ExceptionNames, []},
25+
{Credo.Check.Consistency.LineEndings, []},
26+
{Credo.Check.Consistency.ParameterPatternMatching, []},
27+
{Credo.Check.Consistency.SpaceAroundOperators, []},
28+
{Credo.Check.Consistency.SpaceInParentheses, []},
29+
{Credo.Check.Consistency.TabsOrSpaces, []},
30+
31+
#
32+
## Design Checks
33+
#
34+
# You can customize the priority of any check
35+
# Priority values are: `low, normal, high, higher`
36+
#
37+
{Credo.Check.Design.AliasUsage,
38+
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
39+
# You can also customize the exit_status of each check.
40+
# If you don't want TODO comments to cause `mix credo` to fail, just
41+
# set this value to 0 (zero).
42+
#
43+
{Credo.Check.Design.TagTODO, false},
44+
{Credo.Check.Design.TagFIXME, []},
45+
46+
#
47+
## Readability Checks
48+
#
49+
{Credo.Check.Readability.AliasOrder, []},
50+
{Credo.Check.Readability.FunctionNames, []},
51+
{Credo.Check.Readability.LargeNumbers, []},
52+
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
53+
{Credo.Check.Readability.ModuleAttributeNames, []},
54+
{Credo.Check.Readability.ModuleDoc, false},
55+
{Credo.Check.Readability.ModuleNames, []},
56+
{Credo.Check.Readability.ParenthesesInCondition, []},
57+
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
58+
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
59+
{Credo.Check.Readability.PredicateFunctionNames, []},
60+
{Credo.Check.Readability.PreferImplicitTry, []},
61+
{Credo.Check.Readability.RedundantBlankLines, []},
62+
{Credo.Check.Readability.Semicolons, []},
63+
{Credo.Check.Readability.SpaceAfterCommas, []},
64+
{Credo.Check.Readability.StringSigils, []},
65+
{Credo.Check.Readability.TrailingBlankLine, []},
66+
{Credo.Check.Readability.TrailingWhiteSpace, []},
67+
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
68+
{Credo.Check.Readability.VariableNames, []},
69+
{Credo.Check.Readability.WithSingleClause, []},
70+
71+
#
72+
## Refactoring Opportunities
73+
#
74+
{Credo.Check.Refactor.Apply, []},
75+
{Credo.Check.Refactor.CondStatements, []},
76+
{Credo.Check.Refactor.CyclomaticComplexity, []},
77+
{Credo.Check.Refactor.FunctionArity, []},
78+
{Credo.Check.Refactor.LongQuoteBlocks, []},
79+
{Credo.Check.Refactor.MatchInCondition, []},
80+
{Credo.Check.Refactor.MapJoin, []},
81+
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
82+
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
83+
{Credo.Check.Refactor.Nesting, []},
84+
{Credo.Check.Refactor.UnlessWithElse, []},
85+
{Credo.Check.Refactor.WithClauses, []},
86+
{Credo.Check.Refactor.FilterFilter, []},
87+
{Credo.Check.Refactor.RejectReject, []},
88+
{Credo.Check.Refactor.RedundantWithClauseResult, []},
89+
90+
#
91+
## Warnings
92+
#
93+
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
94+
{Credo.Check.Warning.BoolOperationOnSameValues, []},
95+
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
96+
{Credo.Check.Warning.IExPry, []},
97+
{Credo.Check.Warning.IoInspect, []},
98+
{Credo.Check.Warning.OperationOnSameValues, []},
99+
{Credo.Check.Warning.OperationWithConstantResult, []},
100+
{Credo.Check.Warning.RaiseInsideRescue, []},
101+
{Credo.Check.Warning.SpecWithStruct, []},
102+
{Credo.Check.Warning.WrongTestFileExtension, []},
103+
{Credo.Check.Warning.UnusedEnumOperation, []},
104+
{Credo.Check.Warning.UnusedFileOperation, []},
105+
{Credo.Check.Warning.UnusedKeywordOperation, []},
106+
{Credo.Check.Warning.UnusedListOperation, []},
107+
{Credo.Check.Warning.UnusedPathOperation, []},
108+
{Credo.Check.Warning.UnusedRegexOperation, []},
109+
{Credo.Check.Warning.UnusedStringOperation, []},
110+
{Credo.Check.Warning.UnusedTupleOperation, []},
111+
{Credo.Check.Warning.UnsafeExec, []}
112+
],
113+
disabled: [
114+
#
115+
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)
116+
117+
#
118+
# Controversial and experimental checks (opt-in, just move the check to `:enabled`
119+
# and be sure to use `mix credo --strict` to see low priority checks)
120+
#
121+
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
122+
{Credo.Check.Consistency.UnusedVariableNames, []},
123+
{Credo.Check.Design.DuplicatedCode, []},
124+
{Credo.Check.Design.SkipTestWithoutComment, []},
125+
{Credo.Check.Readability.AliasAs, []},
126+
{Credo.Check.Readability.BlockPipe, []},
127+
{Credo.Check.Readability.ImplTrue, []},
128+
{Credo.Check.Readability.MultiAlias, []},
129+
{Credo.Check.Readability.NestedFunctionCalls, []},
130+
{Credo.Check.Readability.SeparateAliasRequire, []},
131+
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
132+
{Credo.Check.Readability.SinglePipe, []},
133+
{Credo.Check.Readability.Specs, []},
134+
{Credo.Check.Readability.StrictModuleLayout, []},
135+
{Credo.Check.Readability.WithCustomTaggedTuple, []},
136+
{Credo.Check.Refactor.ABCSize, []},
137+
{Credo.Check.Refactor.AppendSingleItem, []},
138+
{Credo.Check.Refactor.DoubleBooleanNegation, []},
139+
{Credo.Check.Refactor.FilterReject, []},
140+
{Credo.Check.Refactor.IoPuts, []},
141+
{Credo.Check.Refactor.MapMap, []},
142+
{Credo.Check.Refactor.ModuleDependencies, []},
143+
{Credo.Check.Refactor.NegatedIsNil, []},
144+
{Credo.Check.Refactor.PipeChainStart, []},
145+
{Credo.Check.Refactor.RejectFilter, []},
146+
{Credo.Check.Refactor.VariableRebinding, []},
147+
{Credo.Check.Warning.LazyLogging, []},
148+
{Credo.Check.Warning.LeakyEnvironment, []},
149+
{Credo.Check.Warning.MapGetUnsafePass, []},
150+
{Credo.Check.Warning.MixEnv, []},
151+
{Credo.Check.Warning.UnsafeToAtom, []}
152+
153+
# {Credo.Check.Refactor.MapInto, []},
154+
155+
#
156+
# Custom checks can be created using `mix credo.gen.check`.
157+
#
158+
]
159+
}
160+
}
161+
]
162+
}
File renamed without changes.

services/app/Dockerfile.codebattle

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM elixir:1.14.3 AS compile-image
2+
ENV MIX_ENV=prod
3+
4+
WORKDIR /opt/app
5+
6+
RUN mix local.hex --force \
7+
&& mix local.rebar --force
8+
9+
RUN apt-get update \
10+
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
11+
&& apt-get install --no-install-recommends -y nodejs \
12+
&& rm -rf /var/lib/apt/lists/* \
13+
&& npm install --global [email protected]
14+
15+
COPY mix.lock .
16+
COPY mix.exs .
17+
RUN mix do deps.get, compile
18+
19+
COPY package.json .
20+
COPY yarn.lock .
21+
RUN yarn install --froze-lockfile
22+
23+
COPY . .
24+
25+
RUN yarn build && mix phx.digest
26+
27+
RUN mix release codebattle \
28+
&& mv _build/prod/rel/codebattle /opt/release
29+
30+
FROM elixir:1.14.3 AS runtime-image
31+
32+
33+
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates wkhtmltopdf git make curl vim \
34+
&& rm -rf /var/lib/apt/lists/*
35+
36+
ENV PORT=4000
37+
EXPOSE ${PORT}
38+
WORKDIR /opt/app
39+
COPY --from=compile-image /opt/release .
40+
COPY Makefile Makefile
41+
CMD exec /opt/app/bin/codebattle start
File renamed without changes.
Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,14 @@ WORKDIR /opt/app
66
RUN mix local.hex --force \
77
&& mix local.rebar --force
88

9-
RUN apt-get update \
10-
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
11-
&& apt-get install --no-install-recommends -y nodejs \
12-
&& rm -rf /var/lib/apt/lists/* \
13-
&& npm install --global [email protected]
14-
159
COPY mix.lock .
1610
COPY mix.exs .
1711
RUN mix do deps.get, compile
1812

19-
COPY package.json .
20-
COPY yarn.lock .
21-
RUN yarn install --froze-lockfile
22-
2313
COPY . .
2414

25-
RUN yarn build && mix phx.digest
26-
27-
RUN mix release \
28-
&& mv _build/prod/rel/codebattle /opt/release
15+
RUN mix release runner \
16+
&& mv _build/prod/rel/runner /opt/release
2917

3018
FROM elixir:1.14.3 AS runtime-image
3119

@@ -34,7 +22,7 @@ ENV DOCKER_VERSION 20.10.9
3422

3523
ARG DEBIAN_FRONTEND=noninteractive
3624

37-
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates wkhtmltopdf git make curl vim \
25+
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates git make curl vim \
3826
&& rm -rf /var/lib/apt/lists/*
3927

4028
RUN curl -fsSL "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz" \
@@ -46,9 +34,9 @@ RUN curl -fsSL "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_6
4634
# && tar -xzf goon.tar.gz \
4735
# && chmod a+x goon
4836

49-
ENV PORT=4000
37+
ENV PORT=4001
5038
EXPOSE ${PORT}
5139
WORKDIR /opt/app
5240
COPY --from=compile-image /opt/release .
5341
COPY Makefile Makefile
54-
CMD exec /opt/app/bin/codebattle start
42+
CMD exec /opt/app/bin/runner start

0 commit comments

Comments
 (0)