Skip to content

Commit 2b0c7f1

Browse files
authored
fix ci (#90)
* 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
1 parent 24d9655 commit 2b0c7f1

11 files changed

+323
-115
lines changed

.github/workflows/ci-macos.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI (Macos)
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
test:
11+
runs-on: macos-latest
12+
env:
13+
MIX_ENV: test
14+
strategy:
15+
fail-fast: false
16+
steps:
17+
- name: Set up Homebrew
18+
id: set-up-homebrew
19+
uses: Homebrew/actions/setup-homebrew@master
20+
21+
- name: Install Elixir
22+
env:
23+
HOMEBREW_NO_AUTO_UPDATE: 1
24+
run: brew install elixir
25+
26+
- uses: actions/checkout@v3
27+
28+
- run: mix deps.get
29+
30+
- run: mix format --check-formatted
31+
32+
- run: mix deps.unlock --check-unused
33+
34+
- run: mix deps.compile
35+
36+
- run: mix compile --warnings-as-errors
37+
38+
- run: mix test --only os_macos

.github/workflows/ci.yml renamed to .github/workflows/ci-ubuntu.yml

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: CI (Ubuntu)
22

33
on:
44
pull_request:
@@ -23,21 +23,15 @@ jobs:
2323
otp: 26.1
2424
lint: lint
2525
steps:
26-
- uses: actions/checkout@v3
26+
- name: Install inotify-tools
27+
run: sudo apt-get update && sudo apt-get install -y inotify-tools
2728

2829
- uses: erlef/setup-beam@v1
2930
with:
3031
otp-version: ${{matrix.pair.otp}}
3132
elixir-version: ${{matrix.pair.elixir}}
3233

33-
- uses: actions/cache@v3
34-
with:
35-
path: |
36-
deps
37-
_build
38-
key: ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}-${{ hashFiles('**/mix.lock') }}
39-
restore-keys: |
40-
${{ runner.os }}-mix-
34+
- uses: actions/checkout@v3
4135

4236
- run: mix deps.get
4337

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

55-
- run: mix test
49+
- run: mix test --only os_linux

.github/workflows/ci-windows.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI (Windows)
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
test:
11+
runs-on: windows-latest
12+
env:
13+
MIX_ENV: test
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- pair:
19+
elixir: 1.12.3
20+
otp: 23.3
21+
- pair:
22+
elixir: 1.15.7
23+
otp: 26.1
24+
25+
steps:
26+
- uses: erlef/setup-beam@v1
27+
with:
28+
otp-version: ${{matrix.pair.otp}}
29+
elixir-version: ${{matrix.pair.elixir}}
30+
31+
- uses: actions/checkout@v3
32+
33+
- run: mix deps.get
34+
35+
- run: mix deps.compile
36+
37+
- run: mix compile
38+
39+
- run: mix test --only os_windows

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ file_system-*.tar
2626
/tmp
2727

2828
# Misc
29-
/priv/mac_listener
29+
/priv/mac_listener*
3030
/priv/kqueue
3131
mix.lock

lib/file_system/worker.ex

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require Logger
2+
13
defmodule FileSystem.Worker do
24
@moduledoc """
35
FileSystem Worker Process with the backend GenServer, receive events from Port Process
@@ -20,7 +22,9 @@ defmodule FileSystem.Worker do
2022
{:ok, backend_pid} <- backend.start_link([{:worker_pid, self()} | rest]) do
2123
{:ok, %{backend_pid: backend_pid, subscribers: %{}}}
2224
else
23-
_ -> :ignore
25+
reason ->
26+
Logger.warning("Not able to start file_system worker, reason: #{inspect(reason)}")
27+
:ignore
2428
end
2529
end
2630

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
defmodule FileSystem.Backends.FSInotifyLinuxTest do
2+
use ExUnit.Case, async: true
3+
import FileSystem.Backends.FSInotify
4+
5+
@moduletag os_inux: true
6+
7+
describe "options parse test" do
8+
test "supported options" do
9+
assert {:ok,
10+
[
11+
~c"-e",
12+
~c"modify",
13+
~c"-e",
14+
~c"close_write",
15+
~c"-e",
16+
~c"moved_to",
17+
~c"-e",
18+
~c"moved_from",
19+
~c"-e",
20+
~c"create",
21+
~c"-e",
22+
~c"delete",
23+
~c"-e",
24+
~c"attrib",
25+
~c"--format",
26+
[37, 119, 1, 37, 101, 1, 37, 102],
27+
~c"--quiet",
28+
~c"-m",
29+
~c"-r",
30+
~c"/tmp"
31+
]} ==
32+
parse_options(dirs: ["/tmp"], recursive: true)
33+
34+
assert {:ok,
35+
[
36+
~c"-e",
37+
~c"modify",
38+
~c"-e",
39+
~c"close_write",
40+
~c"-e",
41+
~c"moved_to",
42+
~c"-e",
43+
~c"moved_from",
44+
~c"-e",
45+
~c"create",
46+
~c"-e",
47+
~c"delete",
48+
~c"-e",
49+
~c"attrib",
50+
~c"--format",
51+
[37, 119, 1, 37, 101, 1, 37, 102],
52+
~c"--quiet",
53+
~c"-m",
54+
~c"/tmp"
55+
]} ==
56+
parse_options(dirs: ["/tmp"], recursive: false)
57+
end
58+
59+
test "ignore unsupported options" do
60+
assert {:ok,
61+
[
62+
~c"-e",
63+
~c"modify",
64+
~c"-e",
65+
~c"close_write",
66+
~c"-e",
67+
~c"moved_to",
68+
~c"-e",
69+
~c"moved_from",
70+
~c"-e",
71+
~c"create",
72+
~c"-e",
73+
~c"delete",
74+
~c"-e",
75+
~c"attrib",
76+
~c"--format",
77+
[37, 119, 1, 37, 101, 1, 37, 102],
78+
~c"--quiet",
79+
~c"-m",
80+
~c"/tmp"
81+
]} ==
82+
parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options)
83+
84+
assert {:ok,
85+
[
86+
~c"-e",
87+
~c"modify",
88+
~c"-e",
89+
~c"close_write",
90+
~c"-e",
91+
~c"moved_to",
92+
~c"-e",
93+
~c"moved_from",
94+
~c"-e",
95+
~c"create",
96+
~c"-e",
97+
~c"delete",
98+
~c"-e",
99+
~c"attrib",
100+
~c"--format",
101+
[37, 119, 1, 37, 101, 1, 37, 102],
102+
~c"--quiet",
103+
~c"-m",
104+
~c"-r",
105+
~c"/tmp"
106+
]} ==
107+
parse_options(dirs: ["/tmp"], recursive: :unknown_value)
108+
end
109+
end
110+
end

test/backends/fs_inotify_test.exs

+2-102
Original file line numberDiff line numberDiff line change
@@ -2,113 +2,13 @@ defmodule FileSystem.Backends.FSInotifyTest do
22
use ExUnit.Case, async: true
33
import FileSystem.Backends.FSInotify
44

5+
@moduletag os_inux: true, os_windows: true
6+
57
describe "options parse test" do
68
test "without :dirs" do
79
assert {:error, _} = parse_options([])
810
assert {:error, _} = parse_options(recursive: 1)
911
end
10-
11-
test "supported options" do
12-
assert {:ok,
13-
[
14-
~c"-e",
15-
~c"modify",
16-
~c"-e",
17-
~c"close_write",
18-
~c"-e",
19-
~c"moved_to",
20-
~c"-e",
21-
~c"moved_from",
22-
~c"-e",
23-
~c"create",
24-
~c"-e",
25-
~c"delete",
26-
~c"-e",
27-
~c"attrib",
28-
~c"--format",
29-
[37, 119, 1, 37, 101, 1, 37, 102],
30-
~c"--quiet",
31-
~c"-m",
32-
~c"-r",
33-
~c"/tmp"
34-
]} ==
35-
parse_options(dirs: ["/tmp"], recursive: true)
36-
37-
assert {:ok,
38-
[
39-
~c"-e",
40-
~c"modify",
41-
~c"-e",
42-
~c"close_write",
43-
~c"-e",
44-
~c"moved_to",
45-
~c"-e",
46-
~c"moved_from",
47-
~c"-e",
48-
~c"create",
49-
~c"-e",
50-
~c"delete",
51-
~c"-e",
52-
~c"attrib",
53-
~c"--format",
54-
[37, 119, 1, 37, 101, 1, 37, 102],
55-
~c"--quiet",
56-
~c"-m",
57-
~c"/tmp"
58-
]} ==
59-
parse_options(dirs: ["/tmp"], recursive: false)
60-
end
61-
62-
test "ignore unsupported options" do
63-
assert {:ok,
64-
[
65-
~c"-e",
66-
~c"modify",
67-
~c"-e",
68-
~c"close_write",
69-
~c"-e",
70-
~c"moved_to",
71-
~c"-e",
72-
~c"moved_from",
73-
~c"-e",
74-
~c"create",
75-
~c"-e",
76-
~c"delete",
77-
~c"-e",
78-
~c"attrib",
79-
~c"--format",
80-
[37, 119, 1, 37, 101, 1, 37, 102],
81-
~c"--quiet",
82-
~c"-m",
83-
~c"/tmp"
84-
]} ==
85-
parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options)
86-
87-
assert {:ok,
88-
[
89-
~c"-e",
90-
~c"modify",
91-
~c"-e",
92-
~c"close_write",
93-
~c"-e",
94-
~c"moved_to",
95-
~c"-e",
96-
~c"moved_from",
97-
~c"-e",
98-
~c"create",
99-
~c"-e",
100-
~c"delete",
101-
~c"-e",
102-
~c"attrib",
103-
~c"--format",
104-
[37, 119, 1, 37, 101, 1, 37, 102],
105-
~c"--quiet",
106-
~c"-m",
107-
~c"-r",
108-
~c"/tmp"
109-
]} ==
110-
parse_options(dirs: ["/tmp"], recursive: :unknown_value)
111-
end
11212
end
11313

11414
describe "port line parse test" do

0 commit comments

Comments
 (0)