Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ci #44

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Coveralls

on: push

jobs:
coveralls:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-coveralls-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-coveralls-
- uses: erlef/setup-beam@v1
with:
otp-version: 25.1.2
elixir-version: 1.14.2

- run: mix deps.get

- run: MIX_ENV=test mix coveralls.json

- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

23 changes: 23 additions & 0 deletions .github/workflows/credo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Credo

on: push

jobs:
credo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-credo-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-credo-
- uses: erlef/setup-beam@v1
with:
otp-version: 25.1.2
elixir-version: 1.14.2
- run: mix deps.get
- run: mix credo
25 changes: 25 additions & 0 deletions .github/workflows/dialyzer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Dialyzer

on: push

jobs:
dialyzer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
deps
_build
dialyzer
key: ${{ runner.os }}-mix-dialyzer-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-dialyzer-
- uses: erlef/setup-beam@v1
with:
otp-version: 25.1.2
elixir-version: 1.14.2
- run: mix deps.get
- run: mix dialyzer

13 changes: 13 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
coverage:
status:
project:
default:
target: 20%
threshold: 0%
base: auto
patch:
default:
target: 60%
threshold: 2%
base: auto

133 changes: 133 additions & 0 deletions credo.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
allowed_imports = [
[:Ecto]
]

%{
configs: [
%{
name: "default",
files: %{
included: [
"lib/",
"src/",
"test/",
"web/",
"apps/*/lib/",
"apps/*/src/",
"apps/*/test/",
"apps/*/web/"
],
excluded: [~r"_build/", ~r"deps/"]
},
plugins: [],
requires: ["deps/blitz_credo/lib/blitz_credo/"],
strict: true,
parse_timeout: 10000,
color: true,
checks: [

# BlitzCredoChecks

{BlitzCredoChecks.SetWarningsAsErrorsInTest, false},
{BlitzCredoChecks.DocsBeforeSpecs, []},
{BlitzCredoChecks.DoctestIndent, []},
{BlitzCredoChecks.NoAsyncFalse, []},
{BlitzCredoChecks.NoDSLParentheses, []},
{BlitzCredoChecks.NoIsBitstring, []},
{BlitzCredoChecks.StrictComparison, []},
{BlitzCredoChecks.LowercaseTestNames, []},
{BlitzCredoChecks.ImproperImport, allowed_modules: allowed_imports},

# 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
{Credo.Check.Design.AliasUsage, false},

# No outstanding TODOs
{Credo.Check.Design.TagTODO, []},
{Credo.Check.Design.TagFIXME, []},

# # Readability Checks
{Credo.Check.Readability.AliasOrder, false},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength, [max_length: 120]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, false},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, false},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SpaceAfterCommas, false},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, false},
{Credo.Check.Readability.TrailingWhiteSpace, false},
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
{Credo.Check.Readability.VariableNames, []},
#
# Refactoring Opportunities
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, false},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, false},
{Credo.Check.Refactor.MapInto, false},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, false},
{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, false},
{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, []},

# Controversial and experimental checks
{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, []},
{Credo.Check.Readability.WithCustomTaggedTuple, []},
{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, []},
{Credo.Check.Refactor.VariableRebinding, false},
{Credo.Check.Warning.LeakyEnvironment, false},
{Credo.Check.Warning.MapGetUnsafePass, false},
{Credo.Check.Warning.UnsafeToAtom, false}
]
}
]
}
4 changes: 1 addition & 3 deletions lib/actions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@


def update(schema, schema_data, updates, opts) do
with {:ok, schema_data} <- repo!(opts).update(schema.changeset(schema_data, updates), opts) do
{:ok, schema_data}
end
repo!(opts).update(schema.changeset(schema_data, updates), opts)

Check warning on line 321 in lib/actions.ex

View check run for this annotation

Codecov / codecov/patch

lib/actions.ex#L321

Added line #L321 was not covered by tests
end

@doc """
Expand Down
4 changes: 2 additions & 2 deletions lib/common_changes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@moduledoc """
This module is responsible for determining put/cast assoc as well as creating and updating model relations
"""
import Logger, only: [warn: 1]
require Logger

import Ecto.Changeset, only: [
get_field: 2,
Expand Down Expand Up @@ -108,7 +108,7 @@
|> elem(1)
|> Map.get(:queryable)
else
warn "Changeset relationship for CommonChanges.put_or_cast_assoc #{key} was not found"
Logger.warning("Changeset relationship for CommonChanges.put_or_cast_assoc #{key} was not found")

Check warning on line 111 in lib/common_changes.ex

View check run for this annotation

Codecov / codecov/patch

lib/common_changes.ex#L111

Added line #L111 was not covered by tests

changeset
end
Expand Down
2 changes: 2 additions & 0 deletions lib/config.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
defmodule EctoShorts.Config do
@moduledoc false

@app :ecto_shorts

def repo do
Expand Down
22 changes: 19 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@ defmodule EctoShorts.MixProject do
[
app: :ecto_shorts,
version: "2.3.0",
elixir: "~> 1.7",
elixir: "~> 1.11",
start_permanent: Mix.env() == :prod,
deps: deps(),
description: "Helper tools for making ecto interactions more pleasant and shorter",
docs: docs(),
package: package(),
elixirc_paths: elixirc_paths(Mix.env()),
test_coverage: [tool: ExCoveralls],

preferred_cli_env: [
dialyzer: :test
],
coveralls: :test,
doctor: :test,
coverage: :test,
dialyzer: :test,
"coveralls.lcov": :test,
"coveralls.json": :test,
"coveralls.html": :test
],

dialyzer: [
plt_add_apps: [:ex_unit, :mix],
plt_ignore_apps: [:ecto_shorts],
Expand All @@ -36,11 +46,17 @@ defmodule EctoShorts.MixProject do
[
{:ecto_sql, "~> 3.10"},
{:error_message, "~> 0.1"},

{:credo, ">= 0.0.0", only: [:dev, :test]},
{:excoveralls, ">= 0.0.0", only: [:dev, :test]},
{:ex_doc, ">= 0.0.0", only: :dev},
{:dialyxir, "~> 1.1", only: :test, runtime: false}
]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]

defp package do
[
maintainers: ["Mika Kalathil"],
Expand Down
Loading