diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml new file mode 100644 index 0000000..dc41711 --- /dev/null +++ b/.github/workflows/elixir.yml @@ -0,0 +1,74 @@ +name: Elixir CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + name: Build and test ${{ matrix.elixir }} / OTP ${{ matrix.otp }} + runs-on: ubuntu-20.04 + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MIX_ENV: test + + strategy: + fail-fast: false + matrix: + include: + - elixir: '1.10' + otp: '22.3' + - elixir: '1.15' + otp: '25.3' + - elixir: '1.15' + otp: '26.0' + + steps: + - uses: actions/checkout@v3 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.elixir }} + otp-version: ${{ matrix.otp }} + - name: Restore dependency cache + uses: actions/cache@v3.3.1 + id: deps-cache + with: + path: deps + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix- + - name: Restore build cache + uses: actions/cache@v3.3.1 + with: + path: _build + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-build-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-build- + # - name: Restore plt cache + # uses: actions/cache@v3.3.1 + # id: plt-cache + # with: + # path: priv/plts + # key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles('**/mix.lock') }} + # restore-keys: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts- + - name: Install dependencies + if: steps.deps-cache.outputs.cache-hit != 'true' + run: mix deps.get + - name: Compile application + run: mix compile + # - name: Create plts + # if: steps.plt-cache.outputs.cache-hit != 'true' + # run: | + # mkdir -p priv/plts + # mix dialyzer --plt + # - name: Run static code analysis (dialyzer) + # run: mix dialyzer --no-check + # - name: Run static code analysis (credo) + # run: mix credo --strict + - name: Run tests + run: mix test + - name: Run tests and coverage + if: matrix.elixir == '1.15' && matrix.otp == '26.0' + run: mix coveralls.github \ No newline at end of file diff --git a/README.md b/README.md index 0277c6e..7a63e1b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Readability -[![Build Status](https://travis-ci.org/keepcosmos/readability.svg?branch=master)](https://travis-ci.org/keepcosmos/readability) +[![CI](https://github.com/keepcosmos/readability/actions/workflows/elixir.yml/badge.svg)](https://github.com/keepcosmos/readability/actions/workflows/elixir.yml) [![Module Version](https://img.shields.io/hexpm/v/readability.svg)](https://hex.pm/packages/readability) [![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/readability/) [![Total Download](https://img.shields.io/hexpm/dt/readability.svg)](https://hex.pm/packages/readability) [![License](https://img.shields.io/hexpm/l/readability.svg)](https://github.com/keepcosmos/readability/blob/master/LICENSE.md) -[![Last Updated](https://img.shields.io/github/last-commit/keepcosmos/readability.svg)](https://github.com/keepcosmos/readability/commits/master) +[![Coverage Status](https://coveralls.io/repos/github/keepcosmos/readability/badge.svg?branch=master)](https://coveralls.io/github/keepcosmos/readability?branch=master) Readability is a tool for extracting and curating the primary readable content of a webpage. @@ -18,14 +18,14 @@ Add `:readability` to your list of dependencies in `mix.exs`: ```elixir def deps do [ - {:readability, "~> 0.9"} + {:readability, "~> 0.10"} ] end ``` After that, run mix deps.get. -Note: Readability requires Elixir 1.3 or higher. +Note: Readability requires Elixir 1.10 or higher. ## Usage diff --git a/config/config.exs b/config/config.exs deleted file mode 100644 index f12692d..0000000 --- a/config/config.exs +++ /dev/null @@ -1,32 +0,0 @@ -# This file is responsible for configuring your application -# and its dependencies with the aid of the Mix.Config module. -import Config - -# This configuration is loaded before any dependency and is restricted -# to this project. If another project depends on this project, this -# file won't be loaded nor affect the parent project. For this reason, -# if you want to provide default values for your application for -# 3rd-party users, it should be done in your "mix.exs" file. - -# You can configure for your application as: -# -# config :readability, key: :value -# -# And access this configuration in your application as: -# -# Application.get_env(:readability, :key) -# -# Or configure a 3rd-party app: -# -# config :logger, level: :info -# - -# It is also possible to import configuration files, relative to this -# directory. For example, you can emulate configuration per environment -# by uncommenting the line below and defining dev.exs, test.exs and such. -# Configuration from the imported file will override the ones defined -# here (which is why it is important to import them last). -# -# import_config "#{Mix.env}.exs" - -config :readability, httpoison_options: [] diff --git a/lib/readability/helper.ex b/lib/readability/helper.ex index ae78e5f..46cc11f 100644 --- a/lib/readability/helper.ex +++ b/lib/readability/helper.ex @@ -41,7 +41,8 @@ defmodule Readability.Helper do is_binary(target_attr) -> fn attr -> elem(attr, 0) == target_attr end - Kernel.is_struct(target_attr, Regex) -> + # compatibility with older versions of Elixir where is no is_struct/2 + is_struct(target_attr) and :erlang.map_get(:__struct__, target_attr) == Regex -> fn attr -> elem(attr, 0) =~ target_attr end is_list(target_attr) -> diff --git a/mix.exs b/mix.exs index 61b73b6..905bedc 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,7 @@ defmodule Readability.Mixfile do [ app: :readability, version: @version, - elixir: "~> 1.3", + elixir: "~> 1.10", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls],