Skip to content

Commit 9ed39c0

Browse files
authored
Merge branch 'main' into pr/db35a96-fn-newline-metadata
2 parents 3a82c57 + 19f2c88 commit 9ed39c0

10 files changed

Lines changed: 273 additions & 356 deletions

File tree

.formatter.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Used by "mix format"
22
[
33
plugins: [Styler],
4+
import_deps: [:stream_data],
45
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
56
]

.github/property_failures.exs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#! /usr/bin/env elixir
2+
3+
defmodule Main do
4+
@moduledoc false
5+
require Logger
6+
7+
@repo System.get_env("REPO", "elixir-tools/spitfire")
8+
def run do
9+
input =
10+
with :eof <- IO.read(:eof) do
11+
Logger.error("Stdin is empty")
12+
System.halt(2)
13+
end
14+
15+
results =
16+
case JSON.decode(input) do
17+
{:ok, results} ->
18+
results
19+
20+
{:error, reason} ->
21+
case reason do
22+
{_, offset, byte} ->
23+
Logger.error(inspect(byte))
24+
Logger.error(binary_slice(input, offset, byte_size(input)))
25+
26+
_ ->
27+
:ok
28+
end
29+
30+
Logger.error(inspect(reason))
31+
raise "Malformed JSON: " <> input
32+
end
33+
34+
failures =
35+
for failures <- get_in(results, ["tests", Access.all(), "failures"]), f <- failures do
36+
[match] = Regex.run(~r/.*Clause:.*\s+Generated:.*\n+(.*)/, f["message"], capture: :all_but_first)
37+
38+
JSON.decode!(String.trim(match))
39+
end
40+
41+
failures = Enum.uniq_by(failures, & &1["code"])
42+
43+
if failures == [] do
44+
IO.write(:stderr, "No failures!")
45+
end
46+
47+
for fail <- failures do
48+
{issues, 0} =
49+
gh(
50+
~w(issue list --label property-failure --json title) ++
51+
["--jq", ~s<. | map(. | select(.title == "#{fail["code"]}"))>]
52+
)
53+
54+
case JSON.decode!(issues) do
55+
[] ->
56+
IO.write(:stderr, "Making new issue for #{fail["code"]}\n")
57+
58+
gh(
59+
~w(issue create --label property-failure) ++
60+
[
61+
"--title",
62+
fail["code"],
63+
"--body",
64+
"""
65+
Type: #{fail["type"]}
66+
Context: #{fail["context"]}
67+
68+
Code:
69+
```elixir
70+
#{fail["code"]}
71+
```
72+
73+
Elixir AST:
74+
```elixir
75+
#{fail["elixir"]}
76+
```
77+
78+
Spitfire AST:
79+
```elixir
80+
#{fail["spitfire"] || "N/A"}
81+
```
82+
"""
83+
]
84+
)
85+
86+
_ ->
87+
IO.write(:stderr, "Issue already exists for #{fail["code"]}\n")
88+
end
89+
end
90+
end
91+
92+
defp gh(args) do
93+
System.cmd("gh", args ++ ~w(--repo #{@repo}))
94+
end
95+
end
96+
97+
Main.run()
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Property Tests
2+
on:
3+
# schedule:
4+
# - cron: "0 0 * * *"
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
issues: write
10+
11+
concurrency:
12+
group: property-test
13+
cancel-in-progress: false
14+
15+
jobs:
16+
proptest:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: DeterminateSystems/nix-installer-action@main
22+
- uses: cachix/cachix-action@v14
23+
with:
24+
name: elixir-tools
25+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
26+
27+
- uses: actions/cache@v4
28+
with:
29+
path: |
30+
deps
31+
_build
32+
key: ${{ runner.os }}-mix-${{ hashFiles('**/.mise.toml') }}-${{ hashFiles('**/mix.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-mix-${{ hashFiles('**/.mise.toml') }}-
35+
36+
- name: Install Dependencies
37+
run: nix develop --command bash -c "mix deps.get"
38+
39+
- name: Compile
40+
run: nix develop --command bash -c "MIX_ENV=test mix compile"
41+
42+
- name: Run property tests
43+
env:
44+
GH_TOKEN: ${{ github.token }}
45+
run: nix develop --command bash -c "MIX_ENV=test mix test.json --only property | .github/property_failures.exs"

.github/workflows/proptest.yaml

Lines changed: 0 additions & 74 deletions
This file was deleted.

config/config.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,17 @@ if config_env() == :test do
1313
# END: parse_program
1414

1515
config :spitfire, trace: false
16+
17+
is_ci = "CI" |> System.get_env("false") |> String.to_existing_atom()
18+
19+
config :spitfire, is_ci: is_ci
20+
21+
max_runs =
22+
if is_ci do
23+
500_000
24+
else
25+
1000
26+
end
27+
28+
config :stream_data, max_runs: max_runs
1629
end

flake.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
packages = with pkgs; [
1818
beam.packages.erlang_27.erlang
1919
beam.packages.erlang_27.elixir_1_18
20-
act
2120
];
2221
};
2322
};

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ defmodule Spitfire.MixProject do
3535
{:styler, "~> 0.11", only: [:dev, :test]},
3636
{:credo, "~> 1.7", only: :dev},
3737
{:dialyxir, "~> 1.0", only: :dev},
38-
{:stream_data, "~> 1.0", only: [:dev, :test]}
38+
{:stream_data, "~> 1.0", only: [:dev, :test]},
39+
{:ex_unit_json, "~> 0.4.1", only: [:dev, :test]}
3940
]
4041
end
4142

mix.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
66
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
77
"ex_doc": {:hex, :ex_doc, "0.34.0", "ab95e0775db3df71d30cf8d78728dd9261c355c81382bcd4cefdc74610bef13e", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "60734fb4c1353f270c3286df4a0d51e65a2c1d9fba66af3940847cc65a8066d7"},
8+
"ex_unit_json": {:hex, :ex_unit_json, "0.4.1", "e234447a48fa0ed1a7b18d5435bf2b9acf0a595e055a278cbcc71e4c6e750ecd", [:mix], [], "hexpm", "dd35badab48add7317f8c9cc0ac39022edbf7ed23a2547ce4fea38c026bd55ab"},
89
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
910
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1011
"makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"},

0 commit comments

Comments
 (0)