Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init just as command-line runner #660

Merged
merged 10 commits into from
Aug 1, 2024
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
49 changes: 49 additions & 0 deletions .config/commands/docker.justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Prints this help message
[private]
help:
@just --list --justfile {{source_file()}}

# Starts the dev docker containers
@up *args:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose up {{args}}

# Starts the dev docker containers and preseeds the database
[confirm("This will reset all your data in the database locally. Continue? (y/n)")]
up-reseed *args:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
export DB_SQL_PRESEED_URL="https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/20220923120841_mampf.sql"
export UPLOADS_PRESEED_URL="https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/uploads.zip"
docker compose up {{args}}

# Removes the development docker containers
@down:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose down

# Stops the development docker containers (without removing them)
@stop:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose stop

# Puts you into a shell of your desired *development* docker container
@shell name="mampf" shell="bash":
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose exec -it {{name}} bash

# Puts you into a shell of your desired *test* docker container
@shell-test name="mampf" shell="bash":
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/test/
docker compose exec -it {{name}} {{shell}}

# Puts you into the rails console of the dev docker mampf container
@rails-c:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose exec mampf bundle exec rails c
14 changes: 14 additions & 0 deletions .config/commands/test.justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Prints this help message
[private]
help:
@just --list --justfile {{source_file()}}

# Starts the interactive Cypress test runner UI
cypress:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/test
docker compose -f docker-compose.yml -f cypress.yml -f cypress-interactive.yml up --exit-code-from cypress

# Opens Codecov in the default browser
codecov:
xdg-open https://app.codecov.io/gh/MaMpf-HD/mampf
36 changes: 36 additions & 0 deletions .justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Documentation: https://just.systems/man/en/

# Prints this help message
[private]
help:
@just --list

# Test-related commands
mod test ".config/commands/test.justfile"
# see https://github.com/casey/just/issues/2216
# alias t := test

# Docker-related commands
mod docker ".config/commands/docker.justfile"

# Opens the MaMpf wiki in the default browser
wiki:
#!/usr/bin/env bash
xdg-open https://github.com/MaMpf-HD/mampf/wiki

# Opens the MaMpf pull requests (PRs) in the default browser
prs:
#!/usr/bin/env bash
xdg-open https://github.com/MaMpf-HD/mampf/pulls

# Opens the PR for the current branch in the default browser
pr:
#!/usr/bin/env bash
branchname=$(git branch --show-current)
xdg-open "https://github.com/MaMpf-HD/mampf/pulls?q=is%3Apr+is%3Aopen+head%3A$branchname"

# Opens the MaMpf GitHub code tree at the current branch in the default browser
code branch="":
#!/usr/bin/env bash
branchname={{ if branch == "" {"$(git branch --show-current)"} else {branch} }}
xdg-open https://github.com/MaMpf-HD/mampf/tree/$branchname
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"shopify.ruby-lsp",
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker",
"streetsidesoftware.code-spell-checker-german"
"streetsidesoftware.code-spell-checker-german",
"nefrob.vscode-just-syntax"
fosterfarrell9 marked this conversation as resolved.
Show resolved Hide resolved
]
}
8 changes: 5 additions & 3 deletions docker/development/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ services:
PROJECT_EMAIL_PASSWORD: mampf
PROJECT_EMAIL_MAILBOX: INBOX
BLOG: https://mampf.blog
# uncomment DB_SQL_PRESEED_URL and UPLOADS_PRESEED_URL to enable db preseeding
# DB_SQL_PRESEED_URL: "https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/20220923120841_mampf.sql"
# UPLOADS_PRESEED_URL: "https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/uploads.zip"
# DB Preseeding with initial data.
# We don't specify a value here to let docker compose look up the values
# in the current environment/shell. This is used in the docker.justfile.
DB_SQL_PRESEED_URL:
UPLOADS_PRESEED_URL:
volumes:
- type: bind
source: ../../
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@
"eslint-plugin-cypress": "^3.3.0",
"eslint-plugin-erb": "^2.0.0",
"globals": "^15.1.0"
},
"scripts": {
"just-install": "curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin && echo 'export PATH=\"$PATH:$HOME/bin\" # for \"just\" binary' >> ~/.bashrc && echo '(!) Make sure to restart your current shell'",
"just-remove": "rm -r ~/bin/just --interactive",
"just-update": "echo 'We remove just from ~/bin/just, then install it again.' && rm -r ~/bin/just && yarn just-install"
}
}