From be01dba2e21dba7b732ed31e30aabca2df6da72f Mon Sep 17 00:00:00 2001 From: George Mihai Grigore Date: Thu, 12 Sep 2024 16:18:10 +0300 Subject: [PATCH] Rename test job to rspec in CI, add rake env:setup task, and update README --- .env.development.template | 2 +- .env.test.template | 4 ++-- .github/ISSUE_TEMPLATE/bug_report.md | 22 ++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 17 +++++++++++++++ .github/workflows/ci.yml | 9 ++++++-- README.md | 23 ++++++++++++++------- lib/tasks/env.rake | 25 +++++++++++++++++++++++ 7 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 lib/tasks/env.rake diff --git a/.env.development.template b/.env.development.template index e56dfaf..912db65 100644 --- a/.env.development.template +++ b/.env.development.template @@ -1,5 +1,5 @@ # Database -POSTGRES_USER= +POSTGRES_USER=postgres POSTGRES_PASSWORD= # ScoutApm diff --git a/.env.test.template b/.env.test.template index ea6ebef..66f0a61 100644 --- a/.env.test.template +++ b/.env.test.template @@ -1,5 +1,5 @@ -# Databse -POSTGRES_USER= +# Database +POSTGRES_USER=postgres POSTGRES_PASSWORD= # Redis diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..b748c81 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,22 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: Grigore-George-Mihai + +--- + +## Description +A brief description of the issue. + +## Steps to Reproduce +1. +2. +3. + +## Expected Behavior +What did you expect to happen? + +## Actual Behavior +What actually happened? diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..9b08c06 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: Grigore-George-Mihai + +--- + +## Description +A brief description of the feature you would like to see. + +## Motivation +Why is this feature important or how does it improve the project? + +## Proposed Solution +How do you think this feature should work? diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9df717b..cd6a180 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: - name: Lint code for consistent style run: bin/rubocop -f github - test: + rspec: runs-on: ubuntu-latest services: @@ -68,10 +68,15 @@ jobs: ruby-version: .ruby-version bundler-cache: true + - name: Install dependencies + run: bundle install + + - name: Run migrations + run: bin/rails db:migrate RAILS_ENV=test + - name: Prepare database and run tests run: bin/rails db:test:prepare && bundle exec rspec - - name: Keep screenshots from failed system tests uses: actions/upload-artifact@v4 if: failure() diff --git a/README.md b/README.md index e6c821f..57dfc97 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,20 @@ git clone https://github.com/Grigore-George-Mihai/graphql_template - Update the project name to reflect your application. - Modify the [Scout APM](https://github.com/scoutapp/scout_apm_ruby) settings as needed, or remove them if application performance monitoring is not required. -- Rename `.env.development.template` to `.env.development` and `.env.test.template` to `.env.test`. Populate these files with the appropriate environment-specific variables. +- Run the following rake task to create your environment files: + ```bash + rake env:setup + ```` + - After running the task, open the newly created .env.development and .env.test files to modify them with the appropriate environment-specific variables as needed. +- Create DB and seed: + ```bash + rails db:create db:migrate db:seed + ```` ## Gems ### API Framework -- +- [GraphQL](https://github.com/rmosolgo/graphql-ruby): GraphQL implementation for Ruby, providing query execution and schema building tools. ### Pagination - [Kaminari](https://github.com/kaminari/kaminari): A scope and engine-based pagination library for Rails, Sinatra, and other Ruby frameworks. @@ -69,13 +77,14 @@ git clone https://github.com/Grigore-George-Mihai/graphql_template ## Rake Tasks -Run the following rake task to check for security risks in your application: +### Security Check +- Run the following rake task to check for security risks in your application: -```bash -rake security:check -``` + ```bash + rake security:check + ``` -This task runs tools like Brakeman and Bundler Audit to ensure your application is secure. + - This task runs tools like Brakeman and Bundler Audit to ensure your application is secure. ## Contact For questions or further information, feel free to reach out via [LinkedIn](https://www.linkedin.com/in/grigore-george-mihai-73981b86/). diff --git a/lib/tasks/env.rake b/lib/tasks/env.rake new file mode 100644 index 0000000..29a3f17 --- /dev/null +++ b/lib/tasks/env.rake @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +namespace :env do + desc "Create new .env files from .env.template files" + task setup: :environment do + development_template = ".env.development.template" + test_template = ".env.test.template" + development_file = ".env.development" + test_file = ".env.test" + + if File.exist?(development_template) + File.write(development_file, File.read(development_template)) unless File.exist?(development_file) + puts "Created #{development_file} from #{development_template}" + else + puts "#{development_template} does not exist!" + end + + if File.exist?(test_template) + File.write(test_file, File.read(test_template)) unless File.exist?(test_file) + puts "Created #{test_file} from #{test_template}" + else + puts "#{test_template} does not exist!" + end + end +end