Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
46 changes: 46 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This file excludes paths from the Docker build context.
#
# By default, Docker's build context includes all files (and folders) in the
# current directory. Even if a file isn't copied into the container it is still sent to
# the Docker daemon.
#
# There are multiple reasons to exclude files from the build context:
#
# 1. Prevent nested folders from being copied into the container (ex: exclude
# /assets/node_modules when copying /assets)
# 2. Reduce the size of the build context and improve build time (ex. /build, /deps, /doc)
# 3. Avoid sending files containing sensitive information
#
# More information on using .dockerignore is available here:
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

.dockerignore

# Ignore git, but keep git HEAD and refs to access current commit hash if needed:
#
# $ cat .git/HEAD | awk '{print ".git/"$2}' | xargs cat
# d0b8727759e1e0e7aa3d41707d12376e373d5ecc
.git
!.git/HEAD
!.git/refs

# Common development/test artifacts
/cover/
/doc/
/test/
/tmp/
.elixir_ls

# Mix artifacts
/_build/
/deps/
*.ez

# Generated on crash by the VM
erl_crash.dump

# Static artifacts - These should be fetched and built inside the Docker image
# https://hexdocs.pm/phoenix/Mix.Tasks.Phx.Gen.Release.html#module-docker
/assets/node_modules/
/priv/static/assets/
/priv/static/cache_manifest.json
6 changes: 5 additions & 1 deletion .env.dev.sample
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
ASSET_HOST="http://localhost:3000"
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_HOST=localhost
DB_PORT=5432
DB_NAME=yearbook_dev
1 change: 0 additions & 1 deletion .env.prod.sample

This file was deleted.

12 changes: 3 additions & 9 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[
import_deps: [:ecto, :phoenix],
import_deps: [:ecto, :ecto_sql, :phoenix],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter],
heex_line_length: 300,
inputs: [
"*.{heex,ex,exs}",
"priv/*/seeds.exs",
"priv/repo/seeds/*.exs",
"{config,lib,test}/**/*.{heex,ex,exs}"
],
subdirectories: ["priv/*/migrations"]
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
]
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
name: Setup Elixir Project
description: Checks out the code, configures Elixir, fetches dependencies, and manages build caching.
inputs:
# Required inputs
otp-version:
required: true
type: string
description: OTP version to set up
elixir-version:
required: true
type: string
description: Elixir version to set up
# Optional inputs
build-deps:
required: false
type: boolean
default: true
default: 'true'
description: True if we should compile dependencies
build-app:
required: false
type: boolean
default: true
default: 'true'
description: True if we should compile the application itself
build-flags:
required: false
type: string
default: '--all-warnings'
description: Flags to pass to mix compile
install-rebar:
required: false
type: boolean
default: true
default: 'true'
description: By default, we will install Rebar (mix local.rebar --force).
install-hex:
required: false
type: boolean
default: true
default: 'true'
description: By default, we will install Hex (mix local.hex --force).
cache-key:
required: false
type: string
default: 'v1'
description: If you need to reset the cache for some reason, you can change this key.
runs:
Expand All @@ -58,7 +48,7 @@ runs:
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '**/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-

- name: Get build cache
uses: actions/cache@v3
id: build-cache
Expand All @@ -67,11 +57,7 @@ runs:
key: build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-
# In my experience, I have issues with incremental builds maybe 1 in 100
# times that are fixed by doing a full recompile.
# In order to not waste dev time on such trivial issues (while also reaping
# the time savings of incremental builds for *most* day-to-day development),
# I force a full recompile only on builds that we retry.

- name: Clean to rule out incremental build as a source of flakiness
if: github.run_attempt != '1'
run: |
Expand Down Expand Up @@ -101,4 +87,4 @@ runs:
- name: Compile Application
run: mix compile ${{ inputs.build-flags }}
shell: sh
if: inputs.build-app == 'true'
if: inputs.build-app == 'true'
20 changes: 11 additions & 9 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,36 @@ name: Code Quality

on:
pull_request:
branches: [main, master]
branches: [main]
types: [opened, synchronize]
paths:
- '**/*.ex'
- '**/*.exs'
- '**/*.html.heex'

jobs:
style:
runs-on: ubuntu-latest
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
name: Code Quality

strategy:
matrix:
otp: [25.x]
elixir: [1.13.x]
otp: [28.x]
elixir: [1.19.x]

steps:
- name: ☁️ Checkout repository
uses: actions/checkout@v3

- name: 💧 Setup Elixir ${{ matrix.elixir }} (OTP ${{matrix.otp}})
uses: ./.github/actions/elixir-setup
uses: ./.github/actions
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
build-flags: --all-warnings --warnings-as-errors

- name: 📏 Check code formating
- name: 🎨 Check code formating
run: mix format --check-formatted
if: always()

- name: 🔍 Lint the code
run: mix credo --strict --all
if: always()
run: mix credo --all --strict
35 changes: 27 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,51 @@ name: Build and Test

on:
push:
branches: [main, master]
branches: [main]
paths:
- '**/*.ex'
- '**/*.exs'
- '**/*.html.heex'
pull_request:
branches: [main, master]
branches: [main]
types: [opened, synchronize]
paths:
- '**/*.ex'
- '**/*.exs'
- '**/*.html.heex'

jobs:
test:
build:
runs-on: ubuntu-latest
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
env:
MIX_ENV: test

strategy:
matrix:
otp: [25.x]
elixir: [1.13.x]
otp: [28.x]
elixir: [1.19.x]

services:
db:
image: postgres:14.1
ports:
- 5432:5432
env:
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOSTNAME: 0.0.0.0

steps:
- name: ☁️ Checkout repository
uses: actions/checkout@v3

- name: 💧 Setup Elixir ${{ matrix.elixir }} (OTP ${{matrix.otp}})
uses: ./.github/actions/elixir-setup
uses: ./.github/actions
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
build-flags: --all-warnings --warnings-as-errors

- name: 🔬 Run the tests
run: mix test --warnings-as-errors
run: mix test --warnings-as-errors
19 changes: 6 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# Ignore personal development files
.iex.local.exs

# Ignore environment config files
.env.*
!.env.*.sample

# Upload files
/priv/uploads/

# The directory Mix will write compiled artifacts to.
/_build/

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

# Temporary files, for example, from tests.
/tmp/

# Ignore package tarball (built via "mix hex.build").
yearbook-*.tar

Expand All @@ -42,7 +35,7 @@ yearbook-*.tar
npm-debug.log
/assets/node_modules/

# Database files
*.db
*.db-*
.env.dev
.env.prod
.env

21 changes: 0 additions & 21 deletions .iex.exs

This file was deleted.

4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.13.4-otp-25
erlang 25.0.2
elixir 1.19.2
erlang 28.1
75 changes: 0 additions & 75 deletions CODE_OF_CONDUCT.md

This file was deleted.

Loading