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

GitHub Action CI/CD test #700

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
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
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci

on:
workflow_dispatch:
pull_request:

jobs:
ci:
name: Build and run tests with containers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true

- name: Build Docker images
run: |
docker-compose build

- name: Run with Docker Compose
run: docker-compose up -d

- name: Run tests
run: |
docker exec -e RAILS_ENV=test gala_web_1 bash -c "bundle exec rails db:test:prepare && \
bundle exec rspec --exclude-pattern=\"**/features/*_spec.rb\""

- name: Docker Compose down
run: docker-compose down

- if: always()
uses: ouzi-dev/commit-status-updater@v1.1.0
with:
name: Test
status: "${{ job.status }}"
21 changes: 21 additions & 0 deletions .github/workflows/run_tests.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run tests
on:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build docker containers and run tests
run: |
docker compose run -e RAILS_ENV=test web bundle exec rspec --exclude-pattern="**/features/*_spec.rb"

- if: always()
name: Commit status
uses: ouzi-dev/commit-status-updater@v1.1.0
with:
name: "Run tests"
status: "${{ job.status }}"
17 changes: 5 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '3'
version: '3.8'
services:
web: &web
build: ./
build:
context: ./
image: gala_web:latest
stdin_open: true
tty: true
command: foreman start -f Procfile.dev
Expand All @@ -21,7 +23,7 @@ services:
- /app/tmp/cache/
worker:
<<: *web
image: gala_web
image: gala_web:latest
command: bundle exec sidekiq
environment:
<<: *env
Expand All @@ -41,14 +43,5 @@ services:
image: redis:6
ports:
- 6379:6379
# selenium:
# image: seleniarm/standalone-chromium
# shm_size: 4gb
# environment:
# SE_NODE_MAX_SESSIONS: 1
# ports:
# - 4444:4444
# volumes:
# - /dev/shm:/dev/shm
volumes:
db_data:
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if [ "$RAILS_ENV" = "development" ] && [ -z "$SIDEKIQ_CONCURRENCY" ]; then
if [[ "$RAILS_ENV" == "development" || "$RAILS_ENV" == "test" ]] && [[ -z "$SIDEKIQ_CONCURRENCY" ]]; then
count=$(bundle exec rails runner "puts Case.count")
if [ "${count//$'\n'/}" -eq 0 ]; then
bundle exec rails db:environment:set RAILS_ENV=development
Expand Down
Loading