Skip to content

Commit 5d139cf

Browse files
committed
setup core files and gems
1 parent b5a3533 commit 5d139cf

File tree

96 files changed

+635
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+635
-0
lines changed

.bundle/config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
BUNDLE_BIN: "bin"
3+
BUNDLE_PATH: "vendor/gems"
4+
BUNDLE_CACHE_PATH: "vendor/cache"
5+
BUNDLE_CACHE_ALL: "true"
6+
BUNDLE_SPECIFIC_PLATFORM: "true"
7+
BUNDLE_NO_INSTALL: "true"

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
docs/
2+
bin/
3+
README.md
4+
.gitignore
5+
tmp/
6+
.git
7+
coverage/
8+
vendor/gems/
9+
.github/
10+
.devcontainer/
11+
.ruby-lsp/
12+
docker-compose.yml

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @GrantBirki

.github/copilot-instructions.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Copilot Instructions
2+
3+
You are an AI assistant that specializes in software development for the Ruby programming language.
4+
5+
## Environment Setup
6+
7+
Regarding scripts that manage the environment or start the app, follow the guidance given by GitHub in their [Scripts to Rule Them All](https://github.blog/engineering/scripts-to-rule-them-all/) blog post. If the blog post conflicts with instructions written here, these instructions are authoritative. For example:
8+
9+
Bootstrap the Ruby project by running:
10+
11+
```bash
12+
script/bootstrap
13+
```
14+
15+
## Testing
16+
17+
Ensure all unit tests pass by running the following:
18+
19+
```bash
20+
script/test
21+
```
22+
23+
This project **requires 100% test coverage** of code, not including:
24+
25+
- dependencies or their bin scripts
26+
- tests
27+
- scripts in `script/`
28+
- contents of directories that begin with a dot (`.`)
29+
30+
Tests are powered by Ruby's `rspec`. By running `script/test`, the tool `simplecov` will be automatically used and will exit with a non-zero code if the coverage is below 100%.
31+
32+
## Linting
33+
34+
Ensure the linter passes by running:
35+
36+
```bash
37+
script/lint
38+
```
39+
40+
The linter is powered by `rubocop` with its config file located at `.rubocop.yml`. The linter will exit with a non-zero code if any issues are found. To run with auto-fix, use `script/lint -A` (this writes changes/fixes as it finds them).
41+
42+
## Project Guidelines
43+
44+
- Follow:
45+
- Object-Oriented best practices, especially abstraction and encapsulation
46+
- GRASP Principles, especially Information Expert, Creator, Indirection, Low Coupling, High Cohesion, and Pure Fabrication
47+
- SOLID principles, especially Dependency Inversion, Open/Closed, and Single Responsibility
48+
- Design Patterns defined by the Gang of Four, especially Abstract Factory, Factory Method, Chain of Responsibility, Command, Mediator, Observer, State, and Adaptor patterns.
49+
- The YAGI rule: do not introduce extra indirection, abstraction, or complexity unless the benefits of doing so are immediately used. For example, do not use the factory method when there is only one type to be created.
50+
- Use double quotes for strings unless single quotes are absolutely required.
51+
- Base new work on latest `main` branch.
52+
- Changes should maintain consistency with existing patterns and style.
53+
- Document changes clearly and thoroughly, including updates to existing comments when appropriate. Try to use the same "voice" as the other comments, mimicking their tone and style.
54+
- When responding to code refactoring suggestions, function suggestions, or other code changes, please keep your responses as concise as possible. We are capable engineers and can understand the code changes without excessive explanation. If you feel that a more detailed explanation is necessary, you can provide it, but keep it concise.
55+
- When suggesting code changes, always opt for the most maintainable approach. Try your best to keep the code clean and follow DRY principles. Avoid unnecessary complexity and always consider the long-term maintainability of the code.
56+
- When writing unit tests, try to consider edge cases as well as the main path of success. This will help ensure that the code is robust and can handle unexpected inputs or situations.
57+
- If you are updating docs to be YARD-style, please ensure that you keep all and any existing notes or examples in the documentation. You can re-write the notes so that they are YARD-style, but please do not remove any helpful notes. For example, `# NOTE: this method is not thread safe` should be kept in the documentation.
58+
- No additions should ever include credentials, secrets, or personally-identifying information (except github.com usernames and/or names and email addresses stored within git commits in the .git directory).
59+
- Hard-coded strings should almost always be constant variables.
60+
- In general, avoid introducing new dependencies. Use the following guidance:
61+
- Some dependencies are the de facto way to accomplish a goal and should be introduced. For example:
62+
- using a dependency to connect to a database, such as mysql2
63+
- using a dependency for instrumentation, such as dogstatsd-ruby
64+
- using a dependency for process management, such as puma
65+
- using a dependency for unit testing, such as rspec
66+
- using a dependency for serving HTTP requests, such as sinatra
67+
- Introducing a dependency to only use a single method from it should be avoided. Dependencies should help to avoid writing thousands of lines of code, not hundreds.
68+
- Introducing a dependency to use it for a different purpose than it was written for should be avoided
69+
- In writing code, take the following as preferences but not rules:
70+
- Understandability over concision
71+
- Syntax, expressions, and blocks that are common across many languages over language-specific syntax.
72+
- More descriptive names over brevity of variable, function, and class names.
73+
- The use of whitespace (newlines) over compactness of files.
74+
- Naming of variables and methods that lead to expressions and blocks reading more like English sentences.
75+
- Less lines of code over more. Keep changes minimal and focused.
76+
77+
## Pull Request Requirements
78+
79+
- All tests must pass.
80+
- The linter must pass.
81+
- Documentation must be up-to-date.
82+
- Any new dependencies must be vendored.
83+
- All new code must have YARD-style documentation.
84+
- The body of the Pull Request should:
85+
- Contain a summary of the changes.
86+
- Make special note of any changes to dependencies.
87+
- Comment on the security of the changes being made and offer suggestions for further securing the code.
88+
89+
## Repository Organization
90+
91+
- `.github/` - GitHub configurations and settings
92+
- `docs/` - Main documentation storage
93+
- `script/` - Repository maintenance scripts. Includes things like `script/bootstrap`, `script/test`, and `script/lint`.
94+
- `config/` - Configuration files for the project.
95+
- `lib/` - Main code for the project. This is where the main application/service code lives.
96+
- `spec/` - Tests for the project. This is where the unit tests and acceptance tests live.
97+
- `vendor/cache` - Vendored dependencies (Ruby Gems).
98+
- `vendor/gems` - Location to which bundler should install the Ruby Gems sourced from `vendor/cache`.

.github/dependabot.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: bundler
5+
vendor: true
6+
directory: "/"
7+
schedule:
8+
interval: weekly
9+
day: "monday"
10+
time: "21:00"
11+
groups:
12+
prod-ruby-dependencies:
13+
dependency-type: "production"
14+
patterns:
15+
- "*"
16+
dev-ruby-dependencies:
17+
dependency-type: "development"
18+
patterns:
19+
- "*"
20+
- package-ecosystem: github-actions
21+
directory: "/"
22+
groups:
23+
github-actions:
24+
patterns:
25+
- "*"
26+
schedule:
27+
interval: weekly
28+
day: "tuesday"
29+
time: "21:00"

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bin/
2+
coverage/
3+
logs/
4+
tmp/
5+
tarballs/
6+
vendor/gems/
7+
.idea
8+
.byebug_history
9+
.local/
10+
.DS_Store
11+
.lesshst
12+
*.pem
13+
*.key
14+
*.crt
15+
*.csr
16+
*.secret

.rubocop.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
inherit_gem:
2+
rubocop-github:
3+
- config/default.yml
4+
5+
AllCops:
6+
NewCops: enable
7+
SuggestExtensions: false
8+
DisplayCopNames: true
9+
TargetRubyVersion: 3.4
10+
Exclude:
11+
- "bin/**/*"
12+
- "tmp/**/*"
13+
- "vendor/**/*"
14+
15+
Style/HashSyntax:
16+
Enabled: false

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.4.4

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ARG RUBY_VERSION=3
2+
FROM ruby:${RUBY_VERSION}-slim AS base
3+
4+
# create a nonroot user
5+
RUN useradd -m nonroot
6+
7+
WORKDIR /app
8+
9+
# install system dependencies
10+
RUN apt-get -qq update && apt-get --no-install-recommends install -y \
11+
build-essential \
12+
git
13+
14+
# set the BUNDLE_APP_CONFIG environment variable
15+
ENV BUNDLE_APP_CONFIG=/app/.bundle
16+
17+
# copy bundler config
18+
COPY --chown=nonroot:nonroot .bundle ./.bundle
19+
20+
# install core scripts
21+
COPY --chown=nonroot:nonroot script ./script
22+
23+
# copy core ruby files first
24+
COPY --chown=nonroot:nonroot .ruby-version Gemfile Gemfile.lock ./
25+
26+
# copy vendored gems
27+
COPY --chown=nonroot:nonroot vendor ./vendor
28+
29+
# bootstrap the ruby environment
30+
RUN RUBY_ENV=production script/bootstrap
31+
32+
# copy the rest of the application
33+
COPY --chown=nonroot:nonroot . .
34+
35+
# change ownership of /app directory to nonroot user
36+
RUN chown -R nonroot:nonroot /app
37+
38+
# switch to the nonroot user
39+
USER nonroot
40+
41+
# set the environment to production
42+
ENV RUBY_ENV=production

Gemfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gemspec
6+
7+
group :development do
8+
gem "irb", "~> 1"
9+
gem "rspec", "~> 3"
10+
gem "rubocop", "~> 1"
11+
gem "rubocop-github", "~> 0.23"
12+
gem "rubocop-performance", "~> 1"
13+
gem "rubocop-rspec", "~> 3"
14+
gem "simplecov", "~> 0.22"
15+
gem "simplecov-erb", "~> 1"
16+
gem "vcr", "~> 6.3", ">= 6.3.1"
17+
gem "webmock", "~> 3"
18+
end

0 commit comments

Comments
 (0)