-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from sparrell/develop
version 0.5.0
- Loading branch information
Showing
102 changed files
with
11,934 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
# This file contains the configuration for Credo and you are probably reading | ||
# this after creating it with `mix credo.gen.config`. | ||
# | ||
# If you find anything wrong or unclear in this file, please report an | ||
# issue on GitHub: https://github.com/rrrene/credo/issues | ||
# | ||
%{ | ||
# | ||
# You can have as many configs as you like in the `configs:` field. | ||
configs: [ | ||
%{ | ||
# | ||
# Run any config using `mix credo -C <name>`. If no config name is given | ||
# "default" is used. | ||
# | ||
name: "default", | ||
# | ||
# These are the files included in the analysis: | ||
files: %{ | ||
# | ||
# You can give explicit globs or simply directories. | ||
# In the latter case `**/*.{ex,exs}` will be used. | ||
# | ||
included: [ | ||
"lib/", | ||
"src/", | ||
"test/", | ||
"web/", | ||
"apps/*/lib/", | ||
"apps/*/src/", | ||
"apps/*/test/", | ||
"apps/*/web/" | ||
], | ||
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"] | ||
}, | ||
# | ||
# Load and configure plugins here: | ||
# | ||
plugins: [], | ||
# | ||
# If you create your own checks, you must specify the source files for | ||
# them here, so they can be loaded by Credo before running the analysis. | ||
# | ||
requires: [], | ||
# | ||
# If you want to enforce a style guide and need a more traditional linting | ||
# experience, you can change `strict` to `true` below: | ||
# | ||
strict: false, | ||
# | ||
# To modify the timeout for parsing files, change this value: | ||
# | ||
parse_timeout: 5000, | ||
# | ||
# If you want to use uncolored output by default, you can change `color` | ||
# to `false` below: | ||
# | ||
color: true, | ||
# | ||
# You can customize the parameters of any check by adding a second element | ||
# to the tuple. | ||
# | ||
# To disable a check put `false` as second element: | ||
# | ||
# {Credo.Check.Design.DuplicatedCode, false} | ||
# | ||
checks: [ | ||
# | ||
## Consistency Checks | ||
# | ||
{Credo.Check.Consistency.ExceptionNames, []}, | ||
{Credo.Check.Consistency.LineEndings, []}, | ||
{Credo.Check.Consistency.ParameterPatternMatching, []}, | ||
{Credo.Check.Consistency.SpaceAroundOperators, []}, | ||
{Credo.Check.Consistency.SpaceInParentheses, []}, | ||
{Credo.Check.Consistency.TabsOrSpaces, []}, | ||
|
||
# | ||
## Design Checks | ||
# | ||
# You can customize the priority of any check | ||
# Priority values are: `low, normal, high, higher` | ||
# | ||
{Credo.Check.Design.AliasUsage, | ||
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 2]}, | ||
# You can also customize the exit_status of each check. | ||
# If you don't want TODO comments to cause `mix credo` to fail, just | ||
# set this value to 0 (zero). | ||
# | ||
{Credo.Check.Design.TagTODO, [exit_status: 2]}, | ||
{Credo.Check.Design.TagFIXME, []}, | ||
|
||
# | ||
## Readability Checks | ||
# | ||
{Credo.Check.Readability.AliasOrder, []}, | ||
{Credo.Check.Readability.FunctionNames, []}, | ||
{Credo.Check.Readability.LargeNumbers, []}, | ||
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]}, | ||
{Credo.Check.Readability.ModuleAttributeNames, []}, | ||
{Credo.Check.Readability.ModuleDoc, []}, | ||
{Credo.Check.Readability.ModuleNames, []}, | ||
{Credo.Check.Readability.ParenthesesInCondition, []}, | ||
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []}, | ||
{Credo.Check.Readability.PredicateFunctionNames, []}, | ||
{Credo.Check.Readability.PreferImplicitTry, []}, | ||
{Credo.Check.Readability.RedundantBlankLines, []}, | ||
{Credo.Check.Readability.Semicolons, []}, | ||
{Credo.Check.Readability.SpaceAfterCommas, []}, | ||
{Credo.Check.Readability.StringSigils, []}, | ||
{Credo.Check.Readability.TrailingBlankLine, []}, | ||
{Credo.Check.Readability.TrailingWhiteSpace, []}, | ||
{Credo.Check.Readability.UnnecessaryAliasExpansion, []}, | ||
{Credo.Check.Readability.VariableNames, []}, | ||
|
||
# | ||
## Refactoring Opportunities | ||
# | ||
{Credo.Check.Refactor.CondStatements, []}, | ||
{Credo.Check.Refactor.CyclomaticComplexity, []}, | ||
{Credo.Check.Refactor.FunctionArity, []}, | ||
{Credo.Check.Refactor.LongQuoteBlocks, []}, | ||
{Credo.Check.Refactor.MapInto, []}, | ||
{Credo.Check.Refactor.MatchInCondition, []}, | ||
{Credo.Check.Refactor.NegatedConditionsInUnless, []}, | ||
{Credo.Check.Refactor.NegatedConditionsWithElse, []}, | ||
{Credo.Check.Refactor.Nesting, []}, | ||
{Credo.Check.Refactor.UnlessWithElse, []}, | ||
{Credo.Check.Refactor.WithClauses, []}, | ||
|
||
# | ||
## Warnings | ||
# | ||
{Credo.Check.Warning.BoolOperationOnSameValues, []}, | ||
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []}, | ||
{Credo.Check.Warning.IExPry, []}, | ||
{Credo.Check.Warning.IoInspect, []}, | ||
{Credo.Check.Warning.LazyLogging, []}, | ||
{Credo.Check.Warning.MixEnv, false}, | ||
{Credo.Check.Warning.OperationOnSameValues, []}, | ||
{Credo.Check.Warning.OperationWithConstantResult, []}, | ||
{Credo.Check.Warning.RaiseInsideRescue, []}, | ||
{Credo.Check.Warning.UnusedEnumOperation, []}, | ||
{Credo.Check.Warning.UnusedFileOperation, []}, | ||
{Credo.Check.Warning.UnusedKeywordOperation, []}, | ||
{Credo.Check.Warning.UnusedListOperation, []}, | ||
{Credo.Check.Warning.UnusedPathOperation, []}, | ||
{Credo.Check.Warning.UnusedRegexOperation, []}, | ||
{Credo.Check.Warning.UnusedStringOperation, []}, | ||
{Credo.Check.Warning.UnusedTupleOperation, []}, | ||
{Credo.Check.Warning.UnsafeExec, []}, | ||
|
||
# | ||
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`) | ||
|
||
# | ||
# Controversial and experimental checks (opt-in, just replace `false` with `[]`) | ||
# | ||
{Credo.Check.Readability.StrictModuleLayout, false}, | ||
{Credo.Check.Consistency.MultiAliasImportRequireUse, false}, | ||
{Credo.Check.Consistency.UnusedVariableNames, false}, | ||
{Credo.Check.Design.DuplicatedCode, false}, | ||
{Credo.Check.Readability.AliasAs, false}, | ||
{Credo.Check.Readability.MultiAlias, false}, | ||
{Credo.Check.Readability.Specs, false}, | ||
{Credo.Check.Readability.SinglePipe, false}, | ||
{Credo.Check.Readability.WithCustomTaggedTuple, false}, | ||
{Credo.Check.Refactor.ABCSize, false}, | ||
{Credo.Check.Refactor.AppendSingleItem, false}, | ||
{Credo.Check.Refactor.DoubleBooleanNegation, false}, | ||
{Credo.Check.Refactor.ModuleDependencies, false}, | ||
{Credo.Check.Refactor.NegatedIsNil, false}, | ||
{Credo.Check.Refactor.PipeChainStart, false}, | ||
{Credo.Check.Refactor.VariableRebinding, false}, | ||
{Credo.Check.Warning.LeakyEnvironment, false}, | ||
{Credo.Check.Warning.MapGetUnsafePass, false}, | ||
{Credo.Check.Warning.UnsafeToAtom, false} | ||
|
||
# | ||
# Custom checks can be created using `mix credo.gen.check`. | ||
# | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
_build/ | ||
assets/node_modules/ | ||
deps/ | ||
doc/ | ||
docs/ | ||
priv/static/ | ||
test/ | ||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export CLIENT_ID=:sfractal2020 | ||
export MQTT_HOST=mqtt.sfractal.com | ||
export MQTT_PORT=1883 | ||
export USER_NAME=plug | ||
export PASSWORD=fest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
import_deps: [:ecto, :phoenix], | ||
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"], | ||
subdirectories: ["priv/*/migrations"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Elixir CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- develop | ||
|
||
jobs: | ||
lint: | ||
|
||
name: Run test and check code styles | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
db: | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: postgres | ||
image: postgres:11 | ||
ports: ['5432:5432'] | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Elixir | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
elixir-version: '1.10.4' # Define the elixir version [required] | ||
otp-version: '22.3' # Define the OTP version [required] | ||
- name: Restore dependencies cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | ||
restore-keys: ${{ runner.os }}-mix- | ||
- name: Install dependencies | ||
run: mix deps.get | ||
- name: Run tests | ||
run: mix test | ||
env: | ||
CLIENT_ID: :sfractal2020 | ||
MQTT_HOST: mqtt.sfractal.com | ||
MQTT_PORT: 1883 | ||
USER_NAME: plug | ||
PASSWORD: fest | ||
- name: Check lints | ||
run: make lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
/_build | ||
/cover | ||
/deps | ||
/doc | ||
/_build/ | ||
/cover/ | ||
/deps/ | ||
/doc/ | ||
/.fetch | ||
erl_crash.dump | ||
*.ez | ||
*.beam | ||
twinkly_maha-*.tar | ||
npm-debug.log | ||
/assets/node_modules/ | ||
/priv/static/ | ||
/config/*.secret.exs | ||
.elixir_ls/ | ||
.elixir_ls/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
deploy_to_production: | ||
image: elixir:1.10.3 | ||
|
||
stage: deploy | ||
before_script: | ||
- mix local.rebar --force | ||
- mix local.hex --force | ||
- apt update -y > /dev/null && apt install nodejs npm -y > /dev/null | ||
- npm i -g webpack webpack-cli | ||
|
||
script: | ||
- export APP_NAME="$(grep 'app:' mix.exs | sed -e 's/\[//g' -e 's/ //g' -e 's/app://' -e 's/[:,]//g')" | ||
- export APP_VSN="$(grep 'version:' mix.exs | cut -d '"' -f2)" | ||
- export CURRENT_APP=$APP_NAME-$APP_VSN | ||
- echo "$PRODSECRETS" > config/prod.secret.exs | ||
- make release | ||
- eval $(ssh-agent -s) | ||
- ssh-add <(echo "$PROD_SSH_KEY") | ||
- scp -T -o StrictHostKeyChecking=no "_build/prod/$CURRENT_APP.tar.gz" sigumagwa@$PROD_IP:/home/sigumagwa/$CURRENT_APP.tar.gz | ||
- ssh -T -o StrictHostKeyChecking=no sigumagwa@$PROD_IP <<EOF | ||
- rm -rf $CURRENT_APP | ||
- mkdir $CURRENT_APP | ||
- tar -xzf $CURRENT_APP.tar.gz --strip-components=0 -C $CURRENT_APP | ||
- cd $CURRENT_APP | ||
- bin/$APP_NAME stop || bin/$APP_NAME daemon | ||
- bin/$APP_NAME eval "TwinklyMaha.Release.migrate" | ||
- bin/$APP_NAME daemon | ||
- EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
elixir 1.10.4-otp-22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# heavily borrowed from https://elixirforum.com/t/cannot-find-libtinfo-so-6-when-launching-elixir-app/24101/11?u=sigu | ||
FROM elixir:1.10.4 AS app_builder | ||
|
||
ARG env=prod | ||
|
||
ENV LANG=C.UTF-8 \ | ||
TERM=xterm \ | ||
MIX_ENV=$env | ||
|
||
RUN mkdir /opt/release | ||
WORKDIR /opt/release | ||
|
||
RUN mix local.hex --force && mix local.rebar --force | ||
|
||
COPY mix.exs . | ||
COPY mix.lock . | ||
RUN mix deps.get && mix deps.compile | ||
|
||
# Let's make sure we have node | ||
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ | ||
apt-get install -y nodejs | ||
|
||
# Compile assets | ||
COPY assets ./assets | ||
RUN npm install --prefix ./assets && \ | ||
npm run deploy --prefix ./assets | ||
|
||
# Now, let's go with the actual elixir code. The order matters: if we only | ||
# change elixir code, all the above layers will be cached ~ less image build time. | ||
COPY config ./config | ||
COPY lib ./lib | ||
COPY priv ./priv | ||
|
||
# Final build step: digest static assets and generate the release | ||
RUN mix phx.digest && mix release | ||
|
||
FROM debian:buster-slim AS app | ||
|
||
ARG CLIENT_ID=:sfractal2020 | ||
ARG MQTT_HOST=35.184.192.117 | ||
ARG MQTT_PORT=1883 | ||
ARG USER_NAME=plug | ||
ARG PASSWORD=fest | ||
|
||
|
||
ENV LANG=C.UTF-8 | ||
ENV CLIENT_ID=$CLIENT_ID | ||
ENV MQTT_HOST=$CLIENT_ID | ||
ENV MQTT_PORT=$MQTT_PORT | ||
ENV USER_NAME=$USER_NAME | ||
ENV PASSWORD=$PASSWORD | ||
|
||
RUN apt-get update && apt-get install -y openssl | ||
|
||
RUN useradd --create-home app | ||
WORKDIR /home/app | ||
COPY --from=app_builder /opt/release/_build . | ||
RUN chown -R app: ./prod | ||
USER app | ||
|
||
CMD ["./prod/rel/twinkly_maha/bin/twinkly_maha", "start"] |
Oops, something went wrong.