diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 10b509e..c5501f5 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -7,7 +7,7 @@ env: ELIXIR_VERSION: "1.14.0" jobs: lint: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest name: Lint OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} strategy: matrix: @@ -23,7 +23,7 @@ jobs: - name: Cache Dependencies id: mix-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | deps @@ -42,18 +42,17 @@ jobs: - run: mix deps.get - run: mix deps.unlock --check-unused - run: mix format --check-formatted + - run: (cd go_src/ && test -z $(gofmt -l .)) - run: mix compile --warnings-as-errors - run: mix credo --strict - run: mix dialyzer --plt linux: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest name: Linux OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} strategy: matrix: include: - - elixir: 1.12.x - otp: 23.x - elixir: 1.13.x otp: 24.x - elixir: 1.14.x @@ -61,7 +60,7 @@ jobs: - elixir: 1.15.x otp: 26.x - elixir: 1.16.x - otp: 26.x + otp: 27.x steps: - uses: erlef/setup-beam@v1 with: @@ -71,7 +70,7 @@ jobs: - name: Cache Dependencies id: mix-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | deps @@ -89,7 +88,7 @@ jobs: - run: mix test --trace macos: - runs-on: macos-11 + runs-on: macos-14 steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main @@ -100,23 +99,23 @@ jobs: - run: nix develop --command mix test --trace windows: - runs-on: windows-2019 + runs-on: windows-latest name: Windows OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} strategy: matrix: include: - - elixir: "1.14" - otp: "25" + - elixir: "1.17" + otp: "27" steps: - uses: erlef/setup-beam@v1 with: otp-version: ${{matrix.otp}} elixir-version: ${{matrix.elixir}} - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache Dependencies id: mix-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | deps diff --git a/go_src/executor.go b/go_src/executor.go index 9ddd12a..0ddd5c0 100644 --- a/go_src/executor.go +++ b/go_src/executor.go @@ -75,7 +75,7 @@ func execute(workdir string, args []string, stderrConfig string) error { return err } -func runPipeline(proc *exec.Cmd, writerDone chan struct{}, stdinClose chan struct{}, kill chan<- bool, stderrConfig string){ +func runPipeline(proc *exec.Cmd, writerDone chan struct{}, stdinClose chan struct{}, kill chan<- bool, stderrConfig string) { cmdInput := make(chan []byte, 1) cmdOutputDemand := make(chan Packet) cmdInputDemand := make(chan Packet) @@ -183,7 +183,7 @@ func stdoutWriter(pid int, cmdStdout <-chan []byte, cmdInputDemand <-chan Packet if len(data) > BufferSize { fatal("Invalid payloadLen") - } else if (len(data) == 0) { + } else if len(data) == 0 { // if we are getting EOF then we are done here // there won't be anymore command coming writePacketToStdout(OutputEOF, make([]byte, 0)) @@ -229,7 +229,7 @@ func safeExit(proc *exec.Cmd, procErr <-chan error, kill <-chan bool, timeout ti case err := <-procErr: logger.Printf("Cmd completed with err: %v", err) return err - case <- kill: + case <-kill: if err := proc.Process.Kill(); err != nil { logger.Fatal("failed to kill process: ", err) return err diff --git a/go_src/exit_status.go b/go_src/exit_status.go index a774233..3206fa2 100644 --- a/go_src/exit_status.go +++ b/go_src/exit_status.go @@ -1,3 +1,4 @@ +//go:build !plan9 // +build !plan9 package main diff --git a/go_src/main.go b/go_src/main.go index 1bf37b0..10f8545 100644 --- a/go_src/main.go +++ b/go_src/main.go @@ -1,10 +1,10 @@ package main import ( - "os/exec" "flag" "fmt" "os" + "os/exec" ) // Version of the odu @@ -53,7 +53,7 @@ func main() { // This shouldn't really happen in practice because we check for // program existence in Elixir, before launching odu logger.Printf("Command exited with error: %v", exitError) - } else { + } else { logger.Printf("Command exited with unknown errors", err) } diff --git a/go_src/process.go b/go_src/process.go index 7eb8f17..99a48a3 100644 --- a/go_src/process.go +++ b/go_src/process.go @@ -35,7 +35,7 @@ func startCommandPipeline(proc *exec.Cmd, input <-chan []byte, inputDemand chan< return output } -func writeToCommandStdin(cmdInput io.WriteCloser, input <- chan []byte, inputDemand chan<- Packet) { +func writeToCommandStdin(cmdInput io.WriteCloser, input <-chan []byte, inputDemand chan<- Packet) { var data []byte var ok bool diff --git a/mix.exs b/mix.exs index c8f7376..4d543f7 100644 --- a/mix.exs +++ b/mix.exs @@ -12,6 +12,7 @@ defmodule ExCmd.MixProject do start_permanent: Mix.env() == :prod, deps: deps(), compilers: Mix.compilers() ++ [:odu], + aliases: aliases(), # Ensure dialyzer sees mix modules dialyzer: [plt_add_apps: [:mix]], @@ -53,10 +54,17 @@ defmodule ExCmd.MixProject do ] end - defp deps do + defp aliases do [ - {:gen_state_machine, "~> 3.0"}, + format: [ + "format", + "cmd --cd go_src/ go fmt" + ] + ] + end + defp deps do + [ # development & test {:credo, "~> 1.6", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 1.0", only: [:dev], runtime: false}, diff --git a/mix.lock b/mix.lock index 69e3c90..0736b5c 100644 --- a/mix.lock +++ b/mix.lock @@ -6,7 +6,6 @@ "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "ex_doc": {:hex, :ex_doc, "0.34.1", "9751a0419bc15bc7580c73fde506b17b07f6402a1e5243be9e0f05a68c723368", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d441f1a86a235f59088978eff870de2e815e290e44a8bd976fe5d64470a4c9d2"}, "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, - "gen_state_machine": {:hex, :gen_state_machine, "3.0.0", "1e57f86a494e5c6b14137ebef26a7eb342b3b0070c7135f2d6768ed3f6b6cdff", [:mix], [], "hexpm", "0a59652574bebceb7309f6b749d2a41b45fdeda8dbb4da0791e355dd19f0ed15"}, "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},