diff --git a/.credo.exs b/.credo.exs index e00a72f..889ab69 100644 --- a/.credo.exs +++ b/.credo.exs @@ -84,12 +84,13 @@ # {Credo.Check.Design.AliasUsage, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]}, + # 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: 0]}, {Credo.Check.Design.TagFIXME, [exit_status: 0]}, + {Credo.Check.Design.TagTODO, [exit_status: 0]}, # ## Readability Checks @@ -139,6 +140,7 @@ {Credo.Check.Refactor.RedundantWithClauseResult, []}, {Credo.Check.Refactor.RejectReject, []}, {Credo.Check.Refactor.UnlessWithElse, []}, + {Credo.Check.Refactor.UtcNowTruncate, []}, {Credo.Check.Refactor.WithClauses, []}, # diff --git a/.dialyzer_ignore.exs b/.dialyzer_ignore.exs index 864608a..fe51488 100644 --- a/.dialyzer_ignore.exs +++ b/.dialyzer_ignore.exs @@ -1,3 +1 @@ -[ - {"lib/mix/tasks/github_workflows.generate.ex", :no_return, 156} -] +[] diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index a526021..034872f 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -196,14 +196,14 @@ defmodule GithubWorkflows do uses: "actions/cache@v3", id: "npm-cache", with: [ - path: "~/.npm", - key: "npm-ubuntu-latest" + path: "node_modules", + key: "${{ runner.os }}-prettier" ] ], [ name: "Install Prettier", if: "steps.npm-cache.outputs.cache-hit != 'true'", - run: "npm i -g prettier" + run: "npm i -D prettier prettier-plugin-toml" ], [ name: "Run Prettier", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20646ed..cfffc5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -235,11 +235,11 @@ jobs: uses: actions/cache@v3 id: npm-cache with: - path: ~/.npm - key: npm-ubuntu-latest + path: node_modules + key: ${{ runner.os }}-prettier - name: Install Prettier if: steps.npm-cache.outputs.cache-hit != 'true' - run: npm i -g prettier + run: npm i -D prettier prettier-plugin-toml - name: Run Prettier run: npx prettier -c . test: diff --git a/.gitignore b/.gitignore index bcbe47e..fd1eb5f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ github_workflows_generator-*.tar # Temporary files, for example, from tests. /tmp/ -# Dialyzer PLT files -/priv/plts/*.plt -/priv/plts/*.plt.hash +# Optimum development/test artifacts +/node_modules/ +/priv/plts/ +.DS_Store +package.json +package-lock.json diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..65198f2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,17 @@ +/_build/ +/.elixir_ls/ +/.git/ +/config/ +/cover/ +/deps/ +/doc/ +/lib/ +/priv/ +/test/ +.credo.exs +.dialyzer_ignore.exs +.formatter.exs +.gitattributes +.gitignore +.iex.exs +.erl_crash.dump diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..e7ece36 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + trailingComma: 'es5', + tabWidth: 2, + semi: false, + singleQuote: true, + plugins: ['prettier-plugin-toml'], +} diff --git a/.tool-versions b/.tool-versions index 6fe0c3d..d836019 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,3 @@ elixir 1.17.1-otp-27 erlang 27.0 +nodejs 20.14.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 21427a2..b316bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - Dropped support for Elixir 1.11 and 1.12 (Credo requires version 1.13 at least). - Removed `fast_yaml` and `libyaml` from `README.md`. - Upgraded Elixir version to 1.17.1. -- Fixed YAML syntax error (`Nested mappings are not allowed in compact mappings`) +- Fixed YAML syntax error (`Nested mappings are not allowed in compact mappings`). +- Generated Optimum infra. ## 0.1.2 (2024-06-21) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..471a5fe --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +ci: + mix ci diff --git a/coveralls.json b/coveralls.json index 77dacb6..54db6e3 100644 --- a/coveralls.json +++ b/coveralls.json @@ -1,5 +1,6 @@ { "coverage_options": { "minimum_coverage": 100.0 - } + }, + "skip_files": [] } diff --git a/mix.exs b/mix.exs index fa7fc85..3b12366 100644 --- a/mix.exs +++ b/mix.exs @@ -11,9 +11,17 @@ defmodule GithubWorkflowsGenerator.MixProject do elixir: "~> 1.13", start_permanent: Mix.env() == :prod, aliases: aliases(), - deps: deps(), + deps: optimum_deps() ++ app_deps(), - # Code checks + # Hex package + description: "Generate GitHub Actions workflows", + package: package(), + + # CI + dialyzer: [ + plt_add_apps: [:ex_unit, :mix], + plt_file: {:no_warn, "priv/plts/dialyzer.plt"} + ], preferred_cli_env: [ ci: :test, coveralls: :test, @@ -23,19 +31,15 @@ defmodule GithubWorkflowsGenerator.MixProject do dialyzer: :test ], test_coverage: [tool: ExCoveralls], - dialyzer: [ - plt_add_apps: [:ex_unit, :mix], - plt_file: {:no_warn, "priv/plts/dialyzer.plt"} - ], # Docs name: "GithubWorkflowsGenerator", source_url: @repo, - docs: docs(), - - # Hex package - description: "Generate GitHub Actions workflows", - package: package() + docs: [ + extras: ["README.md"], + main: "readme", + source_ref: "v#{@version}" + ] ] end @@ -46,13 +50,6 @@ defmodule GithubWorkflowsGenerator.MixProject do ] end - defp docs do - [ - main: "Mix.Tasks.GithubWorkflows.Generate", - source_ref: "v#{@version}" - ] - end - defp package do [ licenses: ["MIT"], @@ -62,18 +59,27 @@ defmodule GithubWorkflowsGenerator.MixProject do end # Run "mix help deps" to learn about dependencies. - defp deps do + defp optimum_deps do [ - {:credo, "~> 1.7", only: [:test], runtime: false}, - {:dialyxir, "~> 1.4", only: [:test], runtime: false}, - {:ex_doc, "~> 0.34", only: [:dev], runtime: false}, - {:excoveralls, "~> 0.18", only: [:test], runtime: false}, - {:mix_audit, "~> 2.1", only: [:test], runtime: false} + {:credo, "~> 1.7", only: :test, runtime: false}, + {:dialyxir, "~> 1.4", only: :test, runtime: false}, + {:doctest_formatter, "~> 0.3", only: [:dev, :test], runtime: false}, + {:ex_doc, "~> 0.34", only: :dev, runtime: false}, + {:excoveralls, "~> 0.18", only: :test}, + {:mix_audit, "~> 2.1", only: :test, runtime: false} ] end + defp app_deps do + [] + end + defp aliases do [ + setup: [ + "deps.get", + "cmd npm i -D prettier prettier-plugin-toml" + ], ci: [ "deps.unlock --check-unused", "deps.audit", diff --git a/mix.lock b/mix.lock index 818cf95..0bf27e0 100644 --- a/mix.lock +++ b/mix.lock @@ -2,6 +2,7 @@ "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, "credo": {:hex, :credo, "1.7.7", "771445037228f763f9b2afd612b6aa2fd8e28432a95dbbc60d8e03ce71ba4446", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8bc87496c9aaacdc3f90f01b7b0582467b69b4bd2441fe8aae3109d843cc2f2e"}, "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, + "doctest_formatter": {:hex, :doctest_formatter, "0.3.0", "19da9fd0d9d1e895f86d7508f1962d8a16393277f73aba1066dddb3d2adcdfc8", [:mix], [], "hexpm", "485f4dab4fc65ecf18aa342d285b393db16814d828caa671c42f9f781b68cf5a"}, "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "ex_doc": {:hex, :ex_doc, "0.34.1", "9751a0419bc15bc7580c73fde506b17b07f6402a1e5243be9e0f05a68c723368", [: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", "d441f1a86a235f59088978eff870de2e815e290e44a8bd976fe5d64470a4c9d2"},