Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci_v29.0.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI v29.0

on:
workflow_call:
pull_request:
branches: ["main"]

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci_v30.0.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI v30.0

on:
workflow_call:
pull_request:
branches: ["main"]

Expand Down Expand Up @@ -41,7 +40,7 @@ jobs:
- typesense: '30.0'
otp: '28'
elixir: '1.18'
lint: true
lint: false
Comment thread
jaeyson marked this conversation as resolved.

services:
typesense:
Expand Down
165 changes: 165 additions & 0 deletions .github/workflows/ci_v30.1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: CI v30.1

on:
workflow_call:
pull_request:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
# Workflows that would otherwise be triggered using `on: push` or
# `on: pull_request` won't be triggered if you add any of the
# following strings to the commit message in a push, or the HEAD
# commit of a pull request:
# - [skip ci]
# - [ci skip]
# - [no ci]
# - [skip actions]
# - [actions skip]

test:
if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request') && github.repository == 'jaeyson/open_api_typesense' }}
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
runs-on: ubuntu-latest
environment: review

env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LATEST_TYPESENSE: '30.1'

strategy:
matrix:
include:
- typesense: '30.1'
otp: '25'
elixir: '1.14'
lint: false
- typesense: '30.1'
otp: '28'
elixir: '1.18'
lint: true

services:
typesense:
image: typesense/typesense:${{ matrix.typesense }}

steps:
- name: Checkout repo
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

- name: Check for misspellings
uses: codespell-project/actions-codespell@8f01853be192eb0f849a5c7d721450e7a467c579

- name: Start Typesense
run: |
docker run -id \
-p 8108:8108 \
--name typesense \
-v /tmp/typesense-data:/data \
-v /tmp/typesense-analytics-data:/analytics-data \
typesense/typesense:${{ matrix.typesense}} \
--api-key xyz \
--data-dir /data \
--enable-search-analytics=true \
--analytics-dir=/analytics-data \
--analytics-flush-interval=60 \
--analytics-minute-rate-limit=100 \
--enable-cors

- name: Wait for Typesense to be healthy
shell: bash
run: |
start_time=$(date +%s)
timeout=30
counter=0
until curl -s http://localhost:8108/health | grep -q '"ok":true'; do
if [ $counter -eq $timeout ]; then
echo "Timed out waiting for Typesense to be healthy"
exit 1
fi
echo "Waiting for Typesense to be healthy..."
sleep 1
counter=$((counter + 1))
done
end_time=$(date +%s)
elapsed=$((end_time - start_time))
echo "Typesense healthcheck elapsed: ${elapsed}s"

- name: Setup Elixir/OTP
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}

- name: Restore cache
id: cache_restore
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7
if: ${{ matrix.lint }}
with:
path: |
deps
_build
priv/plts
key: ${{ runner.os }}-typesense-${{ matrix.typesense}}-${{ matrix.otp}}-${{ matrix.elixir}}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-typesense-${{ matrix.typesense}}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-

- name: Install Dependencies
run: |
mix local.rebar --if-missing
mix local.hex --if-missing
mix deps.get

- name: Find unused dependencies
run: mix deps.unlock --check-unused
if: ${{ matrix.lint }}

- name: Check retired dependencies
run: mix hex.audit
if: ${{ matrix.lint }}

- name: Security audit of dependencies
run: mix deps.audit
if: ${{ matrix.lint }}

- name: Compile project
run: mix compile --all-warnings

- name: Run static analysis
run: mix credo --all --strict
if: ${{ matrix.lint }}

- name: Check format files
run: mix format --check-formatted
if: ${{ matrix.lint }}

- name: Create PLTs
if: ${{ steps.cache_restore.outputs.cache-hit != 'true' && matrix.lint }}
run: mix dialyzer --plt

- name: Dialyzer
run: mix dialyzer --format github --format dialyxir
if: ${{ matrix.lint }}

- name: Run tests
run: mix test --only ${{ matrix.typesense }}:true --only nls:true --trace

- name: Post test coverage to Coveralls
run: mix coveralls.github
if: ${{ matrix.lint && github.event_name == 'push' && github.ref == 'refs/heads/main' }}

- name: Save cache
id: cache_save
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7
if: ${{ matrix.lint }}
with:
path: |
deps
_build
priv/plts
key: |
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
8 changes: 4 additions & 4 deletions .github/workflows/llm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:

jobs:
ci_workflow:
uses: ./.github/workflows/ci_v30.0.yml
uses: ./.github/workflows/ci_v30.1.yml
secrets: inherit

llm:
Expand All @@ -31,15 +31,15 @@ jobs:
- typesense: '30.0'
otp: '25'
elixir: '1.14'
- typesense: '29.0'
otp: '25'
elixir: '1.14'
- typesense: '30.1'
otp: '28'
elixir: '1.18'
- typesense: '30.0'
otp: '28'
elixir: '1.18'
- typesense: '29.0'
otp: '25'
elixir: '1.14'
- typesense: '29.0'
otp: '28'
elixir: '1.18'
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
typesense:
image: docker.io/typesense/typesense:29.0
image: docker.io/typesense/typesense:30.1
container_name: typesense
restart: on-failure
ports:
Expand Down
4 changes: 3 additions & 1 deletion lib/open_api_typesense/operations/analytics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ defmodule OpenApiTypesense.Analytics do
body :: OpenApiTypesense.AnalyticsRuleUpdate.t(),
opts :: keyword
) ::
{:ok, OpenApiTypesense.AnalyticsRule.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
{:ok, OpenApiTypesense.AnalyticsRule.t()}
| {:ok, OpenApiTypesense.AnalyticsRuleSchema.t()}
| {:error, OpenApiTypesense.ApiResponse.t()}
def upsert_analytics_rule(rule_name, body, opts \\ []) do
client = opts[:client] || @default_client

Expand Down
90 changes: 81 additions & 9 deletions test/connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ defmodule ConnectionTest do
message: "Forbidden - a valid `x-typesense-api-key` header must be sent."
}

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "new/0 using the default config to creates a connection struct" do
assert Connection.new() === %Connection{
api_key: "xyz",
Expand All @@ -25,7 +33,15 @@ defmodule ConnectionTest do
}
end

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "new/1 with custom fields creates a connection struct" do
conn =
Connection.new(%{
Expand All @@ -47,7 +63,15 @@ defmodule ConnectionTest do
}
end

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "error: wrong api key was configured" do
conn = %{
host: "localhost",
Expand All @@ -59,7 +83,15 @@ defmodule ConnectionTest do
assert {:error, @forbidden} == Collections.get_collections(conn: conn)
end

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "error: overriding config with a wrong API key" do
conn = %{
host: "localhost",
Expand All @@ -71,34 +103,74 @@ defmodule ConnectionTest do
assert {:error, @forbidden} = Collections.get_collections(conn: conn)
end

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "error: health check, with incorrect port number" do
conn = %{api_key: "xyz", host: "localhost", port: 8100, scheme: "http"}

assert {:error, "connection refused"} = Health.health(conn: conn)
end

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "error: health check, with incorrect host" do
conn = %{api_key: "xyz", host: "my_test_host", port: 8108, scheme: "http"}

assert {:error, "non-existing domain"} = Health.health(conn: conn)
end

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "new/1 with Connection struct" do
conn = Connection.new()
assert %Connection{} = Connection.new(conn)
end

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "new/1 with empty map raises ArgumentError" do
error = assert_raise ArgumentError, fn -> Connection.new(%{}) end

assert error.message === "Missing required fields: [:api_key, :host, :port, :scheme]"
end

@tag ["30.0": true, "29.0": true, "28.0": true, "27.1": true, "27.0": true, "26.0": true]
@tag [
"30.1": true,
"30.0": true,
"29.0": true,
"28.0": true,
"27.1": true,
"27.0": true,
"26.0": true
]
test "new/1 with invalid data type raises ArgumentError" do
invalid_inputs = [
nil,
Expand Down
Loading
Loading