Skip to content
Draft
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
2 changes: 0 additions & 2 deletions .codespellignore

This file was deleted.

187 changes: 187 additions & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# 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/", "test/"],
excluded: [~r"/_build/", ~r"/deps/"]
},
#
# 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: to_timeout(second: 5),
#
# 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: %{
enabled: [
#
## Consistency Checks
#
{Credo.Check.Consistency.ExceptionNames, []},
{Credo.Check.Consistency.LineEndings, []},
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
{Credo.Check.Consistency.ParameterPatternMatching, []},
{Credo.Check.Consistency.SpaceAroundOperators, []},
{Credo.Check.Consistency.SpaceInParentheses, []},
{Credo.Check.Consistency.TabsOrSpaces, []},

#
## Design Checks
#
{Credo.Check.Design.DuplicatedCode, files: %{included: "lib/"}},
{Credo.Check.Design.SkipTestWithoutComment, []},
{Credo.Check.Design.TagFIXME, []},
{Credo.Check.Design.TagTODO, exit_status: 2},

#
## Readability Checks
#
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.BlockPipe, []},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.ImplTrue, []},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 120},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.NestedFunctionCalls, min_pipeline_length: 3},
{Credo.Check.Readability.OneArityFunctionInPipe, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, []},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SeparateAliasRequire, []},
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
{Credo.Check.Readability.SinglePipe, []},
{Credo.Check.Readability.SpaceAfterCommas, []},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
{Credo.Check.Readability.VariableNames, []},
{Credo.Check.Readability.WithCustomTaggedTuple, []},
{Credo.Check.Readability.WithSingleClause, []},

#
## Refactoring Opportunities
#
{Credo.Check.Refactor.AppendSingleItem, []},
{Credo.Check.Refactor.Apply, []},
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.DoubleBooleanNegation, []},
{Credo.Check.Refactor.FilterCount, []},
{Credo.Check.Refactor.FilterFilter, []},
{Credo.Check.Refactor.FilterReject, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.IoPuts, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
{Credo.Check.Refactor.MapJoin, []},
{Credo.Check.Refactor.MapMap, []},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.NegatedIsNil, []},
{Credo.Check.Refactor.PassAsyncInTestCases, []},
{Credo.Check.Refactor.RedundantWithClauseResult, []},
{Credo.Check.Refactor.RejectFilter, []},
{Credo.Check.Refactor.RejectReject, []},
{Credo.Check.Refactor.UnlessWithElse, []},
{Credo.Check.Refactor.UtcNowTruncate, []},
{Credo.Check.Refactor.WithClauses, []},

#
## Warnings
#
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.Dbg, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
{Credo.Check.Warning.IoInspect, []},
{Credo.Check.Warning.LeakyEnvironment, []},
{Credo.Check.Warning.MapGetUnsafePass, []},
{Credo.Check.Warning.MissedMetadataKeyInLoggerConfig, []},
{Credo.Check.Warning.MixEnv, []},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.RaiseInsideRescue, []},
{Credo.Check.Warning.SpecWithStruct, []},
{Credo.Check.Warning.UnsafeExec, []},
{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.WrongTestFileExtension, []}
],
disabled: [
{Credo.Check.Warning.LazyLogging, []},
{Credo.Check.Warning.UnsafeToAtom, []},
{Credo.Check.Readability.OnePipePerLine, []},
{Credo.Check.Readability.MultiAlias, []},
{Credo.Check.Readability.StrictModuleLayout, []},
{Credo.Check.Refactor.ABCSize, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.MapInto, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.VariableRebinding, []},
{Credo.Check.Refactor.PipeChainStart, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Consistency.UnusedVariableNames, []},
{Credo.Check.Readability.Specs, []},
{Credo.Check.Readability.AliasAs, []},
{Credo.Check.Refactor.ModuleDependencies, []}
]
}
}
]
}
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test,bench}/**/*.{ex,exs}"]
inputs: ["{mix,.credo,.formatter}.exs", "{config,lib,test,bench,pages}/**/*.{ex,exs}"]
]
69 changes: 39 additions & 30 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,63 @@
name: bench

on:
workflow_dispatch:
push:
branches: [master]
schedule:
- cron: "42 9 * * *"
- cron: "42 10 * * *"
workflow_dispatch:

# Write access is needed to push benchmark data to gh-pages.
# This workflow intentionally does NOT run on pull_request to avoid
# granting write permissions to untrusted forks.
permissions:
contents: write

jobs:
benchee:
bench:
name: Benchmarks
runs-on: ubuntu-latest

env:
MIX_ENV: bench

services:
clickhouse:
image: clickhouse/clickhouse-server:latest
ports:
- 8123:8123
env:
# https://github.com/ClickHouse/ClickHouse/issues/75494
CLICKHOUSE_SKIP_USER_SETUP: 1
options: >-
--health-cmd nc -zw3 localhost 8124
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4

- id: beam
uses: erlef/setup-beam@v1
with:
elixir-version: 1.18
otp-version: 28
elixir-version: "1.19"
otp-version: "28"

- uses: actions/cache@v5
- name: Restore deps cache
uses: actions/cache@v4
with:
path: |
deps
_build
key: bench-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ github.head_ref || github.ref }}-${{ hashFiles('**/mix.lock') }}
key: bench-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
bench-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ github.head_ref || github.ref }}-
bench-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-refs/heads/master-
bench-${{ steps.beam.outputs.elixir-version }}-

- run: mix deps.get --only $MIX_ENV
- run: mix compile --warnings-as-errors
- run: mix deps.get

# - run: mix run bench/cast.exs
- run: mix run bench/encode.exs
- run: mix run bench/insert.exs
- run: mix run bench/stream.exs
- run: mix benchee_github.clean

- run: mix run bench/ci.exs

- name: Store benchmark results
uses: benchmark-action/github-action-benchmark@v1
with:
name: Ch RowBinary
tool: customSmallerIsBetter
output-file-path: bench_output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
gh-pages-branch: gh-pages
benchmark-data-dir-path: benchmarks
# Alert on >20% regression compared to previous run on master
alert-threshold: "120%"
comment-on-alert: true
fail-on-alert: false
summary-always: true
33 changes: 8 additions & 25 deletions .github/workflows/test.yml → .github/workflows/mix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
test:
name: "test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }} / ClickHouse ${{ matrix.clickhouse || 'latest' }} / TZ ${{ matrix.timezone || 'UTC' }}${{ matrix.dialyzer && ' / Dialyzer' || '' }}${{ matrix.lint && ' / Lint' || '' }})"
name: "test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }} / ClickHouse ${{ matrix.clickhouse || 'latest' }}${{ matrix.dialyzer && ' / Dialyzer' || '' }}${{ matrix.lint && ' / Lint' || '' }})"
runs-on: ubuntu-latest

env:
Expand All @@ -19,41 +19,18 @@ jobs:
strategy:
matrix:
include:
# some old elixir/erlang version
- elixir: 1.15
otp: 25

# some recent version and non-UTC timezone
- elixir: 1.18
otp: 27
timezone: Europe/Berlin

# the latest elixir/erlang version with all static checks
- elixir: 1.19
otp: 28
dialyzer: true
lint: true

# Plausible versions
# - https://github.com/plausible/analytics/blob/master/.tool-versions
# - https://github.com/plausible/analytics/blob/master/.github/workflows/elixir.yml
- elixir: 1.19.4
otp: 27.3.4.6
clickhouse: 25.11.5.8

# some older pre-JSON ClickHouse version
# https://github.com/plausible/ch/issues/273
- elixir: 1.18
otp: 28
clickhouse: 24.5.4.49

services:
clickhouse:
image: clickhouse/clickhouse-server:${{ matrix.clickhouse || 'latest' }}
ports:
- 8123:8123
env:
TZ: ${{ matrix.timezone || 'UTC' }}
# https://github.com/ClickHouse/ClickHouse/issues/75494
CLICKHOUSE_SKIP_USER_SETUP: 1
options: >-
Expand Down Expand Up @@ -96,7 +73,10 @@ jobs:
- run: mix format --check-formatted
if: ${{ matrix.lint }}

- run: mix test --include slow
- run: mix credo --strict
if: ${{ matrix.lint }}

- run: mix test

- name: Restore PLTs cache
if: ${{ matrix.dialyzer }}
Expand All @@ -109,3 +89,6 @@ jobs:

- run: mix dialyzer --format github
if: ${{ matrix.dialyzer }}

- uses: crate-ci/typos@master
if: ${{ matrix.lint }}
22 changes: 0 additions & 22 deletions .github/workflows/spellcheck.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ ch-*.tar

# Dialyzer PLTs
/plts/

# Generated docs.
pages/telemetry-events.md
1 change: 0 additions & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[default.extend-words]
"som" = "som" # ./test/ch/ecto_type_test.exs
"ECT" = "ECT" # ./test/ch/query_test.exs
"Evn" = "Evn" # ./CHANGELOG.md
Loading