Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set environment up
run: |
docker compose pull
docker compose up -d db
docker compose run --rm --no-deps web bundle
docker compose run --rm --no-deps web rake db:setup
docker compose run --rm --no-deps web rake db:test:prepare

- name: Run specs
run: |
docker compose run --rm web bundle exec rspec spec

build:
needs: test
runs-on: ubuntu-22.04
env:
DOCKER_REPOSITORY: 'instedd/pollit'
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
steps:
- uses: actions/checkout@v3
- name: Build image & push to Docker Hub
run: ./build.sh
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM ruby:2.3

# Cleanup expired Let's Encrypt CA (Sept 30, 2021)
RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f

RUN echo 'deb http://archive.debian.org/debian stretch main\n\
deb http://archive.debian.org/debian-security stretch/updates main' > /etc/apt/sources.list

RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs && \
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM ruby:2.3

# Cleanup expired Let's Encrypt CA (Sept 30, 2021)
RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f

RUN echo 'deb http://archive.debian.org/debian stretch main\n\
deb http://archive.debian.org/debian-security stretch/updates main' > /etc/apt/sources.list

RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs && \
Expand Down
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,14 @@ Development
Docker development
------------------

`docker-compose.yml` file build a development environment mounting the current folder and running rails in development environment.
`docker-compose.yml` file builds a development environment mounting the current folder and running rails in development environment.

Run the following commands to have a stable development environment.
To have a stable development environment, simply run `./dev-setup`.

```
$ docker-compose run --rm --no-deps web bundle install
$ docker-compose up -d db
$ docker-compose run --rm web rake db:setup
$ docker-compose up
```

To setup and run test, once the web container is running:
To run the test suite, once the web container is running (`docker compose up -d web`) run:

```
$ docker-compose exec web bash
root@web_1 $ rake
docker compose exec web rake
```

API
Expand Down Expand Up @@ -203,4 +195,4 @@ Pollit will forward any conversation with a logged user identifying them through

If you don't want to use Intercom, you can simply omit `INTERCOM_APP_ID` or set it to ''.

To test the feature in development, add the `INTERCOM_APP_ID` variable and its value to the `environment` object inside the `web` service in `docker-compose.yml`.
To test the feature in development, add the `INTERCOM_APP_ID` variable and its value to the `environment` object inside the `web` service in `docker-compose.yml`.
15 changes: 15 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -eo pipefail

# This will load the script from this repository. Make sure to point to a specific commit so the build continues to work
# event if breaking changes are introduced in this repository
source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/manastech/ci-docker-builder/055890240f6cfd633839bb32f8d4deef83214aed/build.sh)"

# Prepare the build
dockerSetup

# Write a VERSION file for the footer
echo $VERSION > VERSION

# Build and push the Docker image
dockerBuildAndPush
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

scope "(:locale)", :locale => /#{Locales.available.keys.join('|')}/ do

devise_for :users, :controllers => {
devise_for :users, :skip => [ ( :registrations if Guisso.enabled? ) ], :controllers => {
:registrations => 'users/registrations',
omniauth_callbacks: "omniauth_callbacks",
sessions: "sessions"
Expand Down
6 changes: 6 additions & 0 deletions dev-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e
docker compose pull
docker compose build
docker compose run --rm --no-deps web bundle install
docker compose up -d --wait db
docker compose run --rm web rake db:setup
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: '2.0'
services:
db:
image: mysql:5.6
platform: linux/amd64
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
Expand All @@ -12,6 +13,7 @@ services:
build:
context: .
dockerfile: Dockerfile.dev
platform: linux/amd64
working_dir: /app
environment:
RAILS_ENV:
Expand Down
8 changes: 0 additions & 8 deletions travis-build.sh

This file was deleted.