Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ci #90

Merged
merged 18 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI (Macos)

on:
pull_request:
push:
branches:
- main

jobs:
test:
runs-on: macos-latest
env:
MIX_ENV: test
strategy:
fail-fast: false
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install Elixir
env:
HOMEBREW_NO_AUTO_UPDATE: 1
run: brew install elixir

- uses: actions/checkout@v3

- run: mix deps.get

- run: mix format --check-formatted

- run: mix deps.unlock --check-unused

- run: mix deps.compile

- run: mix compile --warnings-as-errors

- run: mix test --only os_macos
16 changes: 5 additions & 11 deletions .github/workflows/ci.yml → .github/workflows/ci-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CI (Ubuntu)

on:
pull_request:
Expand All @@ -23,21 +23,15 @@ jobs:
otp: 26.1
lint: lint
steps:
- uses: actions/checkout@v3
- name: Install inotify-tools
run: sudo apt-get update && sudo apt-get install -y inotify-tools

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

- uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-
- uses: actions/checkout@v3

- run: mix deps.get

Expand All @@ -52,4 +46,4 @@ jobs:
- run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}

- run: mix test
- run: mix test --only os_linux
39 changes: 39 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI (Windows)

on:
pull_request:
push:
branches:
- main

jobs:
test:
runs-on: windows-latest
env:
MIX_ENV: test
strategy:
fail-fast: false
matrix:
include:
- pair:
elixir: 1.12.3
otp: 23.3
- pair:
elixir: 1.15.7
otp: 26.1

steps:
- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.pair.otp}}
elixir-version: ${{matrix.pair.elixir}}

- uses: actions/checkout@v3

- run: mix deps.get

- run: mix deps.compile

- run: mix compile

- run: mix test --only os_windows
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ file_system-*.tar
/tmp

# Misc
/priv/mac_listener
/priv/mac_listener*
/priv/kqueue
mix.lock
6 changes: 5 additions & 1 deletion lib/file_system/worker.ex
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require Logger

defmodule FileSystem.Worker do
@moduledoc """
FileSystem Worker Process with the backend GenServer, receive events from Port Process
Expand All @@ -20,7 +22,9 @@ defmodule FileSystem.Worker do
{:ok, backend_pid} <- backend.start_link([{:worker_pid, self()} | rest]) do
{:ok, %{backend_pid: backend_pid, subscribers: %{}}}
else
_ -> :ignore
reason ->
Logger.warning("Not able to start file_system worker, reason: #{inspect(reason)}")
:ignore
end
end

Expand Down
110 changes: 110 additions & 0 deletions test/backends/fs_inotify_linux_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
defmodule FileSystem.Backends.FSInotifyLinuxTest do
use ExUnit.Case, async: true
import FileSystem.Backends.FSInotify

@moduletag os_inux: true

describe "options parse test" do
test "supported options" do
assert {:ok,
[
~c"-e",
~c"modify",
~c"-e",
~c"close_write",
~c"-e",
~c"moved_to",
~c"-e",
~c"moved_from",
~c"-e",
~c"create",
~c"-e",
~c"delete",
~c"-e",
~c"attrib",
~c"--format",
[37, 119, 1, 37, 101, 1, 37, 102],
~c"--quiet",
~c"-m",
~c"-r",
~c"/tmp"
]} ==
parse_options(dirs: ["/tmp"], recursive: true)

assert {:ok,
[
~c"-e",
~c"modify",
~c"-e",
~c"close_write",
~c"-e",
~c"moved_to",
~c"-e",
~c"moved_from",
~c"-e",
~c"create",
~c"-e",
~c"delete",
~c"-e",
~c"attrib",
~c"--format",
[37, 119, 1, 37, 101, 1, 37, 102],
~c"--quiet",
~c"-m",
~c"/tmp"
]} ==
parse_options(dirs: ["/tmp"], recursive: false)
end

test "ignore unsupported options" do
assert {:ok,
[
~c"-e",
~c"modify",
~c"-e",
~c"close_write",
~c"-e",
~c"moved_to",
~c"-e",
~c"moved_from",
~c"-e",
~c"create",
~c"-e",
~c"delete",
~c"-e",
~c"attrib",
~c"--format",
[37, 119, 1, 37, 101, 1, 37, 102],
~c"--quiet",
~c"-m",
~c"/tmp"
]} ==
parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options)

assert {:ok,
[
~c"-e",
~c"modify",
~c"-e",
~c"close_write",
~c"-e",
~c"moved_to",
~c"-e",
~c"moved_from",
~c"-e",
~c"create",
~c"-e",
~c"delete",
~c"-e",
~c"attrib",
~c"--format",
[37, 119, 1, 37, 101, 1, 37, 102],
~c"--quiet",
~c"-m",
~c"-r",
~c"/tmp"
]} ==
parse_options(dirs: ["/tmp"], recursive: :unknown_value)
end
end
end
104 changes: 2 additions & 102 deletions test/backends/fs_inotify_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,113 +2,13 @@ defmodule FileSystem.Backends.FSInotifyTest do
use ExUnit.Case, async: true
import FileSystem.Backends.FSInotify

@moduletag os_inux: true, os_windows: true

describe "options parse test" do
test "without :dirs" do
assert {:error, _} = parse_options([])
assert {:error, _} = parse_options(recursive: 1)
end

test "supported options" do
assert {:ok,
[
~c"-e",
~c"modify",
~c"-e",
~c"close_write",
~c"-e",
~c"moved_to",
~c"-e",
~c"moved_from",
~c"-e",
~c"create",
~c"-e",
~c"delete",
~c"-e",
~c"attrib",
~c"--format",
[37, 119, 1, 37, 101, 1, 37, 102],
~c"--quiet",
~c"-m",
~c"-r",
~c"/tmp"
]} ==
parse_options(dirs: ["/tmp"], recursive: true)

assert {:ok,
[
~c"-e",
~c"modify",
~c"-e",
~c"close_write",
~c"-e",
~c"moved_to",
~c"-e",
~c"moved_from",
~c"-e",
~c"create",
~c"-e",
~c"delete",
~c"-e",
~c"attrib",
~c"--format",
[37, 119, 1, 37, 101, 1, 37, 102],
~c"--quiet",
~c"-m",
~c"/tmp"
]} ==
parse_options(dirs: ["/tmp"], recursive: false)
end

test "ignore unsupported options" do
assert {:ok,
[
~c"-e",
~c"modify",
~c"-e",
~c"close_write",
~c"-e",
~c"moved_to",
~c"-e",
~c"moved_from",
~c"-e",
~c"create",
~c"-e",
~c"delete",
~c"-e",
~c"attrib",
~c"--format",
[37, 119, 1, 37, 101, 1, 37, 102],
~c"--quiet",
~c"-m",
~c"/tmp"
]} ==
parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options)

assert {:ok,
[
~c"-e",
~c"modify",
~c"-e",
~c"close_write",
~c"-e",
~c"moved_to",
~c"-e",
~c"moved_from",
~c"-e",
~c"create",
~c"-e",
~c"delete",
~c"-e",
~c"attrib",
~c"--format",
[37, 119, 1, 37, 101, 1, 37, 102],
~c"--quiet",
~c"-m",
~c"-r",
~c"/tmp"
]} ==
parse_options(dirs: ["/tmp"], recursive: :unknown_value)
end
end

describe "port line parse test" do
Expand Down
Loading