-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch CI build process to use docker
This also ensures that assets can be built properly so that UI tests pass.
- Loading branch information
1 parent
076ba6f
commit 20582bd
Showing
8 changed files
with
76 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,72 +3,26 @@ name: Ruby | |
on: [push] | ||
|
||
jobs: | ||
docker_build: | ||
name: Build Dockerfile | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Build the Dockerfile | ||
run: docker build -t app . | ||
build: | ||
name: The Build | ||
name: Build and test | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
redis: | ||
image: redis:4 | ||
ports: | ||
- 6379:6379 | ||
postgres: | ||
image: postgres:10 | ||
env: | ||
POSTGRES_DB: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USER: postgres | ||
ports: ["5432:5432"] | ||
# needed because the postgres container does not provide a healthcheck | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/checkout@v3 | ||
- name: Copy .env file | ||
uses: canastro/copy-file-action@master | ||
with: | ||
source: "env.example" | ||
target: ".env" | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- name: Build the Stack | ||
run: "docker compose build" | ||
|
||
- name: Show available Ruby versions | ||
run: | | ||
ls $RUNNER_TOOL_CACHE/Ruby | ||
uname -a | ||
cat /etc/os-release | ||
- name: Start dependencies | ||
run: "docker compose up -d --no-deps db redis app" | ||
|
||
- name: Install required packages | ||
run: sudo apt-get install libpq-dev | ||
- name: Run all tests | ||
run: "docker compose exec app ./ci.sh" | ||
|
||
- name: Test | ||
run: | | ||
RAILS_ENV=test bundle exec rails db:create | ||
RAILS_ENV=test bundle exec rails db:schema:load | ||
bundle exec rake | ||
env: | ||
#Note: DATABASE_URL does not work in TEST env. | ||
TEST_DB_HOST: localhost | ||
TEST_DB_USERNAME: postgres | ||
TEST_DB_PASSWORD: postgres | ||
TEST_DB_NAME: postgres | ||
discourse_sso_secret: "secret" | ||
discourse_endpoint: "https://example.com" | ||
PG_PORT: ${{ job.services.postgres.ports['5432'] }} | ||
- name: Teardown the stack | ||
run: "docker compose down" | ||
|
||
#- name: Deploy to server via SSH | ||
#uses: appleboy/ssh-action@master | ||
#with: | ||
#host: ${{ secrets.HOST }} | ||
#key: ${{ secrets.KEY }} | ||
#port: ${{ secrets.PORT }} | ||
#username: ${{ secrets.USERNAME }} | ||
#script: | | ||
#cd smartcitizen-api | ||
#pwd | ||
#./scripts/deploy.sh | ||
#if: github.ref == 'refs/heads/master' && job.status == 'success' |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -ae | ||
git config --global --add safe.directory /app | ||
source $NVM_DIR/nvm.sh | ||
nvm use default | ||
yarn install | ||
NODE_OPTIONS=--openssl-legacy-provider bundle exec bin/rake assets:precompile | ||
bundle exec bin/rake db:create | ||
bundle exec bin/rake db:schema:load | ||
unset DATABASE_URL | ||
RAILS_ENV=test bundle exec bin/rake db:create | ||
RAILS_ENV=test bundle exec bin/rake db:schema:load | ||
bundle exec bin/rake spec |
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
services: | ||
app: | ||
build: | ||
args: !reset [] | ||
restart: "no" | ||
sidekiq: | ||
restart: "no" | ||
|
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3.3' | ||
services: | ||
app: | ||
build: | ||
args: | ||
- BUNDLE_WITHOUT=test development | ||
mqtt: | ||
entrypoint: ["echo", "MQTT service disabled in production"] | ||
cassandra-1: | ||
entrypoint: ["echo", "Cassandra service disabled in production"] | ||
kairos: | ||
depends_on: !reset [] |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
services: | ||
db: | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 2gb | ||
app: | ||
build: | ||
args: | ||
- BUNDLE_WITHOUT=test development | ||
mqtt: | ||
entrypoint: ["echo", "MQTT service disabled on staging"] | ||
mqtt-task-main-1: | ||
environment: | ||
MQTT_CLIENT_ID: smartcitizen-staging-api-main-1 | ||
mqtt-task-main-2: | ||
environment: | ||
MQTT_CLIENT_ID: smartcitizen-staging-api-main-2 | ||
mqtt-task-secondary: | ||
environment: | ||
MQTT_CLIENT_ID: "smartcitizen-staging-api-secondary" | ||
|
||
|
||
# cassandra-1: | ||
# entrypoint: ["echo", "Cassandra service disabled on staging"] | ||
# kairos: | ||
# depends_on: !reset [] |
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