-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325 from davetron5000/upgrade-to-minitest-of-10-y…
…ears-ago Upgrade to new Minitest constant + new dev env + 3.3 bugfix
- Loading branch information
Showing
35 changed files
with
532 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,60 @@ | ||
Contributions are welcome as long as they are part of my vision for GLI (or can be treated as optional to the user). I am obsessive about backwards-compatibility, so you may need to default things to disable your features. Sorry, not ready to bump a major version any time soon. | ||
|
||
1. Fork my Repository | ||
2. Create a branch off of main | ||
3. Make your changes: | ||
* Please include tests and watch out for reek and roodi; i.e. keep your code clean | ||
* If you make changes to the gli executable or the scaffolding, please update the cucumber features | ||
* Please rubydoc any new methods and update the rubydoc to methods you change in the following format: | ||
```ruby | ||
# Short description | ||
# | ||
# Longer description if needed | ||
# | ||
# +args+:: get documented using this syntax | ||
# +args+:: please state the TYPE of every arg | ||
# | ||
# Returns goes here, please state the TYPE of what's returned, if anything | ||
``` | ||
* Use <code># :nodoc:</code> for methods that a _user_ of GLI should not call (but still please do document all methods) | ||
4. Make sure your branch will merge with my gli-2 branch (or just rebase your branch from my gli-2 branch) | ||
5. Create a pull request explaining your change | ||
# Contributing/Developing | ||
|
||
## Types of Contributions | ||
|
||
GLI is relatively stable. As such: | ||
|
||
* No major new features should be added | ||
* No refactorings or "modernization" is desired | ||
* No runtime dependencies should be added. | ||
|
||
If you really want to make a change like this, open an issue first to discuss. | ||
|
||
That said, I welcome: | ||
|
||
* Bugfixes | ||
* Doc changes | ||
* Minor improvements | ||
|
||
I am responsive on issues, so reach out there if you have a question. | ||
|
||
## How to Do Development | ||
|
||
GLI us using a Docker-based development system to ensure consistency. To use it, you will need to have Docker installed, as well | ||
as Bash. This should all work under Windows Subsystem for Linux. | ||
|
||
### Setting Up | ||
|
||
1. Install Docker | ||
2. `dx/build` | ||
|
||
This will use `Dockerfile.dx` to create one Docker image for each supported Ruby version (see `dx/docker-compose.env`'s `RUBY_VERSIONS` variable for the current list). This will also generate `docker-compose.dx.yml` which will run all versions of Ruby for GLI at the same time. | ||
3. `dx/start` | ||
|
||
This will start Docker using `docker-compose.dx.yml`, which will run containers for all the images generated by `dx/build` | ||
|
||
4. From here, you can run commands inside the running containers, or you can run `bash` inside a container to effectively "log | ||
in" and run commands. | ||
|
||
### Doing Development | ||
|
||
Once you are set up, you should run `dx/exec bash`. This will log you into the container running the oldest supported version of | ||
Ruby. This is the version where you should do your basic work. This container has access to the source code you cloned from | ||
GitHub. | ||
|
||
1. `on-your-computer> dx/exec bash` | ||
2. `inside-docker-container> bin/setup # installs all gems` | ||
3. `inside-docker-container> bin/rake # runs all tests` | ||
|
||
Once you have stuff working, run tests on the other versions. Since the container you were working in was operating on your | ||
checked-out files, the other containers will have access as well. | ||
|
||
1. `on-your-computer> dx/exec -v 3.3 bash # connects to the conatiner where Ruby 3.3 is installed` | ||
2. `inside-docker-container> bin/setup # installs all gems` | ||
3. `inside-docker-container> bin/rake # runs all tests` | ||
|
||
#### If You Want To Use Your Local Computer | ||
|
||
In theory, GLI can be worked on using RVM, RBEnv, asdf, or whatever other way you want to manage Ruby. You can create a | ||
`.ruby-version` or `.tool-versions`. These are ignored so you can keep them on your machine. I don't support this setup, so if | ||
something is wrong, I probably can't help. This is why I have it set up with Docker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ARG RUBY_VERSION | ||
FROM ruby:${RUBY_VERSION} | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN apt-get -y update | ||
|
||
|
||
# dx.snippet.start=templates/snippets/bundler/latest__bundler.dockerfile-snippet | ||
# Based on documentation at https://guides.rubygems.org/command-reference/#gem-update | ||
# based on the vendor's documentation | ||
RUN echo "gem: --no-document" >> ~/.gemrc && \ | ||
gem update --system && \ | ||
gem install bundler | ||
|
||
# dx.snippet.end=templates/snippets/bundler/latest__bundler.dockerfile-snippet | ||
|
||
|
||
# dx.snippet.start=templates/snippets/vim/bullseye_vim.dockerfile-snippet | ||
# Based on documentation at https://packages.debian.org/search?keywords=vim | ||
# based on the vendor's documentation | ||
ENV EDITOR=vim | ||
RUN apt-get install -y vim && \ | ||
echo "set -o vi" >> /root/.bashrc | ||
# dx.snippet.end=templates/snippets/vim/bullseye_vim.dockerfile-snippet | ||
|
||
# This entrypoint produces a nice help message and waits around for you to do | ||
# something with the container. | ||
COPY dx/show-help-in-app-container-then-wait.sh /root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
bundle check || bundle install | ||
if [ Gemfile.lock -ot gli.gemspec ] ; then | ||
echo "[ bin/setup ] gli.gemspec has been modified - deleting Gemfile.lock" | ||
rm Gemfile.lock | ||
bundle install | ||
else | ||
echo "[ bin/setup ] checking bundle and updating as necessary" | ||
bundle check || bundle install | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${0}" )" > /dev/null 2>&1 && pwd ) | ||
|
||
. "${SCRIPT_DIR}/dx.sh.lib" | ||
|
||
require_command "docker" | ||
load_docker_compose_env | ||
|
||
usage_on_help "Builds the Docker image based on the Dockerfile" "" "build.pre" "build.post" "${@}" | ||
|
||
for ruby_version in ${RUBY_VERSIONS[@]}; do | ||
dockerfile="Dockerfile.dx" | ||
docker_image_name="${IMAGE}:ruby-${ruby_version}" | ||
|
||
log "Building for Ruby '${ruby_version}' using Docker image name '${docker_image_name}'" | ||
|
||
exec_hook_if_exists "build.pre" "${dockerfile}" "${docker_image_name}" | ||
|
||
docker build \ | ||
--file "${dockerfile}" \ | ||
--build-arg="RUBY_VERSION=${ruby_version}" \ | ||
--tag "${docker_image_name}" \ | ||
./ | ||
|
||
exec_hook_if_exists "build.post" "${dockerfile}" "${docker_image_name}" | ||
log "🌈" "Your Docker image has been built tagged '${docker_image_name}'" | ||
done | ||
|
||
log "✅" "All images built" | ||
|
||
log "✨" "Creating docker-compose.dx.yml" | ||
compose_file="docker-compose.dx.yml" | ||
log "🗑️" "Deleting previous ${compose_file}" | ||
|
||
rm "${compose_file}" | ||
echo "# THIS IS GENERATED - DO NOT EDIT" > "${compose_file}" | ||
echo "" >> "${compose_file}" | ||
echo "services:" >> "${compose_file}" | ||
|
||
for ruby_version in ${RUBY_VERSIONS[@]}; do | ||
log "Generating stanza for version '${ruby_version}'" | ||
docker_image_name="${IMAGE}:ruby-${ruby_version}" | ||
echo " gli-${ruby_version}:" >> "${compose_file}" | ||
echo " image: ${docker_image_name}" >> "${compose_file}" | ||
echo " init: true" >> "${compose_file}" | ||
echo " volumes:" >> "${compose_file}" | ||
echo " - type: bind" >> "${compose_file}" | ||
echo " source: \"./\"" >> "${compose_file}" | ||
echo " target: \"/root/work\"" >> "${compose_file}" | ||
echo " consistency: \"consistent\"" >> "${compose_file}" | ||
echo " entrypoint: /root/show-help-in-app-container-then-wait.sh" >> "${compose_file}" | ||
echo " working_dir: /root/work" >> "${compose_file}" | ||
done | ||
log "🎼" "${compose_file} is noq created" | ||
log "🔄" "You can run dx/start to start it up, though you may need to stop it first with Ctrl-C" | ||
|
||
# vim: ft=bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This array must include the oldest Ruby first! | ||
RUBY_VERSIONS=("3.1" "3.2" "3.3") | ||
IMAGE=davetron5000/gli-dev | ||
PROJECT_NAME=gli | ||
# vim: ft=bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# shellcheck shell=bash | ||
|
||
. "${SCRIPT_DIR}/setupkit.sh.lib" | ||
|
||
require_command "realpath" | ||
require_command "cat" | ||
|
||
ENV_FILE=$(realpath "${SCRIPT_DIR}")/docker-compose.env | ||
|
||
load_docker_compose_env() { | ||
. "${ENV_FILE}" | ||
} | ||
|
||
exec_hook_if_exists() { | ||
script_name=$1 | ||
shift | ||
if [ -x "${SCRIPT_DIR}"/"${script_name}" ]; then | ||
log "🪝" "${script_name} exists - executing" | ||
"${SCRIPT_DIR}"/"${script_name}" "${@}" | ||
else | ||
debug "${script_name} does not exist" | ||
fi | ||
} | ||
# vim: ft=bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${0}" )" > /dev/null 2>&1 && pwd ) | ||
|
||
. "${SCRIPT_DIR}/dx.sh.lib" | ||
|
||
require_command "docker" | ||
load_docker_compose_env | ||
|
||
usage_description="Execute a command inside the app's container." | ||
usage_args="[-s service] [-v ruby_version] command" | ||
usage_pre="exec.pre" | ||
usage_on_help "${usage_description}" "${usage_args}" "${usage_pre}" "" "${@}" | ||
|
||
LATEST_RUBY=${RUBY_VERSIONS[0]} | ||
DEFAULT_SERVICE=gli-${LATEST_RUBY} | ||
SERVICE="${SERVICE_NAME:-${DEFAULT_SERVICE}}" | ||
while getopts "v:s:" opt "${@}"; do | ||
case ${opt} in | ||
v ) | ||
SERVICE="gli-${OPTARG}" | ||
;; | ||
s ) | ||
SERVICE="${OPTARG}" | ||
;; | ||
\? ) | ||
log "🛑" "Unknown option: ${opt}" | ||
usage "${description}" "${usage_args}" "${usage_pre}" | ||
;; | ||
: ) | ||
log "🛑" "Invalid option: ${opt} requires an argument" | ||
usage "${description}" "${usage_args}" "${usage_pre}" | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND -1)) | ||
|
||
if [ $# -eq 0 ]; then | ||
log "🛑" "You must provide a command e.g. bash or ls -l" | ||
usage "${description}" "${usage_args}" "${usage_pre}" | ||
fi | ||
|
||
|
||
exec_hook_if_exists "exec.pre" | ||
|
||
log "🚂" "Running '${*}' inside container with service name '${SERVICE}'" | ||
|
||
docker \ | ||
compose \ | ||
--file docker-compose.dx.yaml \ | ||
--project-name "${PROJECT_NAME}" \ | ||
--env-file "${ENV_FILE}" \ | ||
exec \ | ||
"${SERVICE}" \ | ||
"${@}" | ||
|
||
# vim: ft=bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${0}" )" > /dev/null 2>&1 && pwd ) | ||
|
||
. "${SCRIPT_DIR}/dx.sh.lib" | ||
require_command "docker" | ||
load_docker_compose_env | ||
|
||
usage_on_help "Prune containers for this repo" "" "" "" "${@}" | ||
|
||
for container_id in $(docker container ls -a -f "name=^${PROJECT_NAME}-.*-1$" --format="{{.ID}}"); do | ||
log "🗑" "Removing container with id '${container_id}'" | ||
docker container rm "${container_id}" | ||
done | ||
echo "🧼" "Containers removed" | ||
|
||
# vim: ft=bash |
Oops, something went wrong.