Skip to content

Commit 689c0f8

Browse files
Merge branch 'main' into ft/addjsscr
2 parents e484b6f + b49a942 commit 689c0f8

File tree

14 files changed

+279
-237
lines changed

14 files changed

+279
-237
lines changed

.github/workflows/deploy.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Elixir CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
name: Run Tests
12+
services:
13+
db:
14+
image: postgres:14
15+
env:
16+
POSTGRES_USER: postgres
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: postgres
19+
ports: ['5432:5432']
20+
options: >-
21+
--health-cmd pg_isready
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: erlef/setup-beam@v1
28+
with:
29+
otp-version: '26'
30+
elixir-version: 'v1.14-otp-26'
31+
- name: Cache dependencies
32+
uses: actions/cache@v2
33+
with:
34+
path: deps
35+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-mix-
38+
- name: Install Dependencies
39+
run: mix deps.get
40+
- name: Start Hasura GraphQL Engine
41+
env:
42+
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
43+
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
44+
HASURA_GRAPHQL_DEV_MODE: "true"
45+
HASURA_GRAPHQL_ADMIN_SECRET: helloworld
46+
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: visitor
47+
HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES: "true"
48+
run: |
49+
docker run -d --name graphql-engine --network host \
50+
-e HASURA_GRAPHQL_METADATA_DATABASE_URL=${{ env.HASURA_GRAPHQL_METADATA_DATABASE_URL }} \
51+
-e HASURA_GRAPHQL_ENABLE_CONSOLE=${{ env.HASURA_GRAPHQL_ENABLE_CONSOLE }} \
52+
-e HASURA_GRAPHQL_DEV_MODE=${{ env.HASURA_GRAPHQL_DEV_MODE }} \
53+
-e HASURA_GRAPHQL_ADMIN_SECRET=${{ env.HASURA_GRAPHQL_ADMIN_SECRET }} \
54+
-e HASURA_GRAPHQL_UNAUTHORIZED_ROLE=${{ env.HASURA_GRAPHQL_UNAUTHORIZED_ROLE }} \
55+
-e HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES=${{ env.HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES }} \
56+
hasura/graphql-engine:v2.40.0
57+
- name: Run Tests
58+
run: mix test
59+
60+
build:
61+
runs-on: ubuntu-latest
62+
needs: test
63+
steps:
64+
- uses: actions/checkout@v2
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v1
67+
- name: Log in to GitHub Container Registry
68+
uses: docker/login-action@v1
69+
with:
70+
registry: ghcr.io
71+
username: ${{ github.actor }}
72+
password: ${{ secrets.GITHUB_TOKEN }}
73+
- name: Build and Push Docker Image
74+
uses: docker/build-push-action@v2
75+
with:
76+
context: .
77+
push: true
78+
tags: ghcr.io/${{ github.repository_owner }}/my_phoenix_app:${{ github.sha }}
79+
80+
deploy:
81+
runs-on: ubuntu-latest
82+
needs: build
83+
steps:
84+
- name: Deploy to Digital Ocean
85+
uses: appleboy/ssh-action@master
86+
with:
87+
host: ${{ secrets.DIGITAL_OCEAN_HOST }}
88+
username: ${{ secrets.DIGITAL_OCEAN_USERNAME }}
89+
key: ${{ secrets.DIGITAL_OCEAN_SSH_KEY }}
90+
script: |
91+
docker pull ghcr.io/${{ github.repository_owner }}/my_phoenix_app:${{ github.sha }}
92+
docker stop my_phoenix_app || true
93+
docker rm my_phoenix_app || true
94+
docker run -d --name my_phoenix_app -p 80:4000 ghcr.io/${{ github.repository_owner }}/my_phoenix_app:${{ github.sha }}

.github/workflows/test-build.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Test Build Process
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
name: Run Tests
12+
services:
13+
db:
14+
image: postgres:14
15+
env:
16+
POSTGRES_USER: postgres
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: postgres
19+
ports: ['5432:5432']
20+
options: >-
21+
--health-cmd pg_isready
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: erlef/setup-beam@v1
28+
with:
29+
otp-version: '26'
30+
elixir-version: 'v1.14-otp-26'
31+
- name: Cache dependencies
32+
uses: actions/cache@v2
33+
with:
34+
path: deps
35+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-mix-
38+
- name: Install Dependencies
39+
run: mix deps.get
40+
- name: Start Hasura GraphQL Engine
41+
env:
42+
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
43+
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
44+
HASURA_GRAPHQL_DEV_MODE: "true"
45+
HASURA_GRAPHQL_ADMIN_SECRET: helloworld
46+
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: visitor
47+
HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES: "true"
48+
run: |
49+
docker run -d --name graphql-engine --network host \
50+
-e HASURA_GRAPHQL_METADATA_DATABASE_URL=${{ env.HASURA_GRAPHQL_METADATA_DATABASE_URL }} \
51+
-e HASURA_GRAPHQL_ENABLE_CONSOLE=${{ env.HASURA_GRAPHQL_ENABLE_CONSOLE }} \
52+
-e HASURA_GRAPHQL_DEV_MODE=${{ env.HASURA_GRAPHQL_DEV_MODE }} \
53+
-e HASURA_GRAPHQL_ADMIN_SECRET=${{ env.HASURA_GRAPHQL_ADMIN_SECRET }} \
54+
-e HASURA_GRAPHQL_UNAUTHORIZED_ROLE=${{ env.HASURA_GRAPHQL_UNAUTHORIZED_ROLE }} \
55+
-e HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES=${{ env.HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES }} \
56+
hasura/graphql-engine:v2.40.0
57+
- name: Run Tests
58+
run: mix test
59+
60+
build:
61+
runs-on: ubuntu-latest
62+
needs: test
63+
steps:
64+
- uses: actions/checkout@v2
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v1
67+
- name: Log in to GitHub Container Registry
68+
uses: docker/login-action@v1
69+
with:
70+
registry: ghcr.io
71+
username: ${{ github.actor }}
72+
password: ${{ secrets.GITHUB_TOKEN }}
73+
- name: Build Docker Image
74+
uses: docker/build-push-action@v2
75+
with:
76+
context: .
77+
push: false
78+
tags: ghcr.io/${{ github.repository_owner }}/my_phoenix_app:test-${{ github.sha }}

lib/fileonchain_web/components/core_components.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,11 @@ defmodule FileonchainWeb.CoreComponents do
474474
end
475475

476476
~H"""
477-
<div class="overflow-y-auto px-4 sm:overflow-visible sm:px-0">
478-
<table class="w-[40rem] mt-11 sm:w-full">
477+
<div class="overflow-y-auto px-4 sm:overflow-visible sm:px-0 mt-6 bg-brand-800 rounded-lg">
478+
<table class="w-full mt-11 sm:w-full">
479479
<thead class="text-sm text-left leading-6 text-brand-200">
480480
<tr>
481-
<th :for={col <- @col} class="p-0 pb-4 pr-6 font-normal"><%= col[:label] %></th>
481+
<th :for={col <- @col} class="pb-4 pr-6 font-normal p-4 border-b border-brand-700"><%= col[:label] %></th>
482482
<th :if={@action != []} class="relative p-0 pb-4">
483483
<span class="sr-only"><%= gettext("Actions") %></span>
484484
</th>

lib/fileonchain_web/components/layouts/app.html.heex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
</a>
1212
</div>
1313
<div class="flex items-center gap-4">
14-
<a href="https://twitter.com/fileonchain" class="hover:text-brand-400">
14+
<a href="https://twitter.com/fileonchain" class="hover:text-brand-400" target="_blank" rel="noopener noreferrer">
1515
@fileonchain
1616
</a>
17-
<a href="https://github.com/fileonchain/fileonchain" class="hover:text-brand-400">
17+
<a href="https://github.com/fileonchain/fileonchain" class="hover:text-brand-400" target="_blank" rel="noopener noreferrer">
1818
GitHub
1919
</a>
2020
<a href="https://hexdocs.pm/phoenix/overview.html" class="rounded-lg bg-brand-700 px-2 py-1 hover:bg-brand-600">

lib/fileonchain_web/live/file_live/index.html.heex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
id="files"
1313
rows={@streams.files}
1414
row_click={fn {_id, file} -> JS.navigate(~p"/files/#{file}") end}
15-
class="w-full mt-6 bg-brand-800 rounded-lg"
1615
>
17-
<:col :let={{_id, file}} label="Filename" class="p-4 border-b border-brand-700"><%= file.filename %></:col>
18-
<:col :let={{_id, file}} label="Preview" class="p-4 border-b border-brand-700">
16+
<:col :let={{_id, file}} label="Filename"><%= file.filename %></:col>
17+
<:col :let={{_id, file}} label="Preview">
1918
<%= raw(render_file_preview(file)) %>
2019
</:col>
2120
<:col :let={{_id, file}} label="Size" class="p-4 border-b border-brand-700"><%= format_file_size(file.data) %></:col>

mix.exs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,35 @@ defmodule Fileonchain.MixProject do
3232
# Type `mix help deps` for examples and options.
3333
defp deps do
3434
[
35-
{:bcrypt_elixir, "~> 3.0"},
35+
{:bcrypt_elixir, "~> 3.1.0"},
3636
{:phoenix, "~> 1.7.14"},
37-
{:phoenix_ecto, "~> 4.5"},
38-
{:ecto_sql, "~> 3.10"},
39-
{:postgrex, ">= 0.0.0"},
40-
{:phoenix_html, "~> 4.1"},
41-
{:phoenix_live_reload, "~> 1.2", only: :dev},
37+
{:phoenix_ecto, "~> 4.6.2"},
38+
{:ecto_sql, "~> 3.12.0"},
39+
{:postgrex, ">= 0.19.1"},
40+
{:phoenix_html, "~> 4.1.1"},
41+
{:phoenix_live_reload, "~> 1.5.3", only: :dev},
4242
# TODO bump on release to {:phoenix_live_view, "~> 1.0.0"},
43-
{:phoenix_live_view, "~> 1.0.0-rc.1", override: true},
43+
{:phoenix_live_view, "~> 1.0.0-rc.6", override: true},
4444
{:phoenix_live_view_dropzone, "~> 0.0.13"},
45-
{:floki, ">= 0.30.0", only: :test},
46-
{:phoenix_live_dashboard, "~> 0.8.3"},
47-
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
48-
{:tailwind, "~> 0.2", runtime: Mix.env() == :dev},
45+
{:floki, ">= 0.36.2", only: :test},
46+
{:phoenix_live_dashboard, "~> 0.8.4"},
47+
{:esbuild, "~> 0.8.1", runtime: Mix.env() == :dev},
48+
{:tailwind, "~> 0.2.3", runtime: Mix.env() == :dev},
4949
{:heroicons,
5050
github: "tailwindlabs/heroicons",
5151
tag: "v2.1.1",
5252
sparse: "optimized",
5353
app: false,
5454
compile: false,
5555
depth: 1},
56-
{:swoosh, "~> 1.5"},
57-
{:finch, "~> 0.13"},
56+
{:swoosh, "~> 1.16.12"},
57+
{:finch, "~> 0.18"},
5858
{:telemetry_metrics, "~> 1.0"},
59-
{:telemetry_poller, "~> 1.0"},
60-
{:gettext, "~> 0.20"},
61-
{:jason, "~> 1.2"},
62-
{:dns_cluster, "~> 0.1.1"},
63-
{:bandit, "~> 1.5"},
59+
{:telemetry_poller, "~> 1.1.0"},
60+
{:gettext, "~> 0.26.1"},
61+
{:jason, "~> 1.4.4"},
62+
{:dns_cluster, "~> 0.1.3"},
63+
{:bandit, "~> 1.5.7"},
6464
{:blake3, "~> 1.0.0"}
6565
]
6666
end

test/fileonchain/chunks_test.exs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
defmodule Fileonchain.ChunksTest do
2+
use Fileonchain.DataCase
3+
4+
alias Fileonchain.Chunks
5+
6+
describe "chunks" do
7+
alias Fileonchain.Chunks.Chunk
8+
9+
import Fileonchain.ChunksFixtures
10+
11+
@invalid_attrs %{data: nil, chunk: nil}
12+
13+
test "list_chunks/0 returns all chunks" do
14+
chunk = chunk_fixture()
15+
assert Chunks.list_chunks() == [chunk]
16+
end
17+
18+
test "get_chunk!/1 returns the chunk with given id" do
19+
chunk = chunk_fixture()
20+
assert Chunks.get_chunk!(chunk.id) == chunk
21+
end
22+
23+
test "create_chunk/1 with valid data creates a chunk" do
24+
valid_attrs = %{hash: "some hash", cid: "some cid", data: "some data"}
25+
26+
assert {:ok, %Chunk{} = chunk} = Chunks.create_chunk(valid_attrs)
27+
assert chunk.hash == "some hash"
28+
assert chunk.cid == "some cid"
29+
assert chunk.data == "some data"
30+
end
31+
32+
test "create_chunk/1 with invalid data returns error changeset" do
33+
assert {:error, %Ecto.Changeset{}} = Chunks.create_chunk(@invalid_attrs)
34+
end
35+
end
36+
end

test/fileonchain/cids_test.exs

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)