Skip to content

Commit

Permalink
added elixir CI test based on expublish workflow (#55)
Browse files Browse the repository at this point in the history
* added elixir CI test based on expublish workflow

* removed config.exs as it had no useful defaults and was not compatible with Elixir < 1.10

* adjusting CI to check elixir >1.10
  • Loading branch information
Valian committed Dec 12, 2023
1 parent 45c4b3d commit 20e0e9c
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 38 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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

Expand Down
32 changes: 0 additions & 32 deletions config/config.exs

This file was deleted.

3 changes: 2 additions & 1 deletion lib/readability/helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 20e0e9c

Please sign in to comment.