Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance collaboration DX through devcontainer #63

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ services:
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

environment:
SELENIUM_REMOTE_HOST: selenium

# Uncomment the next line to use a non-root user for all processes.
# user: vscode

Expand Down
7 changes: 2 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
"ghcr.io/devcontainers/features/node:1": {
"version": "22.11.0"
},
"ghcr.io/duduribeiro/devcontainer-features/tmux:1": {}
},
"containerEnv": {
"CAPYBARA_SERVER_PORT": "45678",
"SELENIUM_HOST": "selenium"
"ghcr.io/duduribeiro/devcontainer-features/tmux:1": {},
"ghcr.io/rails/devcontainer/features/bundler-cache:1": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"
# Use main development branch of Rails
gem "rails"

gem "inertia_rails", github: "inertiajs/inertia-rails"
gem "inertia_rails"

gem "vite_rails", "~> 3.0.19"
# Use sqlite3 as the database for Active Record
Expand Down
11 changes: 3 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
GIT
remote: https://github.com/inertiajs/inertia-rails.git
revision: 234aaabba071028517857743396fee62683f7a37
specs:
inertia_rails (3.5.0)
railties (>= 6)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -154,6 +147,8 @@ GEM
activesupport (>= 6.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
inertia_rails (3.5.0)
railties (>= 6)
io-console (0.7.2)
irb (1.14.1)
rdoc (>= 4.0.0)
Expand Down Expand Up @@ -454,7 +449,7 @@ DEPENDENCIES
capybara
debug
factory_bot_rails
inertia_rails!
inertia_rails
kamal
mailjet (~> 1.8)
overmind
Expand Down
124 changes: 111 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,122 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:
## Getting Started

* Ruby version

* System dependencies

* Configuration
## Development Setup

* Database creation
To set up the Benefactorum project locally:

* Database initialization
1. **Prerequisites**: Ensure you have [Visual Studio Code](https://code.visualstudio.com/) installed.
2. **Dev Container**: Open the project in VS Code; it will automatically set up the development container.
3. **Start Development**: Once the setup is complete, run the following command to start the development environment:

* How to run the test suite
```bash
bin/dev

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...


---

# Benefactorum

Benefactorum is a non-profit, collaborative donation platform that enables French donors to easily discover and support the causes they care about.

---

## Features

1. **Find Associations**: Discover organizations that align with your values.
2. **Make Donations**: Donate directly through Benefactorum.
3. **Tax Benefits**: Easily manage your tax deductions.

---

## Tech Stack

### Backend
- **Ruby on Rails 8**: Provides a robust and maintainable backend foundation.
- **SQLite**: Lightweight and efficient database for streamlined deployment and development.

### Frontend
- **React with TypeScript**: Ensures a dynamic and type-safe front-end experience.
- **Inertia.js**: Bridges the gap between Rails and React for fast single-page app functionality.
- **TailwindCSS**: Provides a modern, responsive, and customizable UI.
- **shadcn/ui**: Reusable components for consistent design.

### Build & Deployment
- **Vite**: Efficient asset bundling and faster development builds.
- **Kamal**: Simplified deployment to Scaleway VPS.
- **GitHub Actions**: Manages CI/CD workflows for testing and deployment.

---

## Installation & Setup

### Prerequisites
- Ensure you have [Visual Studio Code](https://code.visualstudio.com/) or [Dev Container CLI](https://github.com/devcontainers/cli) installed.

### Steps
1. Clone the repository:
```bash
git clone https://github.com/Benefactorum/app benefactorum
cd benefactorum
```

2. Start the development server:
```bash
bin/dev
```

3. Open your browser and navigate to:
```
http://localhost:3000
```

---

## Testing

Run tests to ensure stability:
```bash
bundle exec rspec # Backend & e2e tests
yarn test # Frontend tests
```

---

## Contributing

We welcome contributions! To contribute:
1. Fork the repository.
2. Create a feature branch:
```bash
git checkout -b feature/your-feature-name
```
3. Commit your changes:
```bash
git commit -m "Add your feature description"
```
4. Push your branch and open a Pull Request.

Please follow the coding standards enforced by **Standard Ruby**, **Prettier**, and **ESLint**.

---

## License

This project is licensed under the MIT License.

---

## Contact

For any inquiries, feel free to reach out:
- Email: [email protected]
- Manifesto: [benefactorum.org](https://benefactorum.org)
- Web app: https://staging.benefactorum.org

---
7 changes: 6 additions & 1 deletion app/services/captcha.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class Captcha
SECRET_KEY = Rails.application.credentials.recaptcha[:secret_key]
SECRET_KEY = Rails.application.credentials.dig(:recaptcha, :secret_key)

def initialize(token)
@token = token
end

def valid?
return true if Rails.env.development?

response = Net::HTTP.post_form(
URI.parse("https://www.google.com/recaptcha/api/siteverify"),
{
Expand All @@ -15,5 +17,8 @@ def valid?
)
result = JSON.parse(response.body)
!!result["success"]
rescue Net::HTTPError => e
Rails.logger.error "Captcha validation error: #{e.message}"
false
end
end
4 changes: 4 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ FileUtils.chdir APP_ROOT do
puts "== Installing dependencies =="
system("bundle check") || system!("bundle install")

puts "\n== Installing JavaScript dependencies =="
system("yarn check --integrity") || system!("yarn install")


# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
Expand Down
24 changes: 10 additions & 14 deletions config/initializers/mailjet.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# this condition is needed for build step : RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile
# because Rails.application.credentials is not available in this context as RAILS_MASTER_KEY is not set to decrypt rails secrets
if Rails.application.credentials.mailjet.present?
Mailjet.configure do |config|
config.api_key = Rails.application.credentials.mailjet.api_key
config.secret_key = Rails.application.credentials.mailjet.secret_key
config.default_from = "[email protected]"
# Mailjet API v3.1 is at the moment limited to Send API.
# We’ve not set the version to it directly since there is no other endpoint in that version.
# We recommend you create a dedicated instance of the wrapper set with it to send your emails.
# If you're only using the gem to send emails, then you can safely set it to this version.
# Otherwise, you can remove the dedicated line into config/initializers/mailjet.rb.
config.api_version = "v3.1"
end
Mailjet.configure do |config|
config.api_key = Rails.application.credentials.dig(:mailjet, :api_key)
config.secret_key = Rails.application.credentials.dig(:mailjet, :secret_key)
config.default_from = "[email protected]"
# Mailjet API v3.1 is at the moment limited to Send API.
# We’ve not set the version to it directly since there is no other endpoint in that version.
# We recommend you create a dedicated instance of the wrapper set with it to send your emails.
# If you're only using the gem to send emails, then you can safely set it to this version.
# Otherwise, you can remove the dedicated line into config/initializers/mailjet.rb.
config.api_version = "v3.1"
end
31 changes: 31 additions & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require "capybara/rspec"

Capybara.register_driver :remote_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--window-size=1400,1400")

Capybara::Selenium::Driver.new(
app,
browser: :remote,
url: "http://selenium:4444/wd/hub",
capabilities: options
)
end

Capybara.javascript_driver = :remote_chrome

RSpec.configure do |config|
config.before(:each, type: :system) do
if ENV["SELENIUM_REMOTE_HOST"]
Capybara.server_host = "0.0.0.0"
Capybara.server_port = 3001
Capybara.app_host = "http://rails-app:3001"
driven_by :remote_chrome
else
driven_by :selenium_chrome_headless
end
end
end
Loading