diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e25760..0dcfbbf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,28 +12,42 @@ on: jobs: linux: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + container: ubuntu:20.04 env: MIX_ENV: test + DEBIAN_FRONTEND: noninteractive + ELIXIR_VERSION: "1.17.3" + OTP_VERSION: ${{ matrix.otp_version }} strategy: matrix: - job: - - { otp_version: "26", elixir_version: "1.15" } - - { otp_version: "24", elixir_version: "1.13" } + otp_version: ["27.3.4.10", "25.3.2.21"] - name: Linux x86_64 - OTP ${{ matrix.job.otp_version }} + name: Linux x86_64 - OTP ${{ matrix.otp_version }} steps: + - name: Install system dependencies + run: | + apt-get update + apt-get install -y build-essential ca-certificates curl git unzip + - name: Checkout uses: actions/checkout@v4 - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{ matrix.job.otp_version }} - elixir-version: ${{ matrix.job.elixir_version }} + - name: Install OTP and Elixir + run: | + curl -fsSO https://elixir-lang.org/install.sh + sh install.sh "elixir@${ELIXIR_VERSION}" "otp@${OTP_VERSION}" - name: Compile and Test run: | + export OTP_MAIN_VER="${OTP_VERSION%%.*}" + export PATH=$HOME/.elixir-install/installs/otp/${OTP_VERSION}/bin:$PATH + export PATH=$HOME/.elixir-install/installs/elixir/${ELIXIR_VERSION}-otp-${OTP_MAIN_VER}/bin:$PATH + + mix local.hex --force + mix local.rebar --force + mix deps.get mix elixir_make.precompile mix test @@ -45,8 +59,8 @@ jobs: strategy: matrix: job: - - { otp_version: "26", elixir_version: "1.15" } - - { otp_version: "24", elixir_version: "1.13" } + - { otp_version: "27", elixir_version: "1.17" } + - { otp_version: "25", elixir_version: "1.17" } name: Windows x86_64 - OTP ${{ matrix.job.otp_version }} @@ -71,7 +85,7 @@ jobs: mix test macos: - runs-on: macos-13 + runs-on: macos-15-intel env: MIX_ENV: test ELIXIR_VERSION: "1.16.2" diff --git a/.github/workflows/precompile.yml b/.github/workflows/precompile.yml index 527aafa..3151b83 100644 --- a/.github/workflows/precompile.yml +++ b/.github/workflows/precompile.yml @@ -7,28 +7,25 @@ on: jobs: linux: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + container: ubuntu:20.04 env: MIX_ENV: prod + DEBIAN_FRONTEND: noninteractive + ELIXIR_VERSION: "1.17.3" + OTP_VERSION: ${{ matrix.otp_version }} strategy: matrix: - otp_version: [24] + otp_version: ["25.3.2.21"] name: Linux x86_64 - OTP ${{ matrix.otp_version }} steps: - - name: Checkout - uses: actions/checkout@v4 - - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{ matrix.otp_version }} - elixir-version: 1.13 - - name: Install system dependecies run: | - sudo apt-get update - sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip \ + apt-get update + apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip \ + ca-certificates curl git \ gcc g++ \ gcc-i686-linux-gnu g++-i686-linux-gnu \ gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \ @@ -37,10 +34,26 @@ jobs: gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \ gcc-s390x-linux-gnu g++-s390x-linux-gnu + - name: Checkout + uses: actions/checkout@v4 + + - name: Install OTP and Elixir + run: | + curl -fsSO https://elixir-lang.org/install.sh + sh install.sh "elixir@${ELIXIR_VERSION}" "otp@${OTP_VERSION}" + - name: Precompile run: | + export OTP_MAIN_VER="${OTP_VERSION%%.*}" + export PATH=$HOME/.elixir-install/installs/otp/${OTP_VERSION}/bin:$PATH + export PATH=$HOME/.elixir-install/installs/elixir/${ELIXIR_VERSION}-otp-${OTP_MAIN_VER}/bin:$PATH + export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache mkdir -p "${ELIXIR_MAKE_CACHE_DIR}" + + mix local.hex --force + mix local.rebar --force + mix deps.get mix elixir_make.precompile @@ -52,7 +65,7 @@ jobs: cache/*.sha256 macos: - runs-on: macos-13 + runs-on: macos-15-intel env: MIX_ENV: prod ELIXIR_VERSION: "1.16.0" @@ -100,7 +113,7 @@ jobs: MIX_ENV: prod strategy: matrix: - otp_version: [24] + otp_version: [25] name: Windows x86_64 - OTP ${{ matrix.otp_version }} @@ -111,7 +124,7 @@ jobs: - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} - elixir-version: 1.13 + elixir-version: 1.17 - uses: ilammy/msvc-dev-cmd@v1 with: diff --git a/lib/stb_image.ex b/lib/stb_image.ex index 6bc3695..cefb9f7 100644 --- a/lib/stb_image.ex +++ b/lib/stb_image.ex @@ -113,7 +113,8 @@ defmodule StbImage do defimpl Nx.LazyContainer do def traverse(%StbImage{type: type, shape: shape} = stb_image, acc, fun) do - fun.(Nx.template(shape, type), fn -> StbImage.to_nx(stb_image) end, acc) + template = Nx.template(shape, type, names: [:height, :width, :channels]) + fun.(template, fn -> StbImage.to_nx(stb_image) end, acc) end end end diff --git a/mix.exs b/mix.exs index 067816d..77f62e6 100644 --- a/mix.exs +++ b/mix.exs @@ -40,7 +40,7 @@ defmodule StbImage.MixProject do {:cc_precompiler, "~> 0.1"}, {:elixir_make, "~> 0.8"}, # optional - {:nx, "~> 0.4", optional: true}, + {:nx, "~> 0.4 or ~> 1.0", optional: true}, {:kino, "~> 0.7", optional: true}, # docs {:ex_doc, "~> 0.29", only: :docs, runtime: false} diff --git a/mix.lock b/mix.lock index 772dd79..d0d68bf 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,6 @@ %{ "cc_precompiler": {:hex, :cc_precompiler, "0.1.10", "47c9c08d8869cf09b41da36538f62bc1abd3e19e41701c2cea2675b53c704258", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f6e046254e53cd6b41c6bacd70ae728011aa82b2742a80d6e2214855c6e06b22"}, - "complex": {:hex, :complex, "0.4.2", "923e5db0be13dbb3ea00cf8459d9f75f3afdd9ff5a82742ded21064330d28273", [:mix], [], "hexpm", "069a085ef820ce675a2619fd125b963ff4514af2102c7f7d7965128e5ec0a429"}, + "complex": {:hex, :complex, "1.0.0", "32075df521760e83d808652f52dd57f21712d47d5918a328709da78358387507", [:mix], [], "hexpm", "b4fd7ab305712472521043aa4322f7e4cdd85ca3ddf79c9c2c338d6663adc8d8"}, "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, "elixir_make": {:hex, :elixir_make, "0.8.3", "d38d7ee1578d722d89b4d452a3e36bcfdc644c618f0d063b874661876e708683", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "5c99a18571a756d4af7a4d89ca75c28ac899e6103af6f223982f09ce44942cc9"}, "ex_doc": {:hex, :ex_doc, "0.34.0", "ab95e0775db3df71d30cf8d78728dd9261c355c81382bcd4cefdc74610bef13e", [: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", "60734fb4c1353f270c3286df4a0d51e65a2c1d9fba66af3940847cc65a8066d7"}, @@ -9,6 +9,7 @@ "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"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, - "nx": {:hex, :nx, "0.4.0", "2ec2cebec6a9ac8a3d5ae8ef79345cf92f37f9018d50817684e51e97b86f3d36", [:mix], [{:complex, "~> 0.4.2", [hex: :complex, repo: "hexpm", optional: false]}], "hexpm", "bab955768dadfe2208723fbffc9255341b023291f2aabcbd25bf98167dd3399e"}, + "nx": {:hex, :nx, "1.0.0", "83d586079cb37d11a4cf8c0edaf2eccafe88aa2369e35ebdb1c3d78c43c8eb33", [:mix], [{:complex, "~> 1.0", [hex: :complex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e06c7587efff7a3dfc1e2c92705943e319db20070359e9850c3921aaf26d6998"}, "table": {:hex, :table, "0.1.2", "87ad1125f5b70c5dea0307aa633194083eb5182ec537efc94e96af08937e14a8", [:mix], [], "hexpm", "7e99bc7efef806315c7e65640724bf165c3061cdc5d854060f74468367065029"}, + "telemetry": {:hex, :telemetry, "1.4.2", "a0cb522801dffb1c49fe6e30561badffc7b6d0e180db1300df759faa22062855", [:rebar3], [], "hexpm", "928f6495066506077862c0d1646609eed891a4326bee3126ba54b60af61febb1"}, }