GitHub Actions workflow (#2)
* GitHub Actions workflow Signed-off-by: marcin mikołajczak <git@mkljczk.pl> * update test Signed-off-by: marcin mikołajczak <git@mkljczk.pl> --------- Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
aa2597e2f6
commit
be4c307356
7 changed files with 102 additions and 61 deletions
90
.github/workflows/pl.yaml
vendored
Normal file
90
.github/workflows/pl.yaml
vendored
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
# Adapter from https://fly.io/phoenix-files/github-actions-for-elixir-ci/
|
||||||
|
|
||||||
|
name: pl CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "fork" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "fork" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
ELIXIR_VER: 1.15.8
|
||||||
|
POSTGRES_DB: pleroma_test
|
||||||
|
MIX_ENV: test
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:12
|
||||||
|
ports: ['5432:5432']
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: pleroma_test
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
otp: ['26.2.5']
|
||||||
|
elixir: ['1.15.8']
|
||||||
|
steps:
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: sudo apt install -y imagemagick ffmpeg libimage-exiftool-perl
|
||||||
|
|
||||||
|
- name: Set up Elixir
|
||||||
|
uses: erlef/setup-beam@v1
|
||||||
|
with:
|
||||||
|
otp-version: ${{matrix.otp}}
|
||||||
|
elixir-version: ${{matrix.elixir}}
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cache deps
|
||||||
|
id: cache-deps
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-elixir-deps
|
||||||
|
with:
|
||||||
|
path: deps
|
||||||
|
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-mix-${{ env.cache-name }}-
|
||||||
|
|
||||||
|
- name: Cache compiled build
|
||||||
|
id: cache-build
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-compiled-build
|
||||||
|
with:
|
||||||
|
path: _build
|
||||||
|
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-mix-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-mix-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: mix deps.get
|
||||||
|
|
||||||
|
- name: Compiles without warnings
|
||||||
|
run: mix compile --warnings-as-errors
|
||||||
|
|
||||||
|
- name: Check Formatting
|
||||||
|
run: mix format --check-formatted
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
mix ecto.create
|
||||||
|
mix ecto.migrate
|
||||||
|
mix pleroma.test_runner --cover --preload-modules
|
|
@ -5,8 +5,6 @@
|
||||||
defmodule Pleroma.Repo.Migrations.RenameInstanceChat do
|
defmodule Pleroma.Repo.Migrations.RenameInstanceChat do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
alias Pleroma.ConfigDB
|
|
||||||
|
|
||||||
def up, do: :noop
|
def up, do: :noop
|
||||||
def down, do: :noop
|
def down, do: :noop
|
||||||
end
|
end
|
||||||
|
|
|
@ -387,6 +387,7 @@ test "We don't have unexpected tables which may contain objects that are referen
|
||||||
["data_migration_failed_ids"],
|
["data_migration_failed_ids"],
|
||||||
["data_migrations"],
|
["data_migrations"],
|
||||||
["deliveries"],
|
["deliveries"],
|
||||||
|
["domains"],
|
||||||
["filters"],
|
["filters"],
|
||||||
["following_relationships"],
|
["following_relationships"],
|
||||||
["hashtags"],
|
["hashtags"],
|
||||||
|
@ -416,7 +417,8 @@ test "We don't have unexpected tables which may contain objects that are referen
|
||||||
["user_invite_tokens"],
|
["user_invite_tokens"],
|
||||||
["user_notes"],
|
["user_notes"],
|
||||||
["user_relationships"],
|
["user_relationships"],
|
||||||
["users"]
|
["users"],
|
||||||
|
["webhooks"]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ test "it strips voters list and displays voters count instead" do
|
||||||
})
|
})
|
||||||
|
|
||||||
object = Object.normalize(activity, fetch: false)
|
object = Object.normalize(activity, fetch: false)
|
||||||
{:ok, _, _} = CommonAPI.vote(other_user, object, [1])
|
{:ok, _, _} = CommonAPI.vote(object, other_user, [1])
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,8 @@ test "/api/v2/media, upload_limit", %{conn: conn, user: user} do
|
||||||
|
|
||||||
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
||||||
|
|
||||||
|
File.mkdir_p!(Path.absname("test/tmp"))
|
||||||
|
|
||||||
assert :ok ==
|
assert :ok ==
|
||||||
File.write(Path.absname("test/tmp/large_binary.data"), <<0::size(upload_limit)>>)
|
File.write(Path.absname("test/tmp/large_binary.data"), <<0::size(upload_limit)>>)
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,8 @@ test "updates the user's avatar", %{user: user, conn: conn} do
|
||||||
test "updates the user's avatar, upload_limit, returns a HTTP 413", %{conn: conn, user: user} do
|
test "updates the user's avatar, upload_limit, returns a HTTP 413", %{conn: conn, user: user} do
|
||||||
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
||||||
|
|
||||||
|
File.mkdir_p!(Path.absname("test/tmp"))
|
||||||
|
|
||||||
assert :ok ==
|
assert :ok ==
|
||||||
File.write(Path.absname("test/tmp/large_binary.data"), <<0::size(upload_limit)>>)
|
File.write(Path.absname("test/tmp/large_binary.data"), <<0::size(upload_limit)>>)
|
||||||
|
|
||||||
|
@ -354,6 +356,8 @@ test "updates the user's banner", %{user: user, conn: conn} do
|
||||||
test "updates the user's banner, upload_limit, returns a HTTP 413", %{conn: conn, user: user} do
|
test "updates the user's banner, upload_limit, returns a HTTP 413", %{conn: conn, user: user} do
|
||||||
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
||||||
|
|
||||||
|
File.mkdir_p!(Path.absname("test/tmp"))
|
||||||
|
|
||||||
assert :ok ==
|
assert :ok ==
|
||||||
File.write(Path.absname("test/tmp/large_binary.data"), <<0::size(upload_limit)>>)
|
File.write(Path.absname("test/tmp/large_binary.data"), <<0::size(upload_limit)>>)
|
||||||
|
|
||||||
|
@ -406,6 +410,8 @@ test "updates the user's background, upload_limit, returns a HTTP 413", %{
|
||||||
} do
|
} do
|
||||||
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
||||||
|
|
||||||
|
File.mkdir_p!(Path.absname("test/tmp"))
|
||||||
|
|
||||||
assert :ok ==
|
assert :ok ==
|
||||||
File.write(Path.absname("test/tmp/large_binary.data"), <<0::size(upload_limit)>>)
|
File.write(Path.absname("test/tmp/large_binary.data"), <<0::size(upload_limit)>>)
|
||||||
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
# Pleroma: A lightweight social networking server
|
|
||||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
defmodule Pleroma.WebhookTest do
|
|
||||||
use Pleroma.DataCase, async: true
|
|
||||||
|
|
||||||
alias Pleroma.Repo
|
|
||||||
alias Pleroma.Webhook
|
|
||||||
|
|
||||||
test "creating a webhook" do
|
|
||||||
%{id: id} = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
|
||||||
|
|
||||||
assert %{url: "https://example.com/webhook"} = Webhook.get(id)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "editing a webhook" do
|
|
||||||
%{id: id} =
|
|
||||||
webhook = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
|
||||||
|
|
||||||
Webhook.update(webhook, %{events: [:"account.created"]})
|
|
||||||
|
|
||||||
assert %{events: [:"account.created"]} = Webhook.get(id)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "filter webhooks by type" do
|
|
||||||
%{id: id1} =
|
|
||||||
Webhook.create(%{url: "https://example.com/webhook1", events: [:"report.created"]})
|
|
||||||
|
|
||||||
%{id: id2} =
|
|
||||||
Webhook.create(%{
|
|
||||||
url: "https://example.com/webhook2",
|
|
||||||
events: [:"account.created", :"report.created"]
|
|
||||||
})
|
|
||||||
|
|
||||||
Webhook.create(%{url: "https://example.com/webhook3", events: [:"account.created"]})
|
|
||||||
|
|
||||||
assert [%{id: ^id1}, %{id: ^id2}] = Webhook.get_by_type(:"report.created")
|
|
||||||
end
|
|
||||||
|
|
||||||
test "change webhook state" do
|
|
||||||
%{id: id, enabled: true} =
|
|
||||||
webhook = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
|
||||||
|
|
||||||
Webhook.set_enabled(webhook, false)
|
|
||||||
assert %{enabled: false} = Webhook.get(id)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "rotate webhook secrets" do
|
|
||||||
%{id: id, secret: secret} =
|
|
||||||
webhook = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
|
||||||
|
|
||||||
Webhook.rotate_secret(webhook)
|
|
||||||
%{secret: new_secret} = Webhook.get(id)
|
|
||||||
assert secret != new_secret
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue