Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

jmpa-io/py-lorem

 
 

Repository files navigation

Build status

py-lorem

+ ✏️ Lorem Ipsum library for Python. 

Install

pip install py-lorem

Usage

import loremipsum

# generate a random sentence of max 20 chars.
loremipsum.sentence(max_char=20)

# generate a random sentence of arbitrary length.
loremipsum.sentence()

# generate a random paragraph of max 100 chars.
loremipsum.paragraph(max_char=100)

# generate a random paragraph of arbitrary length.
loremipsum.paragraph()

For running this project, using a terminal, run

make
# or
make help

For a list of full commands.

Design rationale

Below are some design decisions I've used in this task:

  • I've chosen to use Docker volumes over copying files into Docker images because I feel it's cleaner.
  • I've chosen to not to mount buildkite-agent into the Docker container (via the Docker plugin) because I feel CI/CD should have some separation from the runtime Docker environments used in CI/CD - this is largely so that the Docker images used in CI/CD match local development more closely.
  • Most files or scripts under ./bin/ have a number- prefix; This indicates the order of execution in the CI/CD pipeline. Any files in this directory without this prefix are intended to be run sporadically, either locally or in the CI/CD pipeline.
  • The pre-command hook in this repository is run on steps that don’t need it. In production, I would switch this process so that a generic Python image is built for all my Python projects and this image would be used here in the pipeline for this repository. Using the pre-command hook this way kind of mimics this way of working.

Repository breakdown

File Description
Makefile The entrypoint to this repository - this is used to run all the other commands used both locally and in the Buildkite pipeline (see make or make help for all the commands).
--- ---
buildkite.yml The root Buildkite pipeline for this repository. This file is outside the .buildkite directory so that it is more in-your-face and shown to be an important file.
Dockerfile The root Dockerfile in this repository - this image is used to run this project inside a Docker image locally, as well as being the artifact that is pushed to Buildkite's Docker registry.
.buildkite/hooks/pre-command A pre-command hook used to build the Dockerfile locally on each step in a Buildkite pipeline. While not ideal, the intention is to use this Docker image in each step in the pipeline required to run in a Docker container.
--- ---
bin/10-lint.sh A script used to demonstrate my skills with writing Bash scripts - this script runs all the linting it can, as of writing.

Please note: This is not a script I would have in this repository if this was in production - ideally this function and linting code would be within the Makefile itself - it's only here to showcase my experience.
bin/20-generate-sentence.py A Python file to simplify creating dist/sentence.txt.
bin/30-generate-paragraph.py A Python file to simplify creating dist/paragraph.txt.
bin/bk-annotate-file.sh Another script to demonstrate my skills with writing Bash scripts - this script is used to wrap annotating a given file and sending it through to buildkite-agent annotate - it's only intended to be run in the Buildkite pipeline.

Challenges faced

  1. Using the Docker plugin in the pipeline.

    • I've found code is easier to manage when the control of Docker is outside CI/CD, so that whatever I run is able to be run both locally and in the pipeline and they match - if one changes the other changes. I understand the bk CLI can run pipelines though.
  2. I installed a buildkite-agent manually inside my homelab; My homelab is new to me and still being setup - there were some teething issues that were fun to fix.

  3. Below are some technical issues that still exist but I'm aware of:

    • The pre-command hook in this repository is run on steps that don't need it. In production, I would switch this process so that a generic Python image is built for all my Python projects and this image would be used here in the pipeline for this repository.
  4. It's been a while since I worked on a Buildkite pipeline, so I had to refresh a little.

References / Notes

Below are some references & some notes I took while doing this task:

License

The license for this is to of do-whatever-the-hell-you-want-with-it :)

Authors

About

✏️ Lorem Ipsum library for Python.

Topics

Resources

Stars

Watchers

Forks

Languages

  • Makefile 45.5%
  • Shell 30.2%
  • Python 22.0%
  • Dockerfile 2.3%