Skip to content

Commit

Permalink
fix ci (#90)
Browse files Browse the repository at this point in the history
* debug start error

* install inotify-tools before run ci

* add warning log once the worker not able to start

* add ci for macos

* try homebrew for macos

* debug macos homebrew

* fix lint

* add ci for windows

* debug ci for windows

* split test by os

* disable lint for windows since the behaviour is different

* add debug code for windows

* remove cache since no dependents to catch

* test file write event

* fix fs_windows missing args

* debug ci for windows

* debug ci for windows

* disable the failing windows test
  • Loading branch information
falood authored Nov 9, 2023
1 parent 24d9655 commit 2b0c7f1
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 115 deletions.
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

0 comments on commit 2b0c7f1

Please sign in to comment.