Add CI (#4)
* Added credo * Added and ran Prettier; First pass at GH Actions * Updated actions workflow to hopefully work on this branch * Name the folder correctly how about * Added proper container prefix to commands * Apparently you have to get back into the root after commands * CI is working, update branches to final value
This commit is contained in:
parent
89b1640eb6
commit
44bec0a127
16 changed files with 125 additions and 35 deletions
16
.eslintrc.js
16
.eslintrc.js
|
|
@ -1,16 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
commonjs: true,
|
|
||||||
es6: true,
|
|
||||||
node: true
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
sourceType: 'module',
|
|
||||||
ecmaVersion: 2022
|
|
||||||
},
|
|
||||||
extends: ['prettier'],
|
|
||||||
rules: {
|
|
||||||
'prettier/prettier': 'error'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
71
.github/workflows/lint_and_test.yml
vendored
Normal file
71
.github/workflows/lint_and_test.yml
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
name: Perform linting and run tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
name: Build, Lint, and Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
|
||||||
|
env:
|
||||||
|
COMPOSE_FILE: ./docker-compose.ci.yml
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Create and populate ENV file
|
||||||
|
run: |
|
||||||
|
echo MIX_ENV=test >> .env
|
||||||
|
echo POSTGRES_HOST=postgres >> .env
|
||||||
|
echo POSTGRES_USER=postgres >> .env
|
||||||
|
echo POSTGRES_PASSWORD=postgres >> .env
|
||||||
|
|
||||||
|
- name: Pull prebuilt images
|
||||||
|
run: docker compose pull
|
||||||
|
|
||||||
|
- name: Setup Docker layer caching
|
||||||
|
uses: jpribyl/action-docker-layer-caching@v0.1.1
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
key: ci-docker-cache-{hash}
|
||||||
|
restore-keys: |
|
||||||
|
ci-docker-cache-
|
||||||
|
layer-ci-docker-cache-
|
||||||
|
|
||||||
|
- name: Build and Run Docker image
|
||||||
|
run: docker compose up --detach
|
||||||
|
|
||||||
|
# NOTE: All exec commands use the -T flag to compensate for
|
||||||
|
# a bug in the GitHub Actions runner where its stdin/stderr
|
||||||
|
# will erroneously report that it's a TTY.
|
||||||
|
# Aside from handling this bug the -T flag is not required
|
||||||
|
# See https://github.com/actions/runner/issues/241 and https://github.com/docker/compose/issues/8537
|
||||||
|
- name: Install Elixir and JS deps
|
||||||
|
run: |
|
||||||
|
docker compose exec -T phx yarn install && cd assets && yarn install && cd ..
|
||||||
|
docker compose exec -T phx mix deps.get
|
||||||
|
|
||||||
|
- name: Create and Migrate database
|
||||||
|
run: |
|
||||||
|
docker compose exec -T phx mix ecto.create
|
||||||
|
docker compose exec -T phx mix ecto.migrate
|
||||||
|
|
||||||
|
- name: Check JS formatting
|
||||||
|
run: docker compose exec -T phx yarn run prettier . --check
|
||||||
|
|
||||||
|
- name: Check Elixir formatting
|
||||||
|
run: docker compose exec -T phx mix format --check-formatted
|
||||||
|
|
||||||
|
- name: Check Credo
|
||||||
|
run: docker compose exec -T phx mix credo
|
||||||
|
|
||||||
|
- name: Run Elixir tests
|
||||||
|
run: docker compose exec -T phx mix test
|
||||||
0
.github/workflows/list_and_test.yml
vendored
Normal file
0
.github/workflows/list_and_test.yml
vendored
Normal file
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -33,6 +33,7 @@ pinchflat-*.tar
|
||||||
|
|
||||||
# In case you use Node.js/npm, you want to ignore these.
|
# In case you use Node.js/npm, you want to ignore these.
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
/node_modules/
|
||||||
/assets/node_modules/
|
/assets/node_modules/
|
||||||
|
|
||||||
/.elixir_ls
|
/.elixir_ls
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
assets/vendor/
|
assets/vendor/
|
||||||
assets/node_modules/
|
deps/
|
||||||
|
_build/
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ RUN bash nodesource_setup.sh
|
||||||
RUN apt-get install nodejs
|
RUN apt-get install nodejs
|
||||||
RUN npm install -g yarn
|
RUN npm install -g yarn
|
||||||
|
|
||||||
# Install Phoenix packages
|
# Install baseline Elixir packages
|
||||||
RUN mix local.hex --force
|
RUN mix local.hex --force
|
||||||
RUN mix local.rebar --force
|
RUN mix local.rebar --force
|
||||||
|
|
||||||
|
|
@ -27,5 +27,7 @@ COPY . ./
|
||||||
# Needs permissions to be updated AFTER the copy step
|
# Needs permissions to be updated AFTER the copy step
|
||||||
RUN chmod +x ./docker-run.sh
|
RUN chmod +x ./docker-run.sh
|
||||||
|
|
||||||
# # Compile the project.
|
# Install Elixir deps
|
||||||
|
RUN mix deps.get
|
||||||
|
|
||||||
EXPOSE 4008
|
EXPOSE 4008
|
||||||
|
|
|
||||||
14
README.md
14
README.md
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
To start your Phoenix server:
|
To start your Phoenix server:
|
||||||
|
|
||||||
* Run `mix setup` to install and setup dependencies
|
- Run `mix setup` to install and setup dependencies
|
||||||
* Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`
|
- Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`
|
||||||
|
|
||||||
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
|
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
|
||||||
|
|
||||||
|
|
@ -11,8 +11,8 @@ Ready to run in production? Please [check our deployment guides](https://hexdocs
|
||||||
|
|
||||||
## Learn more
|
## Learn more
|
||||||
|
|
||||||
* Official website: https://www.phoenixframework.org/
|
- Official website: https://www.phoenixframework.org/
|
||||||
* Guides: https://hexdocs.pm/phoenix/overview.html
|
- Guides: https://hexdocs.pm/phoenix/overview.html
|
||||||
* Docs: https://hexdocs.pm/phoenix
|
- Docs: https://hexdocs.pm/phoenix
|
||||||
* Forum: https://elixirforum.com/c/phoenix-forum
|
- Forum: https://elixirforum.com/c/phoenix-forum
|
||||||
* Source: https://github.com/phoenixframework/phoenix
|
- Source: https://github.com/phoenixframework/phoenix
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
@import "tailwindcss/base";
|
@import 'tailwindcss/base';
|
||||||
@import "tailwindcss/components";
|
@import 'tailwindcss/components';
|
||||||
@import "tailwindcss/utilities";
|
@import 'tailwindcss/utilities';
|
||||||
|
|
||||||
/* This file is for your main application CSS */
|
/* This file is for your main application CSS */
|
||||||
|
|
|
||||||
3
assets/package.json
Normal file
3
assets/package.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"description": "Use this one for actual JS deps used in-app"
|
||||||
|
}
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
||||||
# yarn lockfile v1
|
|
||||||
|
|
||||||
|
|
||||||
16
docker-compose.ci.yml
Normal file
16
docker-compose.ci.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: 'postgres:16-alpine'
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
|
||||||
|
phx:
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
- '.:/app'
|
||||||
|
ports:
|
||||||
|
- '4008:4008'
|
||||||
|
command: tail -F /dev/null
|
||||||
|
env_file: .env
|
||||||
|
|
@ -14,7 +14,6 @@ services:
|
||||||
- '4008:4008'
|
- '4008:4008'
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
# command: 'sh -c "trap : TERM INT; tail -f /dev/null & wait"'
|
|
||||||
command:
|
command:
|
||||||
- ./docker-run.sh
|
- ./docker-run.sh
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
|
|
|
||||||
3
mix.exs
3
mix.exs
|
|
@ -51,7 +51,8 @@ defmodule Pinchflat.MixProject do
|
||||||
{:jason, "~> 1.2"},
|
{:jason, "~> 1.2"},
|
||||||
{:dns_cluster, "~> 0.1.1"},
|
{:dns_cluster, "~> 0.1.1"},
|
||||||
{:plug_cowboy, "~> 2.5"},
|
{:plug_cowboy, "~> 2.5"},
|
||||||
{:mox, "~> 1.0", only: :test}
|
{:mox, "~> 1.0", only: :test},
|
||||||
|
{:credo, "~> 1.7", only: [:dev, :test], runtime: false}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
2
mix.lock
2
mix.lock
|
|
@ -1,8 +1,10 @@
|
||||||
%{
|
%{
|
||||||
|
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
|
||||||
"castore": {:hex, :castore, "1.0.5", "9eeebb394cc9a0f3ae56b813459f990abb0a3dedee1be6b27fdb50301930502f", [:mix], [], "hexpm", "8d7c597c3e4a64c395980882d4bca3cebb8d74197c590dc272cfd3b6a6310578"},
|
"castore": {:hex, :castore, "1.0.5", "9eeebb394cc9a0f3ae56b813459f990abb0a3dedee1be6b27fdb50301930502f", [:mix], [], "hexpm", "8d7c597c3e4a64c395980882d4bca3cebb8d74197c590dc272cfd3b6a6310578"},
|
||||||
"cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"},
|
"cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"},
|
||||||
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
|
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
|
||||||
"cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"},
|
"cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"},
|
||||||
|
"credo": {:hex, :credo, "1.7.3", "05bb11eaf2f2b8db370ecaa6a6bda2ec49b2acd5e0418bc106b73b07128c0436", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "35ea675a094c934c22fb1dca3696f3c31f2728ae6ef5a53b5d648c11180a4535"},
|
||||||
"db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"},
|
"db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"},
|
||||||
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
|
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
|
||||||
"dns_cluster": {:hex, :dns_cluster, "0.1.2", "3eb5be824c7888dadf9781018e1a5f1d3d1113b333c50bce90fb1b83df1015f2", [:mix], [], "hexpm", "7494272040f847637bbdb01bcdf4b871e82daf09b813e7d3cb3b84f112c6f2f8"},
|
"dns_cluster": {:hex, :dns_cluster, "0.1.2", "3eb5be824c7888dadf9781018e1a5f1d3d1113b333c50bce90fb1b83df1015f2", [:mix], [], "hexpm", "7494272040f847637bbdb01bcdf4b871e82daf09b813e7d3cb3b84f112c6f2f8"},
|
||||||
|
|
|
||||||
6
package.json
Normal file
6
package.json
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"description": "Prettier is used for linting of all files so this package has to live in the root of the project. Use the other package.json files for dependencies.",
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "3.2.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
8
yarn.lock
Normal file
8
yarn.lock
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
prettier@3.2.4:
|
||||||
|
version "3.2.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.4.tgz#4723cadeac2ce7c9227de758e5ff9b14e075f283"
|
||||||
|
integrity sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==
|
||||||
Loading…
Reference in a new issue