-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1459 from geeksforsocialchange/better-setup
Automate setup
- Loading branch information
Showing
5 changed files
with
45 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,11 +38,13 @@ To run PlaceCal locally you will need: | |
|
||
With that said, here's what you need to get rolling. | ||
|
||
### Set up postgresql server (Via docker) | ||
### Set up Postgresql locally | ||
|
||
**Note: Skip this step if you're using a system-installed docker** | ||
If you don't already have Postgresql installed and running, here's how you can set it up with Docker. | ||
|
||
Creating a postgres docker image is reasonably quick: | ||
**Skip these steps if you already have Postgresql set up.** | ||
|
||
Creating a Postgresql Docker image is reasonably quick: | ||
|
||
```sh | ||
docker network create placecal-network | ||
|
@@ -60,47 +62,45 @@ POSTGRES_USER=postgres | |
PGPASSWORD=foobar | ||
``` | ||
|
||
### Set up the local placecal repository, set up the database, and run it | ||
### Clone this Git repository | ||
|
||
``` | ||
```sh | ||
git clone https://github.com/geeksforsocialchange/PlaceCal.git | ||
bundle && yarn | ||
bundle exec rails db:setup db:migrate seed:migrate | ||
bundle exec rails import:all_events | ||
./bin/dev | ||
cd PlaceCal | ||
``` | ||
|
||
- Start the server with `./bin/dev` instead of `bundle exec rails server` due to migration to jsbundling | ||
- Make sure you use `lvh.me:3000` instead of `localhost` or you **will** have authentication problems. | ||
- Admin interface is `admin.lvh.me:3000` (You will need to make a new admin user -- see below) | ||
- Access code docs through your local filesystem, and update with `bundle exec rails yard` | ||
### Run the setup script | ||
|
||
To set up your own server, take a look at `INSTALL.md`. | ||
```sh | ||
bin/setup | ||
``` | ||
|
||
### Creating an admin user | ||
Amongst other things, this will create an admin user for you: | ||
|
||
To create an admin user, open the console (`bin/rails c`) and run the following: | ||
- Username: `[email protected]` | ||
- Password: `password` | ||
|
||
``` | ||
User.create!(email: '[email protected]', password: 'password', password_confirmation: 'password', role: :root) | ||
``` | ||
### Run the thing | ||
|
||
(Note: You should replace '[email protected]' and 'password' with more appropriate values) | ||
- Start the server with `bin/dev` | ||
- Make sure you use `lvh.me:3000` instead of `localhost:3000` or you **will** have authentication problems | ||
- The admin interface is at `admin.lvh.me:3000` | ||
- Access code docs through your local filesystem and update them with `bin/rails yard` | ||
|
||
## Testing | ||
|
||
PlaceCal tests are written in minitest. Before running the tests please ensure your dev environment has all of the migrations run, and ensure you have loaded the schema into the test database by running: | ||
|
||
```sh | ||
rails db:test:prepare | ||
bin/rails db:test:prepare | ||
``` | ||
|
||
The following commands are used for running tests: | ||
|
||
```sh | ||
rails test # To run all of the unit tests | ||
rails test:system # To run all of the system tests (Invokes a headless browser) | ||
rails test:all # To run both the unit tests and the system tests at once | ||
bin/rails test # To run all of the unit tests | ||
bin/rails test:system # To run all of the system tests (Invokes a headless browser) | ||
bin/rails test:all # To run both the unit tests and the system tests at once | ||
``` | ||
|
||
Please note that when running unit tests, system tests are **not** run, this is because they can take a while to run and are quite resource intensive. To perform more advanced usage like executing only a specific test or test file, see the documentation [here](https://guides.rubyonrails.org/testing.html) | ||
|
@@ -114,7 +114,7 @@ We use [Prettier](https://prettier.io/) to format everything it's able to parse. | |
If you do want to run it manually, you can: | ||
|
||
```sh | ||
yarn run format | ||
bin/yarn run format | ||
``` | ||
|
||
Note that we use tabs over spaces because [tabs are more accessible to people using braille displays](https://twitter.com/Rich_Harris/status/1541761871585464323). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,18 +15,23 @@ FileUtils.chdir APP_ROOT do | |
|
||
puts '== Installing dependencies ==' | ||
system! 'gem install bundler --conservative' | ||
system('bundle check') || system!('bundle install') | ||
system('bin/bundle check') || system!('bin/bundle install') | ||
system! 'bin/yarn install' | ||
|
||
# Install JavaScript dependencies | ||
# system('bin/yarn') | ||
|
||
# puts "\n== Copying sample files ==" | ||
# unless File.exist?('config/database.yml') | ||
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml' | ||
# end | ||
puts "\n== Copying sample files ==" | ||
unless File.exist?('.env') | ||
FileUtils.cp '.env.example', '.env' | ||
end | ||
|
||
puts "\n== Preparing database ==" | ||
system! 'bin/rails db:prepare' | ||
system! 'bin/rails seed:migrate' | ||
|
||
puts "\n== Importing events ==" | ||
system! 'bin/rails import:all_events' | ||
|
||
puts "\n== Creating admin user ==" | ||
system! 'bin/rails runner \'User.where(email: "[email protected]").exists? || User.create!(email: "[email protected]", password: "password", password_confirmation: "password", role: :root)\'' | ||
|
||
puts "\n== Removing old logs and tempfiles ==" | ||
system! 'bin/rails log:clear tmp:clear' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters