Skip to content

Commit

Permalink
Update GitHub actions workflow (BlakeWilliams#253)
Browse files Browse the repository at this point in the history
* Modernize GitHub actions workflow

* Remove test versions

* Run mix format

* Update deprecated config import

* Remove credo for now

As it wasn't in the old pipeline. If we want to add it, let's make sure that we have resolved all it's errors
  • Loading branch information
inooid authored Aug 8, 2022
1 parent c2f853d commit d7292bd
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 27 deletions.
58 changes: 44 additions & 14 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,55 @@ name: Elixir CI

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

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
otp: ['21.0', '22.0']
elixir: ['1.7.2', '1.10.1']
elixir: ['1.13', '1.12', '1.11', '1.10']
otp: ['24.x', '23.x', '22.x']
include:
- lint: lint
elixir: '1.13'
otp: '24.x'

steps:
- uses: actions/checkout@v2
- name: Setup elixir
uses: actions/setup-elixir@v1
with:
elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
otp-version: ${{matrix.otp}} # Define the OTP version [required]
- name: Install Dependencies
run: mix deps.get
- name: Run Tests
run: mix test
- uses: actions/checkout@v3

- name: Setup BEAM
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Restore dependencies cache
uses: actions/cache@v2
id: mix-cache
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ matrix.otp }}-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ matrix.otp }}-${{ hashFiles('mix.lock') }}
${{ runner.os }}-mix-${{ matrix.otp }}-
${{ runner.os }}-mix-
- name: Install Dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
mix deps.compile
- run: mix format --check-formatted
if: matrix.lint

- name: Run Tests
run: mix test
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
import Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
Expand Down
12 changes: 5 additions & 7 deletions lib/slack.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@ defmodule Slack do
}
end

defoverridable [
handle_connect: 2,
handle_event: 3,
handle_close: 3,
handle_info: 3,
child_spec: 1
]
defoverridable handle_connect: 2,
handle_event: 3,
handle_close: 3,
handle_info: 3,
child_spec: 1
end
end
end
21 changes: 17 additions & 4 deletions lib/slack/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ defmodule Slack.State do
put_in(slack, [:groups, channel.id], channel)
end


def update(%{type: "channel_left", channel: channel_id}, slack) do
put_in(slack, [:channels, channel_id, :is_member], false)
end
Expand All @@ -81,7 +80,13 @@ defmodule Slack.State do
end

def update(
%{type: "message", subtype: unquote(type <> "_topic"), channel: channel, user: user, topic: topic},
%{
type: "message",
subtype: unquote(type <> "_topic"),
channel: channel,
user: user,
topic: topic
},
slack
) do
put_in(slack, [unquote(plural_atom), safe_map_getter(channel), :topic], %{
Expand All @@ -95,14 +100,22 @@ defmodule Slack.State do
%{type: "message", subtype: unquote(type <> "_join"), channel: channel, user: user},
slack
) do
update_in(slack, [unquote(plural_atom), safe_map_getter(channel), safe_list_getter(:members)], &Enum.uniq([user | &1]))
update_in(
slack,
[unquote(plural_atom), safe_map_getter(channel), safe_list_getter(:members)],
&Enum.uniq([user | &1])
)
end

def update(
%{type: "message", subtype: unquote(type <> "_leave"), channel: channel, user: user},
slack
) do
update_in(slack, [unquote(plural_atom), safe_map_getter(channel), safe_list_getter(:members)], &(&1 -- [user]))
update_in(
slack,
[unquote(plural_atom), safe_map_getter(channel), safe_list_getter(:members)],
&(&1 -- [user])
)
end
end)

Expand Down
2 changes: 1 addition & 1 deletion lib/slack/web/documentation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ defmodule Slack.Web.Documentation do
|> String.graphemes()
|> Enum.reverse()
|> Enum.find_index(&(&1 == "."))
|> (&(String.split_at(endpoint, -&1))).()
|> (&String.split_at(endpoint, -&1)).()

{String.replace_suffix(module_name, ".", ""), function_name}
end
Expand Down

0 comments on commit d7292bd

Please sign in to comment.