Skip to content

Commit

Permalink
Merge pull request #469 from nimblehq/release/5.8.0
Browse files Browse the repository at this point in the history
Release 5.8.0
  • Loading branch information
malparty authored Sep 15, 2023
2 parents 2a736d5 + 71ebbb8 commit c4b47a1
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 139 deletions.
117 changes: 117 additions & 0 deletions .github/wiki/Contribution-Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
## How to contribute

### Template structure

```
.
├── .template
│ ├── addons
│ │ └── docker
│ │ ├── ...
│ │ └── template.rb
│ └── variants
│ ├── api
│ │ ├── ...
│ │ └── template.rb
│ └── web
│ ├── ...
│ └── template.rb
├── app
├── bin
├── config
├── spec
├── ...
├── README.md
├── README.md.tt
└── template.rb
```

We keep the Rails-app-like structure. On the root, there are base project file templates.
Other files including the template options are in `.template` folder.

There are 2 kinds of the template options:

1. **Variants** - For the app main options, which are `web` and `api`.

2. **Addons** - For other extra options that we can add to the project like `docker` or `bootstrap`,
use the prompt `ask` to generate a question before generating the project.

### Template files

There are 2 template file types:

1. **`.tt` files**

This file is used for templating the whole new file.
In case if we want to create a new file that Rails has not generated.

2. **`.rb` files**

This is used for modifying the files that Rails has generated.
The file name should be the same as on the generated app.
If it is not a ruby file, append the `.rb` as an extension e.g. `Gemfile.rb`

### Template specs

We are using [Serverspec](https://serverspec.org/) to test the template.
For any changes made, you **must** add a spec for it.

Test files are located under `.template/spec` folder

```
.
├── ...
├── .template
│ ├── ...
│ ├── spec
│ │ └── addons
│ │ │ └── base
│ │ │ │ └── docker
│ │ │ │ │ ├── ...
│ │ │ │ │ └── template_spec.rb
│ │ │ │ └── semaphore
│ │ │ │ │ ├── ...
│ │ │ │ │ └── template_spec.rb
│ │ │ └── variants
│ │ │ │ └── web
│ │ │ │ │ └── boostrap
│ │ │ │ │ ├── ...
│ │ │ │ │ └── template_spec.rb
│ │ │ │ └── api
│ │ │ │ │ └── addon
│ │ │ │ │ ├── ...
│ │ │ │ │ └── template_spec.rb
│ │ └── base
│ │ │ ├── ...
│ │ │ └── template_spec.rb
│ │ └── variants
│ │ │ └── web
│ │ │ │ ├── ...
│ │ │ │ └── template_spec.rb
│ │ │ └── api
│ │ │ │ ├── ...
│ │ │ │ └── template_spec.rb
```

### Template Strings

When using template string with heredoc, use the proper name following the file type / content.

This provides the meaningful context to the content and some IDEs also support to highlight the content depending on the type.

- `DOCKERFILE`
- `ERB`
- `HTML`
- `IGNORE` - For any ignore file e.g. `.gitignore`, `.eslintignore`
- `JAVASCRIPT`
- `JSON`
- `PROCFILE`
- `RUBY`
- `SCSS`
- `SHELL`

For other files that are not fit the types above, use the extension as the name
e.g. `TOOL_VERSION` for `.tool-version` file.

For the normal string, name it after the content
e.g. `ERROR` for template error message.
14 changes: 14 additions & 0 deletions .github/wiki/Testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Testing the Template

To run [RuboCop](https://github.com/rubocop/rubocop) against the template:

```sh
.template/bin/rubocop
```

Any RuboCop command options can be passed:

```sh
# Run RuboCop with auto correct
.template/bin/rubocop -a
```
19 changes: 19 additions & 0 deletions .github/wiki/_Footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## About

<a href="https://nimblehq.co/">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://assets.nimblehq.co/logo/dark/logo-dark-text-160.png">
<img alt="Nimble logo" src="https://assets.nimblehq.co/logo/light/logo-light-text-160.png">
</picture>
</a>

This project is maintained and funded by Nimble.

We ❤️ open source and do our part in sharing our work with the community!
See [our other projects][community] or [hire our team][hire] to help build your product.

Want to join? [Check out our Jobs][jobs]!

[community]: https://github.com/nimblehq
[hire]: https://nimblehq.co/
[jobs]: https://jobs.nimblehq.co/
4 changes: 4 additions & 0 deletions .github/wiki/_Sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Table of Contents

- [[Contribution Guide]]
- [[Testing]]
Empty file.
7 changes: 2 additions & 5 deletions .template/addons/github/.github/workflows/test.yml.tt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
run: docker-compose pull test || true

- name: Run codebase test
run: docker-compose run test bundle exec rspec spec/codebase/codebase_spec.rb --format progress
run: docker-compose run test -e DISABLE_SPRING=1 bundle exec rspec spec/codebase/codebase_spec.rb --format progress

unit_tests:
name: Unit tests
Expand All @@ -98,7 +98,7 @@ jobs:
run: docker-compose pull test || true

- name: Run unit tests
run: docker-compose run test bundle exec rspec --exclude-pattern "spec/systems/**/*_spec.rb, spec/codebase/codebase_spec.rb" --profile --format progress
run: docker-compose run test -e DISABLE_SPRING=1 bundle exec rspec --exclude-pattern "spec/systems/**/*_spec.rb, spec/codebase/codebase_spec.rb" --profile --format progress

- name: Upload tests coverage artifact
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -153,9 +153,6 @@ jobs:
- name: Download tests coverage artifact
uses: actions/download-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: test.yml
workflow_conclusion: success
name: coverage
path: coverage

Expand Down
3 changes: 3 additions & 0 deletions .template/variants/web/spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
# Disable /dev/shm use in CI
options.add_argument('disable-dev-shm-usage') if ENV['CI']

# Use English locale for displaying page
options.add_preference('intl.accept_languages', 'en')

Capybara::Selenium::Driver.new(
app,
browser: :chrome,
Expand Down
2 changes: 1 addition & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
rubocop.lint(inline_comment: true, force_exclusion: true)

# Runs Brakeman on modified and added files
brakeman.run
brakeman.run('./')

# Runs Reek on modified and added files
reek.lint
Expand Down
134 changes: 3 additions & 131 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,138 +62,10 @@ make dev

Read more about Rails Application Template in the [official Rails Guides](https://guides.rubyonrails.org/rails_application_templates.html).

## How to contribute
## Contribution Resources

### Template structure

```
.
├── .template
│ ├── addons
│ │ └── docker
│ │ ├── ...
│ │ └── template.rb
│ └── variants
│ ├── api
│ │ ├── ...
│ │ └── template.rb
│ └── web
│ ├── ...
│ └── template.rb
├── app
├── bin
├── config
├── spec
├── ...
├── README.md
├── README.md.tt
└── template.rb
```

We keep the Rails-app-like structure. On the root, there are base project file templates.
Other files including the template options are in `.template` folder.

There are 2 kinds of the template options:

1. **Variants** - For the app main options, which are `web` and `api`.

2. **Addons** - For other extra options that we can add to the project like `docker` or `bootstrap`,
use the prompt `ask` to generate a question before generating the project.

### Template files

There are 2 template file types:

1. **`.tt` files**

This file is used for templating the whole new file.
In case if we want to create a new file that Rails has not generated.

2. **`.rb` files**

This is used for modifying the files that Rails has generated.
The file name should be the same as on the generated app.
If it is not a ruby file, append the `.rb` as an extension e.g. `Gemfile.rb`

### Template specs

We are using [Serverspec](https://serverspec.org/) to test the template.
For any changes made, you **must** add a spec for it.

Test files are located under `.template/spec` folder

```
.
├── ...
├── .template
│ ├── ...
│ ├── spec
│ │ └── addons
│ │ │ └── base
│ │ │ │ └── docker
│ │ │ │ │ ├── ...
│ │ │ │ │ └── template_spec.rb
│ │ │ │ └── semaphore
│ │ │ │ │ ├── ...
│ │ │ │ │ └── template_spec.rb
│ │ │ └── variants
│ │ │ │ └── web
│ │ │ │ │ └── boostrap
│ │ │ │ │ ├── ...
│ │ │ │ │ └── template_spec.rb
│ │ │ │ └── api
│ │ │ │ │ └── addon
│ │ │ │ │ ├── ...
│ │ │ │ │ └── template_spec.rb
│ │ └── base
│ │ │ ├── ...
│ │ │ └── template_spec.rb
│ │ └── variants
│ │ │ └── web
│ │ │ │ ├── ...
│ │ │ │ └── template_spec.rb
│ │ │ └── api
│ │ │ │ ├── ...
│ │ │ │ └── template_spec.rb
```

### Template Strings

When using template string with heredoc, use the proper name following the file type / content.

This provides the meaningful context to the content and some IDEs also support to highlight the content depending on the type.

- `DOCKERFILE`
- `ERB`
- `HTML`
- `IGNORE` - For any ignore file e.g. `.gitignore`, `.eslintignore`
- `JAVASCRIPT`
- `JSON`
- `PROCFILE`
- `RUBY`
- `SCSS`
- `SHELL`

For other files that are not fit the types above, use the extension as the name
e.g. `TOOL_VERSION` for `.tool-version` file.

For the normal string, name it after the content
e.g. `ERROR` for template error message.

## Testing the Template

To run [RuboCop](https://github.com/rubocop/rubocop) against the template:

```sh
.template/bin/rubocop
```

Any RuboCop command options can be passed:

```sh
# Run RuboCop with auto correct
.template/bin/rubocop -a
```
- [Contributions Guidelines](../../wiki/Contribution_Guide).
- [Testing the template](../../wiki/Testing)

## License

Expand Down
2 changes: 1 addition & 1 deletion spec/codebase/codebase_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'

describe 'Codebase', codebase: true do
describe 'Codebase', :codebase do
it 'does not offend Rubocop' do
expect(`rubocop --parallel --format simple`).to include 'no offenses detected'
end
Expand Down
4 changes: 3 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require 'spec_helper'
require 'support/simplecov'

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)

require 'spec_helper'
require 'rspec/rails'
require 'json_matchers/rspec'
require 'pundit/rspec'
Expand Down

0 comments on commit c4b47a1

Please sign in to comment.