From b54bc18538be8f3924f5ce7965a4244c1f8bdfc3 Mon Sep 17 00:00:00 2001 From: Splines Date: Mon, 18 Dec 2023 23:18:59 +0100 Subject: [PATCH 1/9] Init basic justfiles --- .justfile | 21 +++++++++++++++++++++ commands/docker.justfile | 25 +++++++++++++++++++++++++ commands/test.justfile | 9 +++++++++ 3 files changed, 55 insertions(+) create mode 100644 .justfile create mode 100644 commands/docker.justfile create mode 100644 commands/test.justfile diff --git a/.justfile b/.justfile new file mode 100644 index 000000000..ea79d08b7 --- /dev/null +++ b/.justfile @@ -0,0 +1,21 @@ +# Prints this help message. +help: + @just --list + +alias d := docker +# Groups docker commands +docker recipe='' *ARGS='': + just -f ./commands/docker.justfile {{recipe}} {{ARGS}} + +alias t := test +# Groups test commands +test recipe='' *ARGS='': + just -f ./commands/test.justfile {{recipe}} {{ARGS}} + +# Opens the MaMpf wiki in the browser. +wiki: + xdg-open https://github.com/MaMpf-HD/mampf/wiki + +# Opens the MaMpf pull requests (PRs) in the browser. +prs: + xdg-open https://github.com/MaMpf-HD/mampf/pulls \ No newline at end of file diff --git a/commands/docker.justfile b/commands/docker.justfile new file mode 100644 index 000000000..4ed3538fa --- /dev/null +++ b/commands/docker.justfile @@ -0,0 +1,25 @@ +# Prints this help message. +help: + @just --list --justfile {{justfile()}} + +# Starts the development docker containers. +up: + #!/usr/bin/env bash + cd ../docker/development + docker compose up -d + +# Starts the test docker containers. +up-test: + #!/usr/bin/env bash + cd ../docker/run_cypress_tests + docker compose up -d + +alias s := shell +# Puts you into a shell of your desired development docker container. +shell name="mampf": + docker exec -it $(docker ps -qf "name=development-{{name}}") bash + +alias st := shell-test +# Puts you into a shell of your desired test docker container. +shell-test name="mampf": + docker exec -it $(docker ps -qf "name=tests-{{name}}") bash diff --git a/commands/test.justfile b/commands/test.justfile new file mode 100644 index 000000000..d5fcfb650 --- /dev/null +++ b/commands/test.justfile @@ -0,0 +1,9 @@ +# Prints this help message. +help: + @just --list --justfile {{justfile()}} + +# Prepares the test database. +prep: + #!/usr/bin/env bash + cd ../docker/run_cypress_tests + docker compose exec --no-TTY mampf sh -c "rake db:create db:migrate db:test:prepare" From 664205088b190148b8d948f9722a908efe369d80 Mon Sep 17 00:00:00 2001 From: Splines Date: Thu, 4 Jul 2024 00:02:04 +0200 Subject: [PATCH 2/9] Improve docker and test commands --- .config/commands/docker.justfile | 28 ++++++++++++++++++++++++++++ .config/commands/test.justfile | 9 +++++++++ .justfile | 25 +++++++++++++------------ commands/docker.justfile | 25 ------------------------- commands/test.justfile | 9 --------- 5 files changed, 50 insertions(+), 46 deletions(-) create mode 100644 .config/commands/docker.justfile create mode 100644 .config/commands/test.justfile delete mode 100644 commands/docker.justfile delete mode 100644 commands/test.justfile diff --git a/.config/commands/docker.justfile b/.config/commands/docker.justfile new file mode 100644 index 000000000..181302b16 --- /dev/null +++ b/.config/commands/docker.justfile @@ -0,0 +1,28 @@ +# Prints this help message +[private] +help: + @just --list --justfile {{source_file()}} + +# Starts the development docker containers +@up *args: + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/development/ + docker compose up {{args}} + +# Stops the development docker containers +@down: + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/development/ + docker compose down + +# 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}} diff --git a/.config/commands/test.justfile b/.config/commands/test.justfile new file mode 100644 index 000000000..d62e44229 --- /dev/null +++ b/.config/commands/test.justfile @@ -0,0 +1,9 @@ +# Prints this help message +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 diff --git a/.justfile b/.justfile index ea79d08b7..d527c66d8 100644 --- a/.justfile +++ b/.justfile @@ -1,21 +1,22 @@ -# Prints this help message. +# Documentation: https://just.systems/man/en/ + +# Prints this help message +[private] help: @just --list -alias d := docker -# Groups docker commands -docker recipe='' *ARGS='': - just -f ./commands/docker.justfile {{recipe}} {{ARGS}} +# Test-related commands +mod test ".config/commands/test.justfile" +# see https://github.com/casey/just/issues/2216 +# alias t := test -alias t := test -# Groups test commands -test recipe='' *ARGS='': - just -f ./commands/test.justfile {{recipe}} {{ARGS}} +# Docker-related commands +mod docker ".config/commands/docker.justfile" -# Opens the MaMpf wiki in the browser. +# Opens the MaMpf wiki in the default browser wiki: xdg-open https://github.com/MaMpf-HD/mampf/wiki -# Opens the MaMpf pull requests (PRs) in the browser. +# Opens the MaMpf pull requests (PRs) in the default browser prs: - xdg-open https://github.com/MaMpf-HD/mampf/pulls \ No newline at end of file + xdg-open https://github.com/MaMpf-HD/mampf/pulls diff --git a/commands/docker.justfile b/commands/docker.justfile deleted file mode 100644 index 4ed3538fa..000000000 --- a/commands/docker.justfile +++ /dev/null @@ -1,25 +0,0 @@ -# Prints this help message. -help: - @just --list --justfile {{justfile()}} - -# Starts the development docker containers. -up: - #!/usr/bin/env bash - cd ../docker/development - docker compose up -d - -# Starts the test docker containers. -up-test: - #!/usr/bin/env bash - cd ../docker/run_cypress_tests - docker compose up -d - -alias s := shell -# Puts you into a shell of your desired development docker container. -shell name="mampf": - docker exec -it $(docker ps -qf "name=development-{{name}}") bash - -alias st := shell-test -# Puts you into a shell of your desired test docker container. -shell-test name="mampf": - docker exec -it $(docker ps -qf "name=tests-{{name}}") bash diff --git a/commands/test.justfile b/commands/test.justfile deleted file mode 100644 index d5fcfb650..000000000 --- a/commands/test.justfile +++ /dev/null @@ -1,9 +0,0 @@ -# Prints this help message. -help: - @just --list --justfile {{justfile()}} - -# Prepares the test database. -prep: - #!/usr/bin/env bash - cd ../docker/run_cypress_tests - docker compose exec --no-TTY mampf sh -c "rake db:create db:migrate db:test:prepare" From a086300462643a85878b48ea35616a08782ccb78 Mon Sep 17 00:00:00 2001 From: Splines Date: Thu, 4 Jul 2024 00:02:21 +0200 Subject: [PATCH 3/9] Add Just VSCode extension to workspace recommendations --- .vscode/extensions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index baa13b8bb..d98e845e1 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -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" ] } \ No newline at end of file From 7cef0ffaae6139c29bcdf75ed1152a32350b073b Mon Sep 17 00:00:00 2001 From: Splines Date: Thu, 4 Jul 2024 00:02:33 +0200 Subject: [PATCH 4/9] Add npm script to install latest version of `just` --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index e426ab660..43b31fe0e 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,9 @@ "eslint-plugin-cypress": "^3.3.0", "eslint-plugin-erb": "^2.0.0", "globals": "^15.1.0" + }, + "scripts": { + "install-just-to-bin": "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", + "remove-just-from-bin": "rm -rf ~/bin/just --interactive" } } From 8f602c37c356da4e8e9411010401e0ff57cd4c03 Mon Sep 17 00:00:00 2001 From: Splines Date: Thu, 4 Jul 2024 00:09:30 +0200 Subject: [PATCH 5/9] Don't print help message in list --- .config/commands/test.justfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.config/commands/test.justfile b/.config/commands/test.justfile index d62e44229..0945bce98 100644 --- a/.config/commands/test.justfile +++ b/.config/commands/test.justfile @@ -1,4 +1,5 @@ # Prints this help message +[private] help: @just --list --justfile {{source_file()}} From 689b11b59b42d9414a23143b175cb7b669117823 Mon Sep 17 00:00:00 2001 From: Splines Date: Thu, 4 Jul 2024 13:29:56 +0200 Subject: [PATCH 6/9] Add more docker `just` commands --- .config/commands/docker.justfile | 25 +++++++++++++++++++++++-- docker/development/docker-compose.yml | 8 +++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.config/commands/docker.justfile b/.config/commands/docker.justfile index 181302b16..ec5492394 100644 --- a/.config/commands/docker.justfile +++ b/.config/commands/docker.justfile @@ -3,18 +3,33 @@ help: @just --list --justfile {{source_file()}} -# Starts the development docker containers +# Starts the dev docker containers @up *args: #!/usr/bin/env bash cd {{justfile_directory()}}/docker/development/ docker compose up {{args}} -# Stops the development docker containers +# 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 @@ -26,3 +41,9 @@ help: #!/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 diff --git a/docker/development/docker-compose.yml b/docker/development/docker-compose.yml index e7c1d5dd0..94e3b7591 100644 --- a/docker/development/docker-compose.yml +++ b/docker/development/docker-compose.yml @@ -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: ../../ From d606cf5b18371f861699b5ea432e7fde513c67ac Mon Sep 17 00:00:00 2001 From: Splines Date: Thu, 4 Jul 2024 13:55:20 +0200 Subject: [PATCH 7/9] Add more "open in browser" commands --- .config/commands/test.justfile | 4 ++++ .justfile | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.config/commands/test.justfile b/.config/commands/test.justfile index 0945bce98..c2cacf556 100644 --- a/.config/commands/test.justfile +++ b/.config/commands/test.justfile @@ -8,3 +8,7 @@ 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 diff --git a/.justfile b/.justfile index d527c66d8..0f413a308 100644 --- a/.justfile +++ b/.justfile @@ -15,8 +15,22 @@ 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 \ No newline at end of file From 72ba9114e91fc4bab54b6ee4a937e916568b3d56 Mon Sep 17 00:00:00 2001 From: Splines Date: Thu, 4 Jul 2024 14:32:17 +0200 Subject: [PATCH 8/9] Improve just installation via yarn commands --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 43b31fe0e..92b90cc56 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "globals": "^15.1.0" }, "scripts": { - "install-just-to-bin": "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", - "remove-just-from-bin": "rm -rf ~/bin/just --interactive" + "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" } } From 36d1d364126d3a8924d671bd98856f923a423754 Mon Sep 17 00:00:00 2001 From: Splines Date: Thu, 4 Jul 2024 14:41:50 +0200 Subject: [PATCH 9/9] Add newline at end of `.justfile` --- .justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.justfile b/.justfile index 0f413a308..5b36d3496 100644 --- a/.justfile +++ b/.justfile @@ -33,4 +33,4 @@ pr: 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 \ No newline at end of file + xdg-open https://github.com/MaMpf-HD/mampf/tree/$branchname