diff --git a/.github/workflows/test-lint-rust.yml b/.github/workflows/ci-rust.yml similarity index 95% rename from .github/workflows/test-lint-rust.yml rename to .github/workflows/ci-rust.yml index cfa1ff00..124d23c4 100644 --- a/.github/workflows/test-lint-rust.yml +++ b/.github/workflows/ci-rust.yml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Rust Linter and Tests +name: Rust NIF on: push: @@ -22,7 +22,7 @@ on: jobs: test: - name: Rust tests and linter + name: Tests and linter runs-on: ubuntu-latest steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3c04df0c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,168 @@ +# Copyright 2022 Giuseppe De Palma, Matteo Trentin +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Elixir + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + MIX_ENV: test + +jobs: + lint: + name: Lint check + runs-on: ubuntu-latest + strategy: + matrix: + elixir: [1.14] + otp: [25] + + steps: + - uses: actions/checkout@v3 + + - name: Setup Elixir/OTP + uses: erlef/setup-beam@v1 + with: + otp-version: "=${{ matrix.otp }}" + elixir-version: ${{ matrix.elixir }} + install-hex: true + install-rebar: true + + - name: Retrieve Mix Dependencies Cache + uses: actions/cache@v1 + id: mix-cache # id to use in retrieve action + with: + path: deps + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + + - name: Install Mix Dependencies (if deps cache miss) + if: steps.mix-cache.outputs.cache-hit != 'true' + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get + + - name: Check Formatting + run: mix format --check-formatted + + - name: Run Credo + run: mix credo --strict + + unit-test: + name: Unit Tests + strategy: + matrix: + os: [ubuntu-20.04, windows-2019, macos-10.15] + elixir: [1.14] + otp: [25] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + + - name: Setup Elixir/OTP + if: ${{ startswith(matrix.os, 'ubuntu') || startswith(matrix.os, 'windows') }} + uses: erlef/setup-beam@v1 + with: + otp-version: "=${{ matrix.otp }}" + elixir-version: ${{ matrix.elixir }} + install-hex: true + install-rebar: true + - name: Setup Elixir/OTP + if: ${{ startswith(matrix.os, 'macos') }} + run: | + brew install erlang + brew install elixir + + - name: Retrieve Mix Dependencies Cache + uses: actions/cache@v1 + id: mix-cache # id to use in retrieve action + with: + path: deps + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + + - name: Install Rebar and Hex + run: | + mix local.rebar --force + mix local.hex --force + - name: Install Mix Dependencies (if deps cache miss) + if: steps.mix-cache.outputs.cache-hit != 'true' + run: | + mix do deps.get, deps.compile + + - name: Run Core Unit Tests + run: mix core.test + + - name: Run Worker Tests + run: mix worker.test + + integration-test: + name: Integration Tests + strategy: + matrix: + os: [ubuntu-20.04] + elixir: [1.14] + otp: [25] + + runs-on: ${{ matrix.os }} + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: core_test + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + env: + MIX_ENV: test + + steps: + - uses: actions/checkout@v3 + + - name: Setup Elixir/OTP + if: ${{ startswith(matrix.os, 'ubuntu') || startswith(matrix.os, 'windows') }} + uses: erlef/setup-beam@v1 + with: + otp-version: "=${{ matrix.otp }}" + elixir-version: ${{ matrix.elixir }} + install-hex: true + install-rebar: true + - name: Setup Elixir/OTP + if: ${{ startswith(matrix.os, 'macos') }} + run: | + brew install erlang + brew install elixir + + - name: Retrieve Mix Dependencies Cache + uses: actions/cache@v1 + id: mix-cache # id to use in retrieve action + with: + path: deps + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + + - name: Install Mix Dependencies (if deps cache miss) + if: steps.mix-cache.outputs.cache-hit != 'true' + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get + + - name: Run Core Integration Tests + run: mix core.integration_test diff --git a/.github/workflows/dialyzer.yml b/.github/workflows/dialyzer.yml index 685f34b2..9c61ca61 100644 --- a/.github/workflows/dialyzer.yml +++ b/.github/workflows/dialyzer.yml @@ -24,18 +24,35 @@ jobs: dialyzer: name: Dialyzer check runs-on: ubuntu-latest + strategy: + matrix: + elixir: [1.14] + otp: [25] steps: - uses: actions/checkout@v3 - - name: Set up Elixir - id: beam + + - name: Setup Elixir/OTP uses: erlef/setup-beam@v1 with: - elixir-version: 1.14 - otp-version: 25 + otp-version: "=${{ matrix.otp }}" + elixir-version: ${{ matrix.elixir }} + install-hex: true + install-rebar: true + + - name: Retrieve Mix Dependencies Cache + uses: actions/cache@v1 + id: mix-cache # id to use in retrieve action + with: + path: deps + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - - name: Install Dependencies - run: mix deps.get + - name: Install Mix Dependencies (if deps cache miss) + if: steps.mix-cache.outputs.cache-hit != 'true' + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get # Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones # Cache key based on Elixir & Erlang version (also useful when running in matrix) diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index ff97bd77..021006bd 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Check License Headers +name: License Headers on: push: @@ -22,7 +22,7 @@ on: jobs: license: - name: Check license headers + name: Check headers runs-on: ubuntu-latest steps: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index c4b6ec23..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2022 Giuseppe De Palma, Matteo Trentin -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: Elixir Linter and Formatter - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - linter: - name: Linter and formatting - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: 1.14 - otp-version: 25.0 - - - name: Install Dependencies - run: mix deps.get - - - name: Check formatting - run: mix format --check-formatted - - - name: Run Mix Credo - run: mix credo --strict diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 99df9d1b..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright 2022 Giuseppe De Palma, Matteo Trentin -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: Elixir Tests - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - test: - name: Test - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: 1.14 - otp-version: 25.0 - - - name: Install Dependencies - run: mix deps.get - - - name: Run Core Unit Tests - run: mix core.test - - - name: Run Worker Tests - run: mix worker.test - - test_with_db: - name: Integration Test - runs-on: ubuntu-latest - - services: - postgres: - image: postgres:latest - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: core_test - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - env: - MIX_ENV: test - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: 1.14 - otp-version: 25.0 - - - name: Install Dependencies - run: mix deps.get - - - name: Run Core Integration Tests - run: mix core.integration_test diff --git a/.licenserc.yaml b/.licenserc.yaml index d4f8464f..aca9038a 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -19,21 +19,21 @@ header: copyright-owner: Giuseppe De Palma, Matteo Trentin paths-ignore: - - '**/LICENSE' - - '**/.*-version' - - '**/.task/**' - - '**/build/**' - - '**/target/**' - - '**/pres/**' - - '**/task/**' - - 'workspace.code-workspace' - - 'CODEOWNERS' - - '.gitkeep' - - '.gitmodules' - - '**/aliases' - - '**/native/scheduler/.cargo/**' + - "**/LICENSE" + - "**/.*-version" + - "**/.task/**" + - "**/build/**" + - "**/target/**" + - "**/pres/**" + - "**/task/**" + - "workspace.code-workspace" + - "CODEOWNERS" + - ".gitkeep" + - ".gitmodules" + - "**/aliases" + - "**/apps/worker/native/fn_wasm/.cargo/*" - "**/*.lock" - "**/*.svg" - - '.formatter.exs' + - ".formatter.exs" - comment: on-failure \ No newline at end of file + comment: on-failure diff --git a/apps/worker/native/fn_wasm/.cargo/config b/apps/worker/native/fn_wasm/.cargo/config new file mode 100644 index 00000000..cdeabe8e --- /dev/null +++ b/apps/worker/native/fn_wasm/.cargo/config @@ -0,0 +1,21 @@ +[target.x86_64-apple-darwin] +rustflags = [ + "-C", "link-arg=-undefined", + "-C", "link-arg=dynamic_lookup", +] + +[target.aarch64-apple-darwin] +rustflags = [ + "-C", "link-arg=-undefined", + "-C", "link-arg=dynamic_lookup", +] + +[target.x86_64-unknown-linux-musl] +rustflags = [ + "-C", "target-feature=-crt-static" +] + +[target.aarch64-unknown-linux-musl] +rustflags = [ + "-C", "target-feature=-crt-static" +] \ No newline at end of file diff --git a/apps/worker/native/fn_wasm/Cargo.toml b/apps/worker/native/fn_wasm/Cargo.toml index 76241926..626b3278 100644 --- a/apps/worker/native/fn_wasm/Cargo.toml +++ b/apps/worker/native/fn_wasm/Cargo.toml @@ -23,7 +23,7 @@ path = "src/lib.rs" crate-type = ["cdylib", "lib"] [dependencies] -rustler = "0.26.0" +rustler = "0.27.0" wasmtime = "3.0.0" wasmtime-wasi = "3.0.0" wasi-common = "3.0.0" \ No newline at end of file diff --git a/mix.exs b/mix.exs index 3acd738e..8079ab30 100644 --- a/mix.exs +++ b/mix.exs @@ -22,7 +22,7 @@ defmodule Core.Umbrella.MixProject do start_permanent: Mix.env() == :prod, dialyzer: [ plt_file: {:no_warn, "priv/plts/dialyzer.plt"}, - plt_add_apps: [:ex_unit, :mix, :mnesia] + plt_add_apps: [:ex_unit, :mix] ], deps: deps(), aliases: aliases(),