Skip to content

Commit

Permalink
Merge branch 'feature_project_setup' into TAN-417-allow-open-ended-ph…
Browse files Browse the repository at this point in the history
…ases
  • Loading branch information
EdwinKato committed Oct 23, 2023
2 parents 48077a0 + f733e63 commit 541a41b
Show file tree
Hide file tree
Showing 386 changed files with 83,894 additions and 5,116 deletions.
52 changes: 42 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ slack-fail-post-step-inconsistent-data: &slack-fail-post-step-inconsistent-data
mentions: ":boom: FAILURE: Some data is likely invalid."
template: basic_fail_1

install-front-dependencies: &install-front-dependencies
- run:
name: Install front dependencies
command: |
# Install jq using apt-get (for Debian-based images)
apt-get update
apt-get install -y jq
cd ~/citizenlab/front
CL2_VERSION=$(cat ../cl2-component-library/package.json | jq -r .version)
npm ci
npm i --save @citizenlab/cl2-component-library@${CL2_VERSION}
parameters:
# This parameter is used to trigger the main workflow
trigger:
Expand Down Expand Up @@ -392,7 +405,7 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "package-lock.json" }}
- run: npm ci
- <<: *install-front-dependencies
- save_cache:
paths:
- /root/.npm
Expand All @@ -409,7 +422,7 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "package-lock.json" }}
- run: npm ci
- <<: *install-front-dependencies
- save_cache:
paths:
- /root/.npm
Expand All @@ -426,7 +439,7 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "package-lock.json" }}
- run: npm ci
- <<: *install-front-dependencies
- save_cache:
paths:
- /root/.npm
Expand All @@ -443,8 +456,27 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "package-lock.json" }}
- run: npm ci
- run: /bin/bash -lc "cd ~/citizenlab/front && license_finder"
- run:
name: Install jq
command: |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
apt-get update
apt-get install -y jq
- run:
name: Install node, dependencies and run license_finder
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.nvm/nvm.sh
nvm install 16.15.0
nvm use 16.15.0
CL2_VERSION=$(cat ../cl2-component-library/package.json | jq -r .version)
npm i --save @citizenlab/cl2-component-library@${CL2_VERSION}
npm ci
/bin/bash -lc "cd ~/citizenlab/front && license_finder"
- save_cache:
paths:
- /root/.npm
key: v2-npm-cache-{{ checksum "package-lock.json" }}

front-build:
docker:
Expand All @@ -457,7 +489,7 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "package-lock.json" }}
- run: npm ci
- <<: *install-front-dependencies
- save_cache:
paths:
- /root/.npm
Expand All @@ -476,7 +508,7 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "package-lock.json" }}
- run: npm ci
- <<: *install-front-dependencies
- save_cache:
paths:
- /root/.npm
Expand Down Expand Up @@ -515,7 +547,7 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "citizenlab/front/package-lock.json" }}
- run: cd citizenlab/front && npm ci
- <<: *install-front-dependencies
- save_cache:
paths:
- /root/.npm
Expand Down Expand Up @@ -566,7 +598,7 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "package-lock.json" }}
- run: npm ci
- <<: *install-front-dependencies
- save_cache:
paths:
- /root/.npm
Expand All @@ -592,7 +624,7 @@ jobs:
- restore_cache:
keys:
- v2-npm-cache-{{ checksum "package-lock.json" }}
- run: npm ci
- <<: *install-front-dependencies
- save_cache:
paths:
- /root/.npm
Expand Down
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ updates:
- "adessy"
reviewers:
- "adessy"
- package-ecosystem: npm
directory: '/cl2-component-library'
schedule:
interval: monthly
time: '04:00'
open-pull-requests-limit: 10
assignees:
- 'IvaKop'
reviewers:
- 'IvaKop'
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI
on:
push:
paths: ['cl2-component-library/src/**']# Trigger the action only when files change in the folders defined here
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Begin CI...
uses: actions/checkout@v3

- name: Use Node 16
uses: actions/setup-node@v3
with:
node-version: 16.15.0

- name: Use cached node_modules
uses: actions/cache@v3
with:
path: cl2-component-library/node_modules
key: nodeModules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
nodeModules-
- name: Install dependencies
run: cd cl2-component-library && npm ci
env:
CI: true

- name: Lint
run: cd cl2-component-library && npm run lint
env:
CI: true

- name: Test
run: cd cl2-component-library && npm run test --ci --coverage --maxWorkers=2
env:
CI: true

- name: Build
run: cd cl2-component-library && npm run build
env:
CI: true
34 changes: 34 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Deploy Storybook
on:
push:
branches:
- master
paths: ['cl2-component-library/src/**'] # Trigger the action only when files change in the folders defined here
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Use Node 16
uses: actions/setup-node@v3
with:
node-version: 16.15.0

- name: Install and Build 🔧
run: | # Install npm packages and build the Storybook files
cd cl2-component-library
npm ci
npm run build-storybook
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GB_TOKEN }}
# Test branch
BRANCH: cl2-component-library-storybook # The branch the action should deploy to.
FOLDER: cl2-component-library/docs-build # The folder that the build-storybook script generates files.
CLEAN: true # Automatically remove deleted files from the deploy branch
TARGET_FOLDER: docs # The folder that we serve our Storybook files from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

build:
docker-compose build
cd front && npm install
npm run install:all

reset-dev-env:
# -v removes volumes with all the data inside https://docs.docker.com/compose/reference/down/
Expand Down
8 changes: 8 additions & 0 deletions back/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install Postgres client:
# Import the PostgreSQL repository signing key, add the repository, and install the package.
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --yes --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
# Make sure the version of `postgresql-client` matches the version used by the
# `postgres` service in `docker-compose.yml`.
&& apt-get update && apt-get install -y postgresql-client-12

WORKDIR /cl2_back

RUN gem install bundler:2.4.20
Expand Down
25 changes: 23 additions & 2 deletions back/Dockerfile.development
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
FROM ruby:2.7.6-slim

RUN apt-get update && apt-get install -qq -y --no-install-recommends \
build-essential libpq-dev file imagemagick curl git optipng jpegoptim pngquant libgeos-dev libgmp3-dev netcat shared-mime-info \
less clang
build-essential \
libpq-dev \
file \
imagemagick \
curl \
git \
optipng \
jpegoptim \
pngquant \
libgeos-dev \
libgmp3-dev \
netcat \
shared-mime-info \
less \
clang

RUN curl -sL https://deb.nodesource.com/setup_15.x | bash -
RUN apt-get -y install nodejs

# Install MJML parser required by email engine.
RUN npm install -g [email protected]

# Install Postgres client:
# Import the PostgreSQL repository signing key, add the repository, and install the package.
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --yes --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
# Make sure the version of `postgresql-client` matches the version used by the
# `postgres` service in `docker-compose.yml`.
&& apt-get update && apt-get install -y postgresql-client-12

ENV INSTALL_PATH /cl2_back
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
Expand Down
4 changes: 2 additions & 2 deletions back/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ GEM
bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
bunny (2.20.3)
bunny (2.22.0)
amq-protocol (~> 2.3, >= 2.3.1)
sorted_set (~> 1, >= 1.0.2)
byebug (11.1.3)
Expand Down Expand Up @@ -1079,7 +1079,7 @@ GEM
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.1)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-performance (1.18.0)
rubocop (>= 1.7.0, < 2.0)
Expand Down
18 changes: 18 additions & 0 deletions back/app/controllers/web_api/v1/location_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class WebApi::V1::LocationController < ApplicationController
skip_before_action :authenticate_user
skip_after_action :verify_authorized

def autocomplete
render json: raw_json(Location::Service.new.autocomplete(params[:input], params[:language]))
end

def geocode
render json: raw_json(Location::Service.new.geocode(params[:address], params[:language]))
end

def reverse_geocode
render json: raw_json(Location::Service.new.reverse_geocode(params[:lat], params[:lng], params[:language]))
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def project
end

def participation_context
@participation_context ||= ParticipationContextService.new.get_participation_context project
@participation_context ||= ParticipationContextService.new.get_participation_context(project) || project
end

def input_term
Expand Down
4 changes: 3 additions & 1 deletion back/app/jobs/delete_user_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class DeleteUserJob < ApplicationJob
# @param [User,NilClass] current_user
def run(user, current_user = nil)
user = User.find(user) unless user.respond_to?(:id)
service = SideFxUserService.new
service.before_destroy(user, current_user)
user.destroy!
SideFxUserService.new.after_destroy(user, current_user)
service.after_destroy(user, current_user)
end
end
10 changes: 5 additions & 5 deletions back/app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#
# Indexes
#
# index_activities_on_acted_at (acted_at)
# index_activities_on_action (action)
# index_activities_on_item (item_type,item_id)
# index_activities_on_project_id (project_id)
# index_activities_on_user_id (user_id)
# index_activities_on_acted_at (acted_at)
# index_activities_on_action (action)
# index_activities_on_item_type_and_item_id (item_type,item_id)
# index_activities_on_project_id (project_id)
# index_activities_on_user_id (user_id)
#
# Foreign Keys
#
Expand Down
2 changes: 2 additions & 0 deletions back/app/models/events/attendance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#
# index_events_attendances_on_attendee_id (attendee_id)
# index_events_attendances_on_attendee_id_and_event_id (attendee_id,event_id) UNIQUE
# index_events_attendances_on_created_at (created_at)
# index_events_attendances_on_event_id (event_id)
# index_events_attendances_on_updated_at (updated_at)
#
# Foreign Keys
#
Expand Down
1 change: 1 addition & 0 deletions back/app/models/initiative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class Initiative < ApplicationRecord
scope :feedback_needed, -> { with_status_code('threshold_reached') }
scope :no_feedback_needed, -> { with_status_code(InitiativeStatus::CODES - ['threshold_reached']) }
scope :proposed, -> { with_status_code('proposed') }
scope :voteable_status, -> { with_status_code(InitiativeStatus::REVIEW_CODES + ['proposed']) }

scope :proposed_before, (proc do |time|
with_proposed_status_changes.where('initiative_status_changes.created_at < ?', time)
Expand Down
2 changes: 0 additions & 2 deletions back/app/models/pin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ class Pin < ApplicationRecord
belongs_to :admin_publication, inverse_of: :pins
belongs_to :page, polymorphic: true, inverse_of: :pins

# rubocop:disable Rails/UniqueValidationWithoutIndex
# There is a unique composite index on page_id, admin_publication_id which covers this column
# See https://github.com/rubocop/rubocop-rails/issues/231
validates :admin_publication, presence: true, uniqueness: { scope: :page }
# rubocop:enable Rails/UniqueValidationWithoutIndex
validates :page, presence: true

validate :max_three_pins_per_page
Expand Down
Loading

0 comments on commit 541a41b

Please sign in to comment.