Skip to content

Commit

Permalink
add generate docs test (#338)
Browse files Browse the repository at this point in the history
* add lint and generate docs to CI

* fix credo warnings

* run rust-ci
  • Loading branch information
satoren authored Jan 22, 2025
1 parent 7c559a2 commit 19c2fe3
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 12 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ on:
push:
branches:
- main
paths:
- 'native/**'
pull_request:
paths:
- 'native/**'
workflow_dispatch:
branches:
- main

jobs:
lint-rust:
Expand Down Expand Up @@ -42,5 +39,5 @@ jobs:
- name: run rustfmt
run: cargo fmt --manifest-path=${{ matrix.manifest }} --all -- --check

# - name: run clippy
# run: cargo clippy --manifest-path=${{ matrix.manifest }}
- name: run clippy
run: cargo clippy --manifest-path=${{ matrix.manifest }}
52 changes: 49 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
pull_request:
branches: [ main ]

env:
MIX_ENV: test
RUSTLER_PRECOMPILATION_MEDIASOUP_BUILD: "true"

jobs:
test:
Expand All @@ -20,6 +17,9 @@ jobs:
matrix:
rust:
- stable
env:
MIX_ENV: test
RUSTLER_PRECOMPILATION_MEDIASOUP_BUILD: "true"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Elixir
Expand Down Expand Up @@ -64,5 +64,51 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Leak check test
run: mix test --include leakcheck

lint:
timeout-minutes: 40
name: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust:
- stable
env:
RUSTLER_PRECOMPILATION_MEDIASOUP_BUILD: "true"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.13.4' # Define the elixir version [required]
otp-version: '25.3' # Define the OTP version [required]
- name: Node.js
uses: actions/setup-node@v4
with:
node-version: '16'
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target
deps
_build
key: ${{ runner.os }}-rust-${{ matrix.rust }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-rust-${{ matrix.rust }}-mix-
- name: Run dialyzer
run: mix dialyzer
- name: generate docs
run: mix docs
- name: credo
run: mix credo
5 changes: 3 additions & 2 deletions lib/nif.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule Mediasoup.Nif do
version = Mix.Project.config()[:version]

defmodule Build do
@moduledoc false
def prebuild_targets() do
# Anything that is difficult to prebuilt in cross compile is excluded for now.
[
Expand All @@ -22,7 +23,7 @@ defmodule Mediasoup.Nif do
]
end

defp is_prebuild_target?() do
defp prebuild_target?() do
case RustlerPrecompiled.target() do
{:ok, target} -> prebuild_targets() |> Enum.any?(&String.contains?(target, &1))
_ -> false
Expand All @@ -32,7 +33,7 @@ defmodule Mediasoup.Nif do
def force_build?(),
do:
System.get_env("RUSTLER_PRECOMPILATION_MEDIASOUP_BUILD") in ["1", "true"] or
not is_prebuild_target?()
not prebuild_target?()
end

use RustlerPrecompiled,
Expand Down
3 changes: 3 additions & 0 deletions test/integration/test_util.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
defmodule Mediasoup.TestUtil do
@moduledoc """
Test utilities
"""
import ExUnit.Assertions

def worker_leak_setup_all(_context \\ %{}) do
Expand Down

0 comments on commit 19c2fe3

Please sign in to comment.