Skip to content

Commit b1da3ef

Browse files
Update workflows and dev dependencies (#171)
* Update workflows * Update dev dependencies * Fix credo
1 parent 35e926f commit b1da3ef

29 files changed

+454
-489
lines changed

.credo.exs

Lines changed: 0 additions & 146 deletions
This file was deleted.

.formatter.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

.github/workflows/ci.yml

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@ jobs:
1414
- name: Install OTP and Elixir
1515
uses: erlef/setup-beam@v1
1616
with:
17-
otp-version: "23.0"
18-
elixir-version: "1.11.2"
17+
otp-version: "25.0"
18+
elixir-version: "1.14.2"
1919

2020
- name: Install dependencies
2121
run: mix deps.get
2222

23-
# TODO: Enable in next release
24-
#
25-
# At the moment, we still have pending PRs etc.
26-
# and introducing auto-formatting now would cause
27-
# a ton of conflicts.
28-
#
29-
# - name: Check mix format
30-
# run: mix format --check-formatted
23+
- name: Check mix format
24+
run: mix format --check-formatted
3125

3226
- name: Compile with warnings as errors
3327
run: mix compile --warnings-as-errors
@@ -41,8 +35,8 @@ jobs:
4135
- name: Install OTP and Elixir
4236
uses: erlef/setup-beam@v1
4337
with:
44-
otp-version: "23.0"
45-
elixir-version: "1.11.2"
38+
otp-version: "25.0"
39+
elixir-version: "1.14.2"
4640

4741
- name: Install dependencies
4842
run: mix deps.get
@@ -57,27 +51,18 @@ jobs:
5751
fail-fast: false
5852
matrix:
5953
include:
54+
- erlang: "24.2"
55+
elixir: "1.12.3"
56+
os: "ubuntu-22.04"
57+
- erlang: "24.2"
58+
elixir: "1.13.4"
59+
os: "ubuntu-22.04"
6060
- erlang: "23.0"
6161
elixir: "1.11.2"
62-
os: "ubuntu-latest"
62+
os: "ubuntu-20.04"
6363
- erlang: "23.0"
6464
elixir: "1.10.3"
65-
os: "ubuntu-latest"
66-
- erlang: "22.3"
67-
elixir: "1.9.4"
68-
os: "ubuntu-latest"
69-
- erlang: "21.3"
70-
elixir: "1.8.2"
71-
os: "ubuntu-latest"
72-
- erlang: "20.3.1"
73-
elixir: "1.7.4"
74-
os: "ubuntu-latest"
75-
- erlang: "19.3"
76-
elixir: "1.6.6"
77-
os: "ubuntu-18.04"
78-
- erlang: "18.3"
79-
elixir: "1.5.3"
80-
os: "ubuntu-18.04"
65+
os: "ubuntu-20.04"
8166

8267
steps:
8368
- uses: actions/checkout@v1

config/config.exs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1 @@
1-
# This file is responsible for configuring your application
2-
# and its dependencies with the aid of the Mix.Config module.
3-
use Mix.Config
4-
5-
# This configuration is loaded before any dependency and is restricted
6-
# to this project. If another project depends on this project, this
7-
# file won't be loaded nor affect the parent project. For this reason,
8-
# if you want to provide default values for your application for
9-
# 3rd-party users, it should be done in your "mix.exs" file.
10-
11-
# You can configure for your application as:
12-
#
13-
# config :sshkit, key: :value
14-
#
15-
# And access this configuration in your application as:
16-
#
17-
# Application.get_env(:sshkit, :key)
18-
#
19-
# Or configure a 3rd-party app:
20-
#
21-
# config :logger, level: :info
22-
#
23-
24-
# It is also possible to import configuration files, relative to this
25-
# directory. For example, you can emulate configuration per environment
26-
# by uncommenting the line below and defining dev.exs, test.exs and such.
27-
# Configuration from the imported file will override the ones defined
28-
# here (which is why it is important to import them last).
29-
#
30-
# import_config "#{Mix.env}.exs"
1+
import Config

lib/sshkit.ex

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,11 @@ defmodule SSHKit do
357357
target = Keyword.get(options, :as, Path.basename(source))
358358

359359
run = fn host ->
360-
{:ok, res} = SSH.connect host.name, host.options, fn conn ->
361-
SCP.upload(conn, source, target, options)
362-
end
360+
{:ok, res} =
361+
SSH.connect(host.name, host.options, fn conn ->
362+
SCP.upload(conn, source, target, options)
363+
end)
364+
363365
res
364366
end
365367

@@ -403,9 +405,11 @@ defmodule SSHKit do
403405
target = Keyword.get(options, :as, Path.basename(source))
404406

405407
run = fn host ->
406-
{:ok, res} = SSH.connect host.name, host.options, fn conn ->
407-
SCP.download(conn, source, target, options)
408-
end
408+
{:ok, res} =
409+
SSH.connect(host.name, host.options, fn conn ->
410+
SCP.download(conn, source, target, options)
411+
end)
412+
409413
res
410414
end
411415

lib/sshkit/context.ex

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule SSHKit.Context do
1515

1616
import SSHKit.Utils
1717

18-
defstruct [hosts: [], env: nil, path: nil, umask: nil, user: nil, group: nil]
18+
defstruct hosts: [], env: nil, path: nil, umask: nil, user: nil, group: nil
1919

2020
@doc """
2121
Compiles an executable command string for running the given `command`
@@ -38,12 +38,19 @@ defmodule SSHKit.Context do
3838
end
3939

4040
defp sudo(command, nil, nil), do: command
41-
defp sudo(command, username, nil), do: "sudo -H -n -u #{username} -- sh -c #{shellquote(command)}"
42-
defp sudo(command, nil, groupname), do: "sudo -H -n -g #{groupname} -- sh -c #{shellquote(command)}"
43-
defp sudo(command, username, groupname), do: "sudo -H -n -u #{username} -g #{groupname} -- sh -c #{shellquote(command)}"
41+
42+
defp sudo(command, username, nil),
43+
do: "sudo -H -n -u #{username} -- sh -c #{shellquote(command)}"
44+
45+
defp sudo(command, nil, groupname),
46+
do: "sudo -H -n -g #{groupname} -- sh -c #{shellquote(command)}"
47+
48+
defp sudo(command, username, groupname),
49+
do: "sudo -H -n -u #{username} -g #{groupname} -- sh -c #{shellquote(command)}"
4450

4551
defp export(command, nil), do: command
4652
defp export(command, env) when env == %{}, do: command
53+
4754
defp export(command, env) do
4855
exports = Enum.map_join(env, " ", fn {name, value} -> "#{name}=\"#{value}\"" end)
4956
"(export #{exports} && #{command})"

lib/sshkit/scp/download.ex

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
defmodule SSHKit.SCP.Download do
2-
@moduledoc false
2+
@moduledoc """
3+
Helper module used by SSHKit.SCP.download/4.
4+
"""
35

46
require Bitwise
57

@@ -28,7 +30,7 @@ defmodule SSHKit.SCP.Download do
2830

2931
defp start(connection, source, target, options) do
3032
timeout = Keyword.get(options, :timeout, :infinity)
31-
map_cmd = Keyword.get(options, :map_cmd, &(&1))
33+
map_cmd = Keyword.get(options, :map_cmd, & &1)
3234
command = map_cmd.(Command.build(:download, source, options))
3335
handler = connection_handler(options)
3436

@@ -41,10 +43,13 @@ defmodule SSHKit.SCP.Download do
4143
case message do
4244
{:data, _, 0, data} ->
4345
process_data(state, data, options)
46+
4447
{:exit_status, _, status} ->
4548
exited(options, state, status)
49+
4650
{:eof, _} ->
4751
eof(options, state)
52+
4853
{:closed, _} ->
4954
closed(options, state)
5055
end
@@ -55,6 +60,7 @@ defmodule SSHKit.SCP.Download do
5560
case state do
5661
{:next, path, stack, attrs, buffer} ->
5762
next(options, path, stack, attrs, buffer <> data)
63+
5864
{:read, path, stack, attrs, buffer} ->
5965
read(options, path, stack, attrs, buffer <> data)
6066
end
@@ -193,7 +199,7 @@ defmodule SSHKit.SCP.Download do
193199
atime = :calendar.gregorian_seconds_to_datetime(@epoch + atime)
194200
mtime = :calendar.gregorian_seconds_to_datetime(@epoch + mtime)
195201
{:ok, file_info} = File.stat(path)
196-
:ok = File.write_stat(path, %{file_info| mtime: mtime, atime: atime}, [:posix])
202+
:ok = File.write_stat(path, %{file_info | mtime: mtime, atime: atime}, [:posix])
197203
end
198204

199205
@tfmt ~S"(T)(0|[1-9]\d*) (0|[1-9]\d{0,5}) (0|[1-9]\d*) (0|[1-9]\d{0,5})"
@@ -206,14 +212,19 @@ defmodule SSHKit.SCP.Download do
206212
case Regex.run(@dfmt, value, capture: :all_but_first) do
207213
["T", mtime, mtus, atime, atus] ->
208214
{"T", dec(mtime), dec(mtus), dec(atime), dec(atus)}
215+
209216
[chr, _, _, name] when chr in ["C", "D"] and name in ["/", "..", "."] ->
210217
nil
218+
211219
["C", mode, len, name] ->
212220
{"C", oct(mode), dec(len), name}
221+
213222
["D", mode, len, name] ->
214223
{"D", oct(mode), dec(len), name}
224+
215225
["E"] ->
216226
{"E"}
227+
217228
nil ->
218229
nil
219230
end

0 commit comments

Comments
 (0)