Skip to content

Commit

Permalink
Add unused dependencies check step to CI (#435)
Browse files Browse the repository at this point in the history
* Adds unused dependency check to CI

* Removes PARSER env var logic
  • Loading branch information
antedeguemon authored Nov 4, 2022
1 parent 9182671 commit a16cf5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
jobs:
test:
runs-on: ubuntu-latest
env:
PARSER: ${{ matrix.parser }}

name: Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }} with ${{ matrix.parser }}

strategy:
Expand Down Expand Up @@ -41,6 +38,9 @@ jobs:
- name: Install dependencies
run: mix deps.get

- name: Check for unused dependencies
run: mix deps.unlock --check-unused

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -54,4 +54,4 @@ jobs:

- name: Run test
run: |-
MIX_ENV=test mix test.$PARSER
MIX_ENV=test mix test.${{ matrix.parser }}
20 changes: 4 additions & 16 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,16 @@ defmodule Floki.Mixfile do
end

defp deps do
# Needed to avoid installing unnecessary deps on the CI
parsers_deps = [
html5ever: {:html5ever, ">= 0.8.0", optional: true, only: [:dev, :test]},
fast_html: {:fast_html, ">= 0.0.0", optional: true, only: [:dev, :test]}
]

parsers =
case System.get_env("PARSER") do
nil -> [:fast_html, :html5ever]
parser when parser in ~w(html5ever fast_html) -> [String.to_atom(parser)]
_ -> []
end
|> Enum.map(fn name -> Keyword.fetch!(parsers_deps, name) end)

[
{:jason, "~> 1.1", only: [:dev, :test, :docs]},
{:earmark, "~> 1.2", only: :dev},
{:ex_doc, "~> 0.29.0", only: :dev, runtime: false},
{:benchee, "~> 1.1.0", only: :dev},
{:credo, ">= 0.0.0", only: [:dev, :test]},
{:dialyxir, "~> 1.0", only: [:dev], runtime: false}
] ++ parsers
{:dialyxir, "~> 1.0", only: [:dev], runtime: false},
{:html5ever, ">= 0.8.0", optional: true, only: [:dev, :test]},
{:fast_html, ">= 0.0.0", optional: true, only: [:dev, :test]}
]
end

defp aliases do
Expand Down

0 comments on commit a16cf5e

Please sign in to comment.