Added and ran Prettier; First pass at GH Actions

This commit is contained in:
Kieran Eglin 2024-01-19 23:18:32 -08:00
parent 8121ce6155
commit 8ebbb23836
No known key found for this signature in database
GPG key ID: 193984967FCF432D
13 changed files with 121 additions and 34 deletions

View file

@ -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/workflow/lint_and_test.yml vendored Normal file
View 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 yarn install && cd assets && yarn install
docker compose exec -T mix deps.get
- name: Create and Migrate database
run: |
docker compose exec -T mix ecto.create
docker compose exec -T mix ecto.migrate
- name: Check JS formatting
run: docker compose exec -T yarn run prettier . --check
- name: Check Elixir formatting
run: docker compose exec -T mix format --check-formatted
- name: Check Credo
run: docker compose exec -T mix credo
- name: Run Elixir tests
run: docker compose exec -T mix test

1
.gitignore vendored
View file

@ -33,6 +33,7 @@ pinchflat-*.tar
# In case you use Node.js/npm, you want to ignore these.
npm-debug.log
/node_modules/
/assets/node_modules/
/.elixir_ls

View file

@ -1,2 +1,3 @@
assets/vendor/
assets/node_modules/
deps/
_build/

View file

@ -12,7 +12,7 @@ RUN bash nodesource_setup.sh
RUN apt-get install nodejs
RUN npm install -g yarn
# Install Phoenix packages
# Install baseline Elixir packages
RUN mix local.hex --force
RUN mix local.rebar --force
@ -27,5 +27,7 @@ COPY . ./
# Needs permissions to be updated AFTER the copy step
RUN chmod +x ./docker-run.sh
# # Compile the project.
# Install Elixir deps
RUN mix deps.get
EXPOSE 4008

View file

@ -2,8 +2,8 @@
To start your Phoenix server:
* Run `mix setup` to install and setup dependencies
* Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`
- Run `mix setup` to install and setup dependencies
- 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.
@ -11,8 +11,8 @@ Ready to run in production? Please [check our deployment guides](https://hexdocs
## Learn more
* Official website: https://www.phoenixframework.org/
* Guides: https://hexdocs.pm/phoenix/overview.html
* Docs: https://hexdocs.pm/phoenix
* Forum: https://elixirforum.com/c/phoenix-forum
* Source: https://github.com/phoenixframework/phoenix
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix

View file

@ -1,5 +1,5 @@
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
/* This file is for your main application CSS */

3
assets/package.json Normal file
View file

@ -0,0 +1,3 @@
{
"description": "Use this one for actual JS deps used in-app"
}

View file

@ -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
View 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

View file

@ -14,7 +14,6 @@ services:
- '4008:4008'
depends_on:
- postgres
# command: 'sh -c "trap : TERM INT; tail -f /dev/null & wait"'
command:
- ./docker-run.sh
stdin_open: true

6
package.json Normal file
View 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
View 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==