Skip to content

Commit cd462c7

Browse files
authored
chore: setup phoenix project (#26)
1 parent acf3389 commit cd462c7

177 files changed

Lines changed: 3075 additions & 7474 deletions

File tree

Some content is hidden

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

.dockerignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This file excludes paths from the Docker build context.
2+
#
3+
# By default, Docker's build context includes all files (and folders) in the
4+
# current directory. Even if a file isn't copied into the container it is still sent to
5+
# the Docker daemon.
6+
#
7+
# There are multiple reasons to exclude files from the build context:
8+
#
9+
# 1. Prevent nested folders from being copied into the container (ex: exclude
10+
# /assets/node_modules when copying /assets)
11+
# 2. Reduce the size of the build context and improve build time (ex. /build, /deps, /doc)
12+
# 3. Avoid sending files containing sensitive information
13+
#
14+
# More information on using .dockerignore is available here:
15+
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
16+
17+
.dockerignore
18+
19+
# Ignore git, but keep git HEAD and refs to access current commit hash if needed:
20+
#
21+
# $ cat .git/HEAD | awk '{print ".git/"$2}' | xargs cat
22+
# d0b8727759e1e0e7aa3d41707d12376e373d5ecc
23+
.git
24+
!.git/HEAD
25+
!.git/refs
26+
27+
# Common development/test artifacts
28+
/cover/
29+
/doc/
30+
/test/
31+
/tmp/
32+
.elixir_ls
33+
34+
# Mix artifacts
35+
/_build/
36+
/deps/
37+
*.ez
38+
39+
# Generated on crash by the VM
40+
erl_crash.dump
41+
42+
# Static artifacts - These should be fetched and built inside the Docker image
43+
# https://hexdocs.pm/phoenix/Mix.Tasks.Phx.Gen.Release.html#module-docker
44+
/assets/node_modules/
45+
/priv/static/assets/
46+
/priv/static/cache_manifest.json

.env.dev.sample

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
ASSET_HOST="http://localhost:3000"
1+
DB_USERNAME=postgres
2+
DB_PASSWORD=postgres
3+
DB_HOST=localhost
4+
DB_PORT=5432
5+
DB_NAME=yearbook_dev

.env.prod.sample

Lines changed: 0 additions & 1 deletion
This file was deleted.

.formatter.exs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
[
2-
import_deps: [:ecto, :phoenix],
2+
import_deps: [:ecto, :ecto_sql, :phoenix],
3+
subdirectories: ["priv/*/migrations"],
34
plugins: [Phoenix.LiveView.HTMLFormatter],
4-
heex_line_length: 300,
5-
inputs: [
6-
"*.{heex,ex,exs}",
7-
"priv/*/seeds.exs",
8-
"priv/repo/seeds/*.exs",
9-
"{config,lib,test}/**/*.{heex,ex,exs}"
10-
],
11-
subdirectories: ["priv/*/migrations"]
5+
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
126
]
Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,34 @@
11
name: Setup Elixir Project
22
description: Checks out the code, configures Elixir, fetches dependencies, and manages build caching.
33
inputs:
4-
# Required inputs
54
otp-version:
65
required: true
7-
type: string
86
description: OTP version to set up
97
elixir-version:
108
required: true
11-
type: string
129
description: Elixir version to set up
13-
# Optional inputs
1410
build-deps:
1511
required: false
16-
type: boolean
17-
default: true
12+
default: 'true'
1813
description: True if we should compile dependencies
1914
build-app:
2015
required: false
21-
type: boolean
22-
default: true
16+
default: 'true'
2317
description: True if we should compile the application itself
2418
build-flags:
2519
required: false
26-
type: string
2720
default: '--all-warnings'
2821
description: Flags to pass to mix compile
2922
install-rebar:
3023
required: false
31-
type: boolean
32-
default: true
24+
default: 'true'
3325
description: By default, we will install Rebar (mix local.rebar --force).
3426
install-hex:
3527
required: false
36-
type: boolean
37-
default: true
28+
default: 'true'
3829
description: By default, we will install Hex (mix local.hex --force).
3930
cache-key:
4031
required: false
41-
type: string
4232
default: 'v1'
4333
description: If you need to reset the cache for some reason, you can change this key.
4434
runs:
@@ -58,7 +48,7 @@ runs:
5848
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '**/mix.lock')) }}
5949
restore-keys: |
6050
${{ runner.os }}-mix-
61-
51+
6252
- name: Get build cache
6353
uses: actions/cache@v3
6454
id: build-cache
@@ -67,11 +57,7 @@ runs:
6757
key: build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-${{ hashFiles('**/mix.lock') }}
6858
restore-keys: |
6959
build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-
70-
# In my experience, I have issues with incremental builds maybe 1 in 100
71-
# times that are fixed by doing a full recompile.
72-
# In order to not waste dev time on such trivial issues (while also reaping
73-
# the time savings of incremental builds for *most* day-to-day development),
74-
# I force a full recompile only on builds that we retry.
60+
7561
- name: Clean to rule out incremental build as a source of flakiness
7662
if: github.run_attempt != '1'
7763
run: |
@@ -101,4 +87,4 @@ runs:
10187
- name: Compile Application
10288
run: mix compile ${{ inputs.build-flags }}
10389
shell: sh
104-
if: inputs.build-app == 'true'
90+
if: inputs.build-app == 'true'

.github/workflows/style.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,36 @@ name: Code Quality
22

33
on:
44
pull_request:
5-
branches: [main, master]
5+
branches: [main]
66
types: [opened, synchronize]
7+
paths:
8+
- '**/*.ex'
9+
- '**/*.exs'
10+
- '**/*.html.heex'
711

812
jobs:
913
style:
1014
runs-on: ubuntu-latest
11-
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
15+
name: Code Quality
1216

1317
strategy:
1418
matrix:
15-
otp: [25.x]
16-
elixir: [1.13.x]
19+
otp: [28.x]
20+
elixir: [1.19.x]
1721

1822
steps:
1923
- name: ☁️ Checkout repository
2024
uses: actions/checkout@v3
2125

2226
- name: 💧 Setup Elixir ${{ matrix.elixir }} (OTP ${{matrix.otp}})
23-
uses: ./.github/actions/elixir-setup
27+
uses: ./.github/actions
2428
with:
2529
otp-version: ${{ matrix.otp }}
2630
elixir-version: ${{ matrix.elixir }}
2731
build-flags: --all-warnings --warnings-as-errors
2832

29-
- name: 📏 Check code formating
33+
- name: 🎨 Check code formating
3034
run: mix format --check-formatted
31-
if: always()
3235

3336
- name: 🔍 Lint the code
34-
run: mix credo --strict --all
35-
if: always()
37+
run: mix credo --all --strict

.github/workflows/test.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,51 @@ name: Build and Test
22

33
on:
44
push:
5-
branches: [main, master]
5+
branches: [main]
6+
paths:
7+
- '**/*.ex'
8+
- '**/*.exs'
9+
- '**/*.html.heex'
610
pull_request:
7-
branches: [main, master]
11+
branches: [main]
812
types: [opened, synchronize]
13+
paths:
14+
- '**/*.ex'
15+
- '**/*.exs'
16+
- '**/*.html.heex'
917

1018
jobs:
11-
test:
19+
build:
1220
runs-on: ubuntu-latest
1321
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
1422
env:
1523
MIX_ENV: test
24+
1625
strategy:
1726
matrix:
18-
otp: [25.x]
19-
elixir: [1.13.x]
27+
otp: [28.x]
28+
elixir: [1.19.x]
29+
30+
services:
31+
db:
32+
image: postgres:14.1
33+
ports:
34+
- 5432:5432
35+
env:
36+
POSTGRES_USERNAME: postgres
37+
POSTGRES_PASSWORD: postgres
38+
POSTGRES_HOSTNAME: 0.0.0.0
2039

2140
steps:
2241
- name: ☁️ Checkout repository
2342
uses: actions/checkout@v3
2443

2544
- name: 💧 Setup Elixir ${{ matrix.elixir }} (OTP ${{matrix.otp}})
26-
uses: ./.github/actions/elixir-setup
45+
uses: ./.github/actions
2746
with:
2847
otp-version: ${{ matrix.otp }}
2948
elixir-version: ${{ matrix.elixir }}
3049
build-flags: --all-warnings --warnings-as-errors
31-
50+
3251
- name: 🔬 Run the tests
33-
run: mix test --warnings-as-errors
52+
run: mix test --warnings-as-errors

.gitignore

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
# Ignore personal development files
2-
.iex.local.exs
3-
4-
# Ignore environment config files
5-
.env.*
6-
!.env.*.sample
7-
8-
# Upload files
9-
/priv/uploads/
10-
111
# The directory Mix will write compiled artifacts to.
122
/_build/
133

@@ -29,6 +19,9 @@ erl_crash.dump
2919
# Also ignore archive artifacts (built via "mix archive.build").
3020
*.ez
3121

22+
# Temporary files, for example, from tests.
23+
/tmp/
24+
3225
# Ignore package tarball (built via "mix hex.build").
3326
yearbook-*.tar
3427

@@ -42,7 +35,7 @@ yearbook-*.tar
4235
npm-debug.log
4336
/assets/node_modules/
4437

45-
# Database files
46-
*.db
47-
*.db-*
38+
.env.dev
39+
.env.prod
40+
.env
4841

.iex.exs

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

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
elixir 1.13.4-otp-25
2-
erlang 25.0.2
1+
elixir 1.19.2
2+
erlang 28.1

0 commit comments

Comments
 (0)