Skip to content

Commit

Permalink
Merge pull request #366 from joken-elixir/chore/tidyup
Browse files Browse the repository at this point in the history
small refactor of CI
  • Loading branch information
victorolinasc authored Jun 18, 2022
2 parents 737c47e + 874f77a commit fe5cd72
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ updates:
- package-ecosystem: mix
directory: "/"
schedule:
interval: weekly
interval: monthly
open-pull-requests-limit: 10
ignore:
- dependency-name: ex_doc
Expand Down
39 changes: 13 additions & 26 deletions .github/workflows/tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Tests
name: CI

on:
push:
branches: [ master ]
pull_request:
branches:
- master
branches: [ master ]

jobs:
check_duplicate_runs:
Expand All @@ -24,29 +24,24 @@ jobs:
do_not_skip: '["pull_request"]'

tests:
name: Run tests (Elixir ${{matrix.elixir}}, OTP ${{matrix.otp}})
name: Run tests

needs: check_duplicate_runs
if: ${{ needs.check_duplicate_runs.outputs.should_skip != 'true' }}

env:
FORCE_COLOR: 1

strategy:
fail-fast: false
matrix:
elixir:
- "1.8.2"
- "1.10.4"
- "1.12.2"
otp:
- "22.3"
- "23.3"
- "24.0"
exclude:
- elixir: "1.8.2"
otp: "23.3"
- elixir: "1.8.2"
otp: "24.0"
- elixir: "1.12.2"
include:
- elixir: "1.10.4"
otp: "22.3"
- elixir: "1.12.2"
otp: "23.3"
- elixir: "1.13.3"
otp: "24.3"

runs-on: ubuntu-latest

Expand Down Expand Up @@ -88,30 +83,22 @@ jobs:

- name: Check source code format
run: mix format --check-formatted
if: ${{ matrix.lint }}

- name: Perform source code static analysis
run: mix credo --strict
if: ${{ matrix.lint }}
env:
MIX_ENV: test

- name: Check unused dependencies
run: mix deps.unlock --check-unused
if: ${{ matrix.lint }}

- name: Remove compiled application files
run: mix clean

- name: Compile dependencies
run: mix compile
if: ${{ !matrix.lint }}
env:
MIX_ENV: test

- name: Compile & lint dependencies
run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}
env:
MIX_ENV: test

Expand Down
58 changes: 0 additions & 58 deletions .github/workflows/release.yml

This file was deleted.

29 changes: 10 additions & 19 deletions lib/joken.ex
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ defmodule Joken do
signer_arg \\ :default_signer,
hooks \\ []
) do
with {:ok, claims} <- generate_claims(token_config, extra_claims, hooks),
{:ok, token, claims} <- encode_and_sign(claims, signer_arg, hooks) do
{:ok, token, claims}
case generate_claims(token_config, extra_claims, hooks) do
{:ok, claims} -> encode_and_sign(claims, signer_arg, hooks)
err -> err
end
end

Expand Down Expand Up @@ -254,10 +254,8 @@ defmodule Joken do
with {:ok, {bearer_token, signer}} <-
Hooks.run_before_hook(hooks, :before_verify, {bearer_token, signer}),
:ok <- check_signer_not_empty(signer),
result <- Signer.verify(bearer_token, signer),
{:ok, claims_map} <-
Hooks.run_after_hook(hooks, :after_verify, result, {bearer_token, signer}) do
{:ok, claims_map}
result <- Signer.verify(bearer_token, signer) do
Hooks.run_after_hook(hooks, :after_verify, result, {bearer_token, signer})
end
end

Expand Down Expand Up @@ -298,9 +296,9 @@ defmodule Joken do
context \\ nil,
hooks \\ []
) do
with {:ok, claims} <- verify(bearer_token, signer, hooks),
{:ok, claims} <- validate(token_config, claims, context, hooks) do
{:ok, claims}
case verify(bearer_token, signer, hooks) do
{:ok, claims} -> validate(token_config, claims, context, hooks)
err -> err
end
end

Expand Down Expand Up @@ -338,15 +336,8 @@ defmodule Joken do
def generate_claims(token_config, extra_claims, hooks) do
with {:ok, {token_config, extra_claims}} <-
Hooks.run_before_hook(hooks, :before_generate, {token_config, extra_claims}),
claims <- Enum.reduce(token_config, extra_claims, &Claim.__generate_claim__/2),
{:ok, claims} <-
Hooks.run_after_hook(
hooks,
:after_generate,
{:ok, claims},
{token_config, extra_claims}
) do
{:ok, claims}
claims <- Enum.reduce(token_config, extra_claims, &Claim.__generate_claim__/2) do
Hooks.run_after_hook(hooks, :after_generate, {:ok, claims}, {token_config, extra_claims})
end
end

Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ defmodule Joken.Mixfile do
use Mix.Project

@source_url "https://github.com/joken-elixir/joken"
@version "2.4.1"
@version "2.5.0"

def project do
[
app: :joken,
version: @version,
name: "Joken",
elixir: "~> 1.8",
elixir: "~> 1.10",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
consolidate_protocols: Mix.env() != :test,
Expand Down

0 comments on commit fe5cd72

Please sign in to comment.