Skip to content

WIP: Implement Geographic Data Models and Migrations #545

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

Draft
wants to merge 68 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5a15a63
WIP: Add initial geography models and seed data
rsmithlal May 21, 2024
4a5db11
WIP: Added Regions, Settlements, and region settlements
rsmithlal May 23, 2024
5aceb43
Fix migration copy omission
rsmithlal May 23, 2024
dcd6076
Update install generator to include column definitions in the table a…
rsmithlal May 23, 2024
cec92b2
disable trix editor for now
rsmithlal May 24, 2024
2397ad8
Ensure that primary community is always created from the primary reco…
rsmithlal May 24, 2024
1c5e561
Update minitest version
rsmithlal May 24, 2024
16b3560
add route resources for region_settlements
rsmithlal May 24, 2024
ea56fb2
specs passing
rsmithlal May 24, 2024
6cef744
Rubocop changes
rsmithlal May 24, 2024
19bcd3c
Rubocop changes
rsmithlal May 24, 2024
ecd457d
Create and assign primary community before validation
rsmithlal May 24, 2024
40c9e0f
Bump rubocop from 1.63.5 to 1.64.0
dependabot[bot] May 24, 2024
8d0a554
Rubocop fixes
rsmithlal May 25, 2024
5e5eb34
Update rubyonrails.yml
rsmithlal May 25, 2024
473ad63
Allow for easy integration with host app error reporting systems
rsmithlal May 25, 2024
1aecfc2
Disable app-wrapping exception handler to get data into Sentry
rsmithlal May 25, 2024
2b37832
Update GitHub Config
rsmithlal May 25, 2024
c1a84ac
Rename docker compose image and paths
rsmithlal May 25, 2024
e7ff9fe
Specify ruby version for GitHub CI
rsmithlal May 25, 2024
113eb25
Revert "Disable app-wrapping exception handler to get data into Sentry"
rsmithlal May 26, 2024
938914d
Bump faker from 3.3.1 to 3.4.1
dependabot[bot] May 29, 2024
6bfbcf7
Bump pundit-resources from `16b9030` to `b6218c6`
dependabot[bot] May 27, 2024
4485e46
Bump rubocop from 1.64.0 to 1.64.1
dependabot[bot] May 31, 2024
cc9f74a
Add es module shim
rsmithlal Jun 3, 2024
03ace39
Set Community Engine hero background via Rails asset helpers
rsmithlal Jun 8, 2024
2eced17
improved community engine info page
rsmithlal Jun 8, 2024
48c0431
Fix app-breaking javascript re: stimulus-loading
rsmithlal Jun 8, 2024
b82ee1f
rubocop fix
rsmithlal Jun 8, 2024
fc6de83
update rails to 7.0.8.3
rsmithlal Jun 8, 2024
c3e07e0
Bump sprockets-rails from 3.4.2 to 3.5.1
dependabot[bot] Jun 8, 2024
0c85708
attempt to address issue double-loading js controllers
rsmithlal Jun 8, 2024
d5da7f1
Fix: Refactor app js to reduce unnecessary complexity
rsmithlal Jun 8, 2024
3faba9b
Fix loading of stimulus controllers
rsmithlal Jun 8, 2024
9e0fc68
Include stimulus controllers in manifest
rsmithlal Jun 8, 2024
f679c7f
Enable logging to try and identify production issue
rsmithlal Jun 9, 2024
cf26d04
fix: update how stimulus js files are loaded
rsmithlal Jun 9, 2024
35e484c
Migrate BT host app files and configuration to the Engine and dummy app.
rsmithlal Jun 9, 2024
1ab4de5
improvements to dummy app
rsmithlal Jun 9, 2024
2178f53
get trix editor working and assets loading reliably (in dev)
rsmithlal Jun 9, 2024
cebbfbb
Fix navigation to updated page after create and update actions
rsmithlal Jun 9, 2024
af0acd4
Correctly map local js imports
rsmithlal Jun 9, 2024
f2ebf88
Remove relative stimulus controller reference to hopefully use import…
rsmithlal Jun 9, 2024
60b44f5
Address rubocop and brakeman issues
rsmithlal Jun 10, 2024
6a6ec45
Address rubocop style guide
rsmithlal Jun 10, 2024
802b15c
Update version to 0.4.0
rsmithlal Jun 10, 2024
8004c34
Fix pages safe redirect url
rsmithlal Jun 11, 2024
1a73c65
alllow setting default url protocol
rsmithlal Jun 11, 2024
81f31eb
Ensure trix attachments use request url options for blobs
rsmithlal Jun 11, 2024
2952e06
Use trix editor stimulus controller
rsmithlal Jun 11, 2024
5b8dc94
Adjust blob url again
rsmithlal Jun 11, 2024
22fdd1b
rubocop fixes
rsmithlal Jun 11, 2024
7504ef4
Update version to v0.4.1
rsmithlal Jun 11, 2024
96ae65a
Update gem version in lockfile
rsmithlal Jun 11, 2024
e64811d
Bump aws-sdk-s3 from 1.152.0 to 1.152.1
dependabot[bot] Jun 11, 2024
cf01433
Bump rails from 7.0.8.3 to 7.1.3.4
dependabot[bot] Jun 8, 2024
7b79ce9
fix running specs with rails 7.1.3.4
rsmithlal Jun 8, 2024
d1ce315
Update gemfile confirming compatibility with rails 7.1
rsmithlal Jun 11, 2024
a733d75
Bump aws-sdk-s3 from 1.152.1 to 1.152.3
dependabot[bot] Jun 14, 2024
5e0d1d4
Bump rubocop-rspec from 2.31.0 to 3.0.1
dependabot[bot] Jun 12, 2024
763e2b3
Add encrypted credentials to dummy
rsmithlal Jun 16, 2024
67e648c
Add initial docs for community engine envs
rsmithlal Jun 16, 2024
4c34850
WIP: expand production deployment docs
rsmithlal Jun 16, 2024
746d18d
Ensure that engine runs turnkey in dev without any configuration
rsmithlal Jun 17, 2024
119ec34
Adjust dev setup in readme and docs
rsmithlal Jun 17, 2024
95d6bc3
Clean up unused files
rsmithlal Jun 17, 2024
03775e0
Create CODE_OF_CONDUCT.md
rsmithlal Jun 17, 2024
c1fd295
Create SECURITY.md
rsmithlal Jun 17, 2024
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 .dokku/predeploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
bundle install
bundle exec rails db:migrate
28 changes: 28 additions & 0 deletions .dokku/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Exit immediately if a command exits with a non-zero status.
set -e

# Ensure Sentry CLI is installed
if ! command -v sentry-cli &> /dev/null
then
echo "sentry-cli could not be found, please install it."
exit 1
fi

# Set the release version
RELEASE_VERSION=$(git rev-parse --short HEAD)

# Export the release version as an environment variable
export SENTRY_RELEASE=$RELEASE_VERSION

# Notify Sentry of the new release
sentry-cli releases new $SENTRY_RELEASE
sentry-cli releases finalize $SENTRY_RELEASE

echo "Sentry release $SENTRY_RELEASE has been set."

# Run any pending migrations (if needed)
bundle exec rails db:migrate

echo "Release step completed."
6 changes: 6 additions & 0 deletions .dokku/web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# release.sh
#!/bin/bash
set -e

mkdir -p spec/dummy/tmp/pids
bash -c "rm -f spec/dummy/tmp/pids/server.pid && cd ./spec/dummy && bundle exec puma -C config/puma.rb"
2 changes: 2 additions & 0 deletions .env.db.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
15 changes: 15 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copy this file to `.env.dev` `cp ./.env.sample ./.env.dev`
#

# App URLS
ALLOWED_HOSTS='http://localhost:3000'
APP_HOST='http://localhost:3000'
BASE_URL='http://localhost:3000'

REDIS_URL='redis://community-engine-redis:6379'

# Mail config
SMTP_PASSWORD=
SMTP_USERNAME='apikey'
SMTP_address='smtp.sendgrid.net'
35 changes: 35 additions & 0 deletions .env.prod.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ALLOWED_HOSTS=yourdomain.com
APP_HOST=yourdomain.com
BASE_URL=yourdomain.com

DATABASE_URL=your-postgres-connection-string
REDIS_URL=your-redis-connection-string

ASSET_HOST=cdn-assets.yourdomain.com
FOG_HOST=cdn-assets.yourdomain.com

AWS_ACCESS_KEY_ID=your-aws-key-id
AWS_SECRET_ACCESS_KEY=your-aws-secret-access-key

CDN_DISTRIBUTION_ID=your-cdn-distribution-id

S3_BUCKET_NAME=your-s3-bucket-name
FOG_DIRECTORY=your-s3-bucket-name

S3_REGION=your-s3-region
FOG_REGION=your-s3-region

LANG='en_US.UTF-8'
PORT=5000

RACK_ENV=production
RAILS_ENV=production
RAILS_LOG_LEVEL=debug
RAILS_LOG_TO_STDOUT=true
RAILS_SERVE_STATIC_FILES=true

SENTRY_DSN=your-sentry-dsn-url

SMTP_ADDRESS=your-smtp-address
SMTP_PASSWORD=your-smtp-password
SMTP_USERNAME=your-smtp-username
38 changes: 15 additions & 23 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:
pull_request:
branches: [ "main" ]
jobs:
test:
rspec:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11-alpine
image: postgis/postgis:latest
ports:
- "5432:5432"
env:
Expand All @@ -40,7 +40,19 @@ jobs:
- name: Run tests
run: rm -f spec/dummy/tmp/pids/server.pid && bundle exec rspec

lint:
rubocop:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
with:
bundler-cache: true
- name: Lint Ruby files with Rubocop
run: bundle exec rubocop --parallel

security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -55,23 +67,3 @@ jobs:
run: bundle exec bundler-audit --update
- name: Security audit application code
run: bundle exec brakeman -q -w2
- name: Lint Ruby files
run: bundle exec rubocop --parallel


# lint:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install Ruby and gems
# uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
# with:
# bundler-cache: true
# # Add or replace any other lints here
# - name: Security audit dependencies
# run: bin/bundler-audit --update
# - name: Security audit application code
# run: bin/brakeman -q -w2
# - name: Lint Ruby files
# run: bin/rubocop --parallel
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ node_modules/

spec/dummy/storage/og/9g/og9gmixuxfbx1sl5rgk6brbjmvms
spec/dummy/storage/va/ri/variants/og9gmixuxfbx1sl5rgk6brbjmvms/6e7b83b26e6f33c216f6d559f3b939a455b14b656f2fc1797c3cfcef371301b5
spec/dummy/storage/*
spec/dummy/storage/*

.env.prod
spec/dummy/config/master.key
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
91 changes: 79 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,87 @@
# This Dockerfile is only used for the production deployment using dokku.
# When pushed to dokku via git, it detects this Dockerfile and automatically chooses Docker build

FROM ruby:3.2
# Stage 1: Build environment
FROM ruby:3.2.2 AS builder

# Define build-time variables
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG FOG_DIRECTORY
ARG FOG_HOST
ARG FOG_REGION
ARG ASSET_HOST
ARG CDN_DISTRIBUTION_ID

# Set environment variables for asset precompilation
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV FOG_DIRECTORY=${FOG_DIRECTORY}
ENV FOG_HOST=${FOG_HOST}
ENV FOG_REGION=${FOG_REGION}
ENV ASSET_HOST=${ASSET_HOST}
ENV CDN_DISTRIBUTION_ID=${CDN_DISTRIBUTION_ID}

# Install dependencies
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
build-essential \
postgresql-client \
libpq-dev \
nodejs \
libssl-dev \
apt-transport-https \
ca-certificates \
libvips42 \
curl

# Set working directory
WORKDIR /community-engine

# Copy Gemfile and Gemfile.lock
COPY Gemfile Gemfile.lock better_together.gemspec ./

COPY lib lib

# Install bundler and gems
RUN gem uninstall bundler \
&& gem install bundler:2.4.13 \
&& bundle install --jobs 4 --retry 3

# Copy the rest of the application code
COPY . .

# Precompile assets and sync to S3
RUN bundle exec rake app:assets:precompile
RUN bundle exec rake app:assets:sync

# Stage 2: Runtime environment
FROM ruby:3.2.2

# Install runtime dependencies
RUN apt-get update -qq \
&& apt-get install -y build-essential postgresql-client libpq-dev nodejs libssl-dev apt-transport-https ca-certificates libvips42
&& apt-get install -y --no-install-recommends \
libpq-dev \
nodejs \
libssl-dev \
libvips42 \
curl \
&& curl -sL https://sentry.io/get-cli/ | bash \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# Set working directory
WORKDIR /community-engine

RUN apt-get update -qq && apt-get install -y yarn
# Copy the application code from the build stage
COPY --from=builder /community-engine /community-engine

RUN mkdir /btc
WORKDIR /btc
COPY Gemfile /btc/Gemfile
COPY Gemfile.lock /btc/Gemfile.lock
# Create and set permissions for spec/dummy/tmp/pids directory
RUN mkdir -p spec/dummy/tmp/pids
RUN chmod -R 755 spec/dummy/tmp

RUN gem uninstall bundler
RUN gem install bundler:2.4.13
# Set environment variables
ENV RAILS_ENV=production
ENV RACK_ENV=production

COPY . /btc
# Run the application
CMD ["./spec/dummy","bundle", "exec", "puma", "-C", "config/puma.rb"]
Loading