Skip to content

Commit 9adb5f5

Browse files
authored
Upload Updates (#7)
* Upload overhaul * Remove unused test * Add migrations module * Fix pipeline in insert_variant * Format * Credo * Add test coverage / use ecto multi * Credo * Use ACL branch of file_store * Add postgres service container for tests * Specify port and user for postgres * Use MIX_ENV=test for repo config * Use verbose ecto dropping to figure out what's going on * Try specifying DB creds * Fix Dialyzer issues and add missing docs * Use dev mode for Dialyzer * Use repo get instead of repo get_by * Pass through errors from ecto multis * Add multiple variants to blob variant removal test * Do not allow keys with periods * Add tests for multi error cases * Use Ecto.Query select to only select the variant field
1 parent 326b563 commit 9adb5f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1590
-1272
lines changed

.github/workflows/build.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Build
2+
23
on: [push]
4+
35
jobs:
46
build:
57
name: Elixir ${{matrix.elixir}} - OTP ${{matrix.otp}}
@@ -12,16 +14,29 @@ jobs:
1214
strategy:
1315
matrix:
1416
elixir:
15-
- "1.12.0"
16-
- "1.13.0"
17+
- "1.16.1"
1718
otp:
18-
- "24.3.4"
19+
- "26.2.2"
1920

2021
services:
2122
fake-s3:
2223
image: lphoward/fake-s3
2324
ports: ["4569:4569"]
2425

26+
postgres:
27+
image: postgres:16
28+
ports:
29+
- 5432:5432
30+
env:
31+
POSTGRES_USER: postgres
32+
POSTGRES_PASSWORD: postgres
33+
POSTGRES_DB: upload_test
34+
options: >-
35+
--health-cmd pg_isready
36+
--health-interval 10s
37+
--health-timeout 5s
38+
--health-retries 5
39+
2540
steps:
2641
- name: Checkout
2742
uses: actions/checkout@v2
@@ -41,6 +56,9 @@ jobs:
4156
- name: Check formatting
4257
run: mix format --check-formatted
4358

59+
- name: Credo
60+
run: mix credo
61+
4462
- name: Test
4563
run: mix test
4664

@@ -51,4 +69,4 @@ jobs:
5169
key: plts-${{ matrix.elixir }}
5270

5371
- name: Dialyzer
54-
run: mix dialyzer
72+
run: MIX_ENV=dev mix dialyzer

.tool-versions

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
erlang 24.2
2-
elixir 1.13.2-otp-24
1+
erlang 26.2.2
2+
elixir 1.16.1-otp-26

config/config.exs

+7-41
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,12 @@
11
# This file is responsible for configuring your application
22
# and its dependencies with the aid of the Mix.Config module.
3-
use Mix.Config
3+
import Config
44

5-
config :upload, Upload, adapter: Upload.Adapters.Test
6-
config :upload, Upload.Adapters.S3, bucket: "my_bucket_name"
5+
config :logger, level: :info
76

8-
# Configuration For AWS
9-
config :ex_aws,
10-
access_key_id: "foo",
11-
secret_access_key: "bar"
7+
# Import environment specific config. This must remain at the bottom
8+
# of this file so it overrides the configuration defined above.
129

13-
config :ex_aws, :retries, max_attempts: 1
14-
15-
config :ex_aws, :s3,
16-
scheme: "http://",
17-
host: "localhost",
18-
port: 4569,
19-
region: "us-east-1"
20-
21-
# This configuration is loaded before any dependency and is restricted
22-
# to this project. If another project depends on this project, this
23-
# file won't be loaded nor affect the parent project. For this reason,
24-
# if you want to provide default values for your application for
25-
# 3rd-party users, it should be done in your "mix.exs" file.
26-
27-
# You can configure your application as:
28-
#
29-
# config :upload, key: :value
30-
#
31-
# and access this configuration in your application as:
32-
#
33-
# Application.get_env(:upload, :key)
34-
#
35-
# You can also configure a 3rd-party app:
36-
#
37-
# config :logger, level: :info
38-
#
39-
40-
# It is also possible to import configuration files, relative to this
41-
# directory. For example, you can emulate configuration per environment
42-
# by uncommenting the line below and defining dev.exs, test.exs and such.
43-
# Configuration from the imported file will override the ones defined
44-
# here (which is why it is important to import them last).
45-
#
46-
# import_config "#{Mix.env}.exs"
10+
if Mix.env() == :test do
11+
import_config "#{config_env()}.exs"
12+
end

config/test.exs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Config
2+
3+
# Configuration for the test suite
4+
config :upload, ecto_repos: [Upload.Test.Repo]
5+
6+
config :upload, Upload.Test.Repo,
7+
adapter: Ecto.Adapters.Postgres,
8+
database: "upload_test",
9+
pool: Ecto.Adapters.SQL.Sandbox,
10+
priv: "test/support/",
11+
username: "postgres",
12+
password: "postgres",
13+
hostname: "localhost"
14+
15+
config :upload, Upload.Test.Vault,
16+
ciphers: [
17+
default:
18+
{Cloak.Ciphers.AES.GCM,
19+
tag: "AES.GCM.V1", key: Base.decode64!("KyRFNTop589ClLNsY0fNus68AvWKQfUQMKu5LvS8ToQ=")}
20+
]
21+
22+
config :upload, Upload.Storage,
23+
adapter: FileStore.Adapters.Memory,
24+
base_url: "http://example.com"
25+
26+
config :upload,
27+
repo: Upload.Test.Repo,
28+
vault: Upload.Test.Vault

0 commit comments

Comments
 (0)