Skip to content

Commit b3bf10f

Browse files
authored
Merge pull request #10 from s3cur3/master
Add support for a number of new TLDs This takes the changes I've been using in production on [SleepEasy](https://www.sleepeasy.app). It adds support for the following new TLDs: - .se - .no - .de - .im - .africa - .io - .com.au - .com.br It also adds a number of GitHub Actions checks: - code quality (checking formatting, some basic Credo rules, and Dialyzer) - compilation without warnings - unit testing It also bumps the minimum Elixir version to 1.12.
2 parents 1485ff7 + 44b48e4 commit b3bf10f

35 files changed

+1585
-446
lines changed

.credo.exs

+216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# This file contains the configuration for Credo and you are probably reading
2+
# this after creating it with `mix credo.gen.config`.
3+
#
4+
# If you find anything wrong or unclear in this file, please report an
5+
# issue on GitHub: https://github.com/rrrene/credo/issues
6+
#
7+
%{
8+
#
9+
# You can have as many configs as you like in the `configs:` field.
10+
configs: [
11+
%{
12+
#
13+
# Run any config using `mix credo -C <name>`. If no config name is given
14+
# "default" is used.
15+
#
16+
name: "default",
17+
#
18+
# These are the files included in the analysis:
19+
files: %{
20+
#
21+
# You can give explicit globs or simply directories.
22+
# In the latter case `**/*.{ex,exs}` will be used.
23+
#
24+
included: [
25+
"lib/",
26+
"src/",
27+
"test/",
28+
"web/",
29+
"apps/*/lib/",
30+
"apps/*/src/",
31+
"apps/*/test/",
32+
"apps/*/web/"
33+
],
34+
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
35+
},
36+
#
37+
# Load and configure plugins here:
38+
#
39+
plugins: [],
40+
#
41+
# If you create your own checks, you must specify the source files for
42+
# them here, so they can be loaded by Credo before running the analysis.
43+
#
44+
requires: [],
45+
#
46+
# If you want to enforce a style guide and need a more traditional linting
47+
# experience, you can change `strict` to `true` below:
48+
#
49+
strict: false,
50+
#
51+
# To modify the timeout for parsing files, change this value:
52+
#
53+
parse_timeout: 5000,
54+
#
55+
# If you want to use uncolored output by default, you can change `color`
56+
# to `false` below:
57+
#
58+
color: true,
59+
#
60+
# You can customize the parameters of any check by adding a second element
61+
# to the tuple.
62+
#
63+
# To disable a check put `false` as second element:
64+
#
65+
# {Credo.Check.Design.DuplicatedCode, false}
66+
#
67+
checks: %{
68+
enabled: [
69+
#
70+
## Consistency Checks
71+
#
72+
{Credo.Check.Consistency.ExceptionNames, []},
73+
{Credo.Check.Consistency.LineEndings, []},
74+
{Credo.Check.Consistency.ParameterPatternMatching, []},
75+
{Credo.Check.Consistency.SpaceAroundOperators, []},
76+
{Credo.Check.Consistency.SpaceInParentheses, []},
77+
{Credo.Check.Consistency.TabsOrSpaces, []},
78+
79+
#
80+
## Design Checks
81+
#
82+
# You can customize the priority of any check
83+
# Priority values are: `low, normal, high, higher`
84+
#
85+
{Credo.Check.Design.AliasUsage,
86+
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
87+
{Credo.Check.Design.TagFIXME, []},
88+
# You can also customize the exit_status of each check.
89+
# If you don't want TODO comments to cause `mix credo` to fail, just
90+
# set this value to 0 (zero).
91+
#
92+
{Credo.Check.Design.TagTODO, [exit_status: 2]},
93+
94+
#
95+
## Readability Checks
96+
#
97+
{Credo.Check.Readability.AliasOrder, []},
98+
{Credo.Check.Readability.FunctionNames, []},
99+
{Credo.Check.Readability.LargeNumbers, []},
100+
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
101+
{Credo.Check.Readability.ModuleAttributeNames, []},
102+
{Credo.Check.Readability.ModuleDoc, []},
103+
{Credo.Check.Readability.ModuleNames, []},
104+
{Credo.Check.Readability.ParenthesesInCondition, []},
105+
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
106+
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
107+
{Credo.Check.Readability.PredicateFunctionNames, []},
108+
{Credo.Check.Readability.PreferImplicitTry, []},
109+
{Credo.Check.Readability.RedundantBlankLines, []},
110+
{Credo.Check.Readability.Semicolons, []},
111+
{Credo.Check.Readability.SpaceAfterCommas, []},
112+
{Credo.Check.Readability.StringSigils, []},
113+
{Credo.Check.Readability.TrailingBlankLine, []},
114+
{Credo.Check.Readability.TrailingWhiteSpace, []},
115+
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
116+
{Credo.Check.Readability.VariableNames, []},
117+
{Credo.Check.Readability.WithSingleClause, []},
118+
119+
#
120+
## Refactoring Opportunities
121+
#
122+
{Credo.Check.Refactor.Apply, []},
123+
{Credo.Check.Refactor.CondStatements, []},
124+
{Credo.Check.Refactor.CyclomaticComplexity, false},
125+
{Credo.Check.Refactor.FilterCount, []},
126+
{Credo.Check.Refactor.FilterFilter, []},
127+
{Credo.Check.Refactor.FunctionArity, []},
128+
{Credo.Check.Refactor.LongQuoteBlocks, []},
129+
{Credo.Check.Refactor.MapJoin, []},
130+
{Credo.Check.Refactor.MatchInCondition, []},
131+
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
132+
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
133+
{Credo.Check.Refactor.Nesting, false},
134+
{Credo.Check.Refactor.RedundantWithClauseResult, []},
135+
{Credo.Check.Refactor.RejectReject, []},
136+
{Credo.Check.Refactor.UnlessWithElse, []},
137+
{Credo.Check.Refactor.WithClauses, []},
138+
139+
#
140+
## Warnings
141+
#
142+
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
143+
{Credo.Check.Warning.BoolOperationOnSameValues, []},
144+
{Credo.Check.Warning.Dbg, []},
145+
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
146+
{Credo.Check.Warning.IExPry, []},
147+
{Credo.Check.Warning.IoInspect, []},
148+
{Credo.Check.Warning.MissedMetadataKeyInLoggerConfig, []},
149+
{Credo.Check.Warning.OperationOnSameValues, []},
150+
{Credo.Check.Warning.OperationWithConstantResult, []},
151+
{Credo.Check.Warning.RaiseInsideRescue, []},
152+
{Credo.Check.Warning.SpecWithStruct, []},
153+
{Credo.Check.Warning.UnsafeExec, []},
154+
{Credo.Check.Warning.UnusedEnumOperation, []},
155+
{Credo.Check.Warning.UnusedFileOperation, []},
156+
{Credo.Check.Warning.UnusedKeywordOperation, []},
157+
{Credo.Check.Warning.UnusedListOperation, []},
158+
{Credo.Check.Warning.UnusedPathOperation, []},
159+
{Credo.Check.Warning.UnusedRegexOperation, []},
160+
{Credo.Check.Warning.UnusedStringOperation, []},
161+
{Credo.Check.Warning.UnusedTupleOperation, []},
162+
{Credo.Check.Warning.WrongTestFileExtension, []}
163+
],
164+
disabled: [
165+
#
166+
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)
167+
168+
#
169+
# Controversial and experimental checks (opt-in, just move the check to `:enabled`
170+
# and be sure to use `mix credo --strict` to see low priority checks)
171+
#
172+
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
173+
{Credo.Check.Consistency.UnusedVariableNames, []},
174+
{Credo.Check.Design.DuplicatedCode, []},
175+
{Credo.Check.Design.SkipTestWithoutComment, []},
176+
{Credo.Check.Readability.AliasAs, []},
177+
{Credo.Check.Readability.BlockPipe, []},
178+
{Credo.Check.Readability.ImplTrue, []},
179+
{Credo.Check.Readability.MultiAlias, []},
180+
{Credo.Check.Readability.NestedFunctionCalls, []},
181+
{Credo.Check.Readability.OneArityFunctionInPipe, []},
182+
{Credo.Check.Readability.OnePipePerLine, []},
183+
{Credo.Check.Readability.SeparateAliasRequire, []},
184+
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
185+
{Credo.Check.Readability.SinglePipe, []},
186+
{Credo.Check.Readability.Specs, []},
187+
{Credo.Check.Readability.StrictModuleLayout, []},
188+
{Credo.Check.Readability.WithCustomTaggedTuple, []},
189+
{Credo.Check.Refactor.ABCSize, []},
190+
{Credo.Check.Refactor.AppendSingleItem, []},
191+
{Credo.Check.Refactor.DoubleBooleanNegation, []},
192+
{Credo.Check.Refactor.FilterReject, []},
193+
{Credo.Check.Refactor.IoPuts, []},
194+
{Credo.Check.Refactor.MapMap, []},
195+
{Credo.Check.Refactor.ModuleDependencies, []},
196+
{Credo.Check.Refactor.NegatedIsNil, []},
197+
{Credo.Check.Refactor.PassAsyncInTestCases, []},
198+
{Credo.Check.Refactor.PipeChainStart, []},
199+
{Credo.Check.Refactor.RejectFilter, []},
200+
{Credo.Check.Refactor.VariableRebinding, []},
201+
{Credo.Check.Warning.LazyLogging, []},
202+
{Credo.Check.Warning.LeakyEnvironment, []},
203+
{Credo.Check.Warning.MapGetUnsafePass, []},
204+
{Credo.Check.Warning.MixEnv, []},
205+
{Credo.Check.Warning.UnsafeToAtom, []}
206+
207+
# {Credo.Check.Refactor.MapInto, []},
208+
209+
#
210+
# Custom checks can be created using `mix credo.gen.check`.
211+
#
212+
]
213+
}
214+
}
215+
]
216+
}

.formatter.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
inputs: [
3-
"{lib,unicode,test}/**/*.{ex,exs}",
3+
"{lib,config,test}/**/*.{ex,exs}",
44
"*.exs",
55
".*.exs"
66
]
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Setup Elixir Project
2+
description: Checks out the code, configures Elixir, fetches dependencies, and manages build caching.
3+
inputs:
4+
elixir-version:
5+
required: true
6+
type: string
7+
description: Elixir version to set up
8+
otp-version:
9+
required: true
10+
type: string
11+
description: OTP version to set up
12+
#################################################################
13+
# Everything below this line is optional.
14+
#
15+
# It's designed to make compiling a reasonably standard Elixir
16+
# codebase "just work," though there may be speed gains to be had
17+
# by tweaking these flags.
18+
#################################################################
19+
build-deps:
20+
required: false
21+
type: boolean
22+
default: true
23+
description: True if we should compile dependencies
24+
build-app:
25+
required: false
26+
type: boolean
27+
default: true
28+
description: True if we should compile the application itself
29+
build-flags:
30+
required: false
31+
type: string
32+
default: '--all-warnings'
33+
description: Flags to pass to mix compile
34+
install-rebar:
35+
required: false
36+
type: boolean
37+
default: true
38+
description: By default, we will install Rebar (mix local.rebar --force).
39+
install-hex:
40+
required: false
41+
type: boolean
42+
default: true
43+
description: By default, we will install Hex (mix local.hex --force).
44+
cache-key:
45+
required: false
46+
type: string
47+
default: 'v1'
48+
description: If you need to reset the cache for some reason, you can change this key.
49+
outputs:
50+
otp-version:
51+
description: "Exact OTP version selected by the BEAM setup step"
52+
value: ${{ steps.beam.outputs.otp-version }}
53+
elixir-version:
54+
description: "Exact Elixir version selected by the BEAM setup step"
55+
value: ${{ steps.beam.outputs.elixir-version }}
56+
runs:
57+
using: "composite"
58+
steps:
59+
- name: Setup elixir
60+
uses: erlef/setup-beam@v1
61+
id: beam
62+
with:
63+
elixir-version: ${{ inputs.elixir-version }}
64+
otp-version: ${{ inputs.otp-version }}
65+
66+
- name: Get deps cache
67+
uses: actions/cache@v2
68+
with:
69+
path: deps/
70+
key: deps-${{ inputs.cache-key }}-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}
71+
restore-keys: |
72+
deps-${{ inputs.cache-key }}-${{ runner.os }}-
73+
74+
- name: Get build cache
75+
uses: actions/cache@v2
76+
id: build-cache
77+
with:
78+
path: _build/${{env.MIX_ENV}}/
79+
key: build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-${{ hashFiles('**/mix.lock') }}
80+
restore-keys: |
81+
build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-
82+
83+
- name: Get Hex cache
84+
uses: actions/cache@v2
85+
id: hex-cache
86+
with:
87+
path: ~/.hex
88+
key: build-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
89+
restore-keys: |
90+
build-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-
91+
92+
# In my experience, I have issues with incremental builds maybe 1 in 100
93+
# times that are fixed by doing a full recompile.
94+
# In order to not waste dev time on such trivial issues (while also reaping
95+
# the time savings of incremental builds for *most* day-to-day development),
96+
# I force a full recompile only on builds that we retry.
97+
- name: Clean to rule out incremental build as a source of flakiness
98+
if: github.run_attempt != '1'
99+
run: |
100+
mix deps.clean --all
101+
mix clean
102+
shell: sh
103+
104+
- name: Install Rebar
105+
run: mix local.rebar --force
106+
shell: sh
107+
if: inputs.install-rebar == 'true'
108+
109+
- name: Install Hex
110+
run: mix local.hex --force
111+
shell: sh
112+
if: inputs.install-hex == 'true'
113+
114+
- name: Install Dependencies
115+
run: mix deps.get
116+
shell: sh
117+
118+
# Normally we'd use `mix deps.compile` here, however that incurs a large
119+
# performance penalty when the dependencies are already fully compiled:
120+
# https://elixirforum.com/t/github-action-cache-elixir-always-recompiles-dependencies-elixir-1-13-3/45994/12
121+
#
122+
# Accoring to Jose Valim at the above link `mix loadpaths` will check and
123+
# compile missing dependencies
124+
- name: Compile Dependencies
125+
run: mix loadpaths
126+
shell: sh
127+
if: inputs.build-deps == 'true'
128+
129+
- name: Compile Application
130+
run: mix compile ${{ inputs.build-flags }}
131+
shell: sh
132+
if: inputs.build-app == 'true'

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: mix
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "12:00"
8+
open-pull-requests-limit: 10

0 commit comments

Comments
 (0)