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

closes #456 - update development setup #465

Merged
merged 8 commits into from
Jan 19, 2021

Conversation

Ulisseus
Copy link
Collaborator

Fixes issue #456.

This PR will add step by step guide on how to configure fully local copy of c0d3 app. It comes with preconfigured docker compose (lesson/challenges data, admin user which has completed lesson 0 and is able to review new submissions).

Potential issues:
No tests for docker images, in theory I could try to start test containers, load dump and compare it to dummy lesson data, but should I? These tests won't be fast.
I explicitly added port in sequelize options, maybe I am overlooking something but sequelize refuses to work when you provide host:port in options. I even went as far as checking my hostfile since I use localhost, but I still couldn't figure it out.

@vercel
Copy link

vercel bot commented Jan 12, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/c0d3/c0d3-app/a3uwavdng
✅ Preview: https://c0d3-app-git-fork-ulisseus-devsetup-main.c0d3.vercel.app

@@ -13,6 +13,7 @@ const sequelize = new Sequelize(
process.env.DB_PW || 'this',
{
host: process.env.DB_HOST || 'city',
port: ((process.env.DB_PORT as unknown) as number) || 5432,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this won't break production.

Copy link
Collaborator

@anthonykhoa anthonykhoa Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will break production since 5432 is the default port for a postgresql database. I'm not sure if we have changed our configurations to use a different port.

However, I think that this port key should only be added in when used for development. In case we are not using 5432 as the port for our production database, or in case the port for the database we use ever changes, this will ensure that nothing breaks.

import { Options, Sequelize } from 'sequelize'
// showing you the import so you can see where I got the Options type

const sequelizeOptions: Options = {
  host: process.env.DB_HOST || 'city',
  logging: false,
  dialect: 'postgres',
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  }
}
if (process.env.MODE === 'DEV') {
  sequelizeOptions.port = ((process.env.DB_PORT as unknown) as number) || 5432
}
const sequelize = new Sequelize(
  process.env.DB_NAME || 'you',
  process.env.DB_USER || 'failed',
  process.env.DB_PW || 'this',
  sequelizeOptions
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better safe than sorry. Done.

@codecov
Copy link

codecov bot commented Jan 12, 2021

Codecov Report

Merging #465 (6fa923c) into master (6d96268) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #465   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           89        91    +2     
  Lines         1202      1223   +21     
  Branches       256       254    -2     
=========================================
+ Hits          1202      1223   +21     
Impacted Files Coverage Δ
helpers/dbload.ts 100.00% <100.00%> (ø)
components/theme/Button.tsx 100.00% <0.00%> (ø)
components/ChallengeMaterial.tsx 100.00% <0.00%> (ø)
graphql/queryResolvers/session.ts 100.00% <0.00%> (ø)
components/Thanks.tsx 100.00% <0.00%> (ø)
components/ModalCard.tsx 100.00% <0.00%> (ø)

docs/developmentSetup.md Outdated Show resolved Hide resolved
docs/developmentSetup.md Outdated Show resolved Hide resolved
docs/developmentSetup.md Outdated Show resolved Hide resolved
@anthonykhoa anthonykhoa merged commit 15f8e79 into garageScript:master Jan 19, 2021
@ggwadera
Copy link
Collaborator

Nice work @Ulisseus, I believe the dev setup will be much easier now.

@all-contributors please add @Ulisseus for code and documentation.

@allcontributors
Copy link
Contributor

@ggwadera

I've put up a pull request to add @Ulisseus! 🎉

@Ulisseus Ulisseus deleted the devSetup/main branch March 5, 2021 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants