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

Fix Github Actions and use PropEr github revision #224

Merged
merged 15 commits into from
Nov 28, 2023
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
60 changes: 21 additions & 39 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,18 @@ jobs:
# WARNING:
# Changing the naming pattern requires changes in the branch protection
# at GitHub, the name of jobs are referenced there!
name: lint (Elixir ${{ matrix.elixir }} OTP ${{ matrix.otp }})

runs-on: ubuntu-latest

name: lint (Elixir ${{ matrix.pair.elixir }} OTP ${{ matrix.pair.otp }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- elixir: 1.9.4
otp: 22.3.4

pair:
- { erlang: "26", elixir: "1.15", latest: true }
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
otp-version: "26"
elixir-version: "1.15"
- uses: actions/checkout@v3
- name: Install Dependencies
run: mix do deps.get, deps.compile
- name: Run Lint
Expand All @@ -43,46 +38,33 @@ jobs:
# WARNING:
# Changing the naming pattern requires changes in the branch protection
# at GitHub, the name of jobs are referenced there!
name: test (Elixir ${{ matrix.elixir }} OTP ${{ matrix.otp }})

runs-on: ubuntu-latest

name: test (Elixir ${{ matrix.pair.elixir }} OTP ${{ matrix.pair.erlang }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- elixir: 1.7.4
otp: 21.3.8
- elixir: 1.8.1
otp: 21.3.8
- elixir: 1.9.4
otp: 21.3.8
- elixir: 1.10.4
otp: 22.3.4
- elixir: 1.11.1
otp: 22.3.4
- elixir: 1.11
otp: 23.3
- elixir: 1.11
otp: 24.0

pair:
- { erlang: "26", elixir: "1.15", latest: true }
- { erlang: "26", elixir: "1.14" }
- { erlang: "25", elixir: "1.14" }
- { erlang: "24", elixir: "1.13" }
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-mix-
- uses: erlef/setup-beam@v1
- name: Install Erlang/Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
otp-version: ${{matrix.pair.erlang}}
elixir-version: ${{matrix.pair.elixir}}
- name: Install Dependencies
run: mix do deps.get, deps.compile
- name: Compile PropCheck
run: mix compile --warnings-as-errors
- name: Run Tests
run: PROPCHECK_DEBUG=1 PROPCHECK_VERBOSE=1 PROPCHECK_NUMTESTS=200 PROPCHECK_SEARCH_STEPS=1000 mix tests --cover --trace
run: PROPCHECK_NUMTESTS=200 PROPCHECK_SEARCH_STEPS=1000 mix tests
24 changes: 0 additions & 24 deletions config/config.exs

This file was deleted.

7 changes: 4 additions & 3 deletions lib/propcheck.ex
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,8 @@ defmodule PropCheck do
{:ok, levels} ->
levels

# {:error, msg} -> raise msg # Currently it make dialyzer unhappy mostly because of `Graph.topsort/1` spec.
{:error, msg} ->
raise msg
end

unpinned_raw_types = Enum.map(raw_types, &PropCheck.Utils.unpin_vars/1)
Expand Down Expand Up @@ -1133,7 +1134,7 @@ defmodule PropCheck do
each `collect` wrapper are printed separately.
"""
@spec collect(test, any) :: test
def collect(property, category), do: collect(property, with_title(''), category)
def collect(property, category), do: collect(property, with_title(~c""), category)

@doc """
Same as `collect/2`, but also accepts a fun `printer` to be used
Expand All @@ -1148,7 +1149,7 @@ defmodule PropCheck do
"""
@spec aggregate(test, sample) :: test
def aggregate(property, sample) do
aggregate(property, with_title(''), sample)
aggregate(property, with_title(~c""), sample)
end

@doc """
Expand Down
2 changes: 1 addition & 1 deletion lib/propcheck/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule PropCheck.Logger do

@moduledoc false

@levels ~w(debug info warn error)a
@levels ~w(debug info warning error)a

for level <- @levels, fun = :"log_#{level}" do
def unquote(fun)(arg) do
Expand Down
6 changes: 3 additions & 3 deletions lib/propcheck/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ defmodule PropCheck.Utils do
|> List.flatten()
end

def elixirfy_output('Stacktrace: ~p.~n', [stacktrace]) do
def elixirfy_output(~c"Stacktrace: ~p.~n", [stacktrace]) do
IO.puts("Stacktrace:")
IO.puts(Exception.format_stacktrace(stacktrace))
:ok
end

def elixirfy_output('An exception was raised:' ++ _, [kind, exception]) do
def elixirfy_output(~c"An exception was raised:" ++ _, [kind, exception]) do
IO.puts("An exception was raised:")
IO.puts(Exception.format(kind, exception))
:ok
end

def elixirfy_output('A linked process died' ++ _, [{reason, stack}]) do
def elixirfy_output(~c"A linked process died" ++ _, [{reason, stack}]) do
IO.puts("A linked process died with reason: an exception was raised:")
IO.puts(Exception.format(:error, reason, stack))
:ok
Expand Down
6 changes: 3 additions & 3 deletions lib/result.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ defmodule PropCheck.Result do
def handle_call({:message, fmt, args}, _from, state) do
state =
cond do
:lists.prefix('Error', fmt) ->
:lists.prefix(~c"Error", fmt) ->
%__MODULE__{state | errors: [{state.current, {fmt, args}} | state.errors]}

:lists.prefix('Failed', fmt) ->
:lists.prefix(~c"Failed", fmt) ->
%__MODULE__{state | errors: [{state.current, {fmt, args}} | state.errors]}

:lists.prefix('Testing', fmt) ->
:lists.prefix(~c"Testing", fmt) ->
%__MODULE__{state | tests: [args | state.tests], current: args}
end

Expand Down
27 changes: 14 additions & 13 deletions lib/statem/reporter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ defmodule PropCheck.StateM.Reporter do
defp do_indent(indent, str) do
str
|> String.split("\n")
|> Enum.map(&"#{indent}#{&1}")
|> Enum.join("\n")
|> Enum.map_join("\n", &"#{indent}#{&1}")
end

def pretty_cmds_name(cmds, opts) do
Expand All @@ -368,17 +367,19 @@ defmodule PropCheck.StateM.Reporter do
args =
args
|> Enum.with_index()
|> Enum.map(fn
{{:var, m}, _} ->
symb_var(m)

{arg, i} ->
case Keyword.get(opts, :cmd_args, true) do
true -> inspectx(arg, opts)
false -> "arg#{n}_#{i + 1}"
end
end)
|> Enum.join(", ")
|> Enum.map_join(
", ",
fn
{{:var, m}, _} ->
symb_var(m)

{arg, i} ->
case Keyword.get(opts, :cmd_args, true) do
true -> inspectx(arg, opts)
false -> "arg#{n}_#{i + 1}"
end
end
)

"#{symb_var(n)} = #{inspect(mod)}.#{fun}(#{args})"
end
Expand Down
40 changes: 10 additions & 30 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule PropCheck.Mixfile do
elixirc_paths: elixirc_paths(Mix.env()),
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
test_coverage: [tool: Coverex.Task, console_log: true],
test_coverage: [threshold: 0.58],
package: package(),
name: "PropCheck",
homepage_url: @source_url,
Expand All @@ -29,13 +29,11 @@ defmodule PropCheck.Mixfile do
aliases: aliases(),
preferred_cli_env: [
tests: :test,
test_ext: :test,
dialyzer: :test,
external_tests: :test,
parallel_test: :test,
test_parallel: :test
],
deps: deps(),
dialyzer: dialyzer()
deps: deps()
]
end

Expand Down Expand Up @@ -74,47 +72,29 @@ defmodule PropCheck.Mixfile do
def aliases do
[
clean: ["clean", "propcheck.clean"],
test_ext: &external_tests/1,
external_tests: &external_tests/1,
parallel_test: ["test --include concurrency_test --only concurrency_test"],
test_parallel: ["test --include concurrency_test --only concurrency_test"],
tests: ["test_ext", "test"],
tests: [&loglevel/1, "external_tests", "test"],
lint: [
"credo --strict",
"hex.audit",
"dialyzer"
"hex.audit"
]
]
end

defp deps do
[
# This is the reference to proper on its github repo - instable.
# {:proper, "~> 1.3", github: "proper-testing/proper"},
{:proper, "~> 1.4"},
{:proper, github: "proper-testing/proper", ref: "a5ae5669f01143b0828fc21667d4f5e344aa760b"},
{:libgraph, "~> 0.13"},
{:coverex, "~> 1.4", only: :test},
{:credo, "~> 1.4", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.0.0", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.21", only: :dev}
]
end

defp dialyzer do
[
plt_add_deps: :apps_direct,
plt_add_apps: ~w(
ex_unit
iex
mix
compiler
)a,
flags: ~w(
error_handling
race_conditions
unmatched_returns
underspecs
)a
]
defp loglevel(_args) do
log_level = System.get_env("LOG_LEVEL", "info") |> String.to_atom()
Logger.configure(level: log_level)
end

defp external_tests(_args) do
Expand Down
Loading