From c52a6ebd945711f8a831c37abde3b5ee52adb85b Mon Sep 17 00:00:00 2001 From: adrian peralta Date: Thu, 8 Aug 2024 23:12:00 +0000 Subject: [PATCH] config: #6 update github test workflow --- .github/workflows/test.yml | 34 ++++++++++++++++++++++++++++++++-- README.md | 5 +++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 799f7e6..897f759 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,22 @@ jobs: backend: name: 'Rails API Tests' runs-on: ubuntu-latest + + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres_user + POSTGRES_PASSWORD: testpassword + POSTGRES_DB: monitoring_sys_test + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - name: Checkout code uses: actions/checkout@v4 @@ -18,12 +34,26 @@ jobs: - name: Install dependencies run: | cd backend + gem install bundler bundle install - - name: Run Rails tests + - name: Set up environment variables + run: | + echo "DATABASE_HOST=localhost" >> $GITHUB_ENV + echo "DATABASE_USER=postgres_user" >> $GITHUB_ENV + echo "DATABASE_PASSWORD=testpassword" >> $GITHUB_ENV + + - name: Set up database + run: | + cd backend + RAILS_ENV=test rails db:create + RAILS_ENV=test rails db:migrate + RAILS_ENV=test rails db:seed + + - name: Run RSpec tests run: | cd backend - bundle exec rspec + RAILS_ENV=test bundle exec rspec frontend: name: 'Vue Frontend Tests' diff --git a/README.md b/README.md index df56d70..5ea8d39 100644 --- a/README.md +++ b/README.md @@ -77,12 +77,13 @@ - abrir command palette: ctrl + shift + p - Seleccionar: Reopen in container - Seleccionar: "Rails API Container" - - Dentro ejecutar: `rails s` + - Dentro ejecutar: `rails s -b 0.0.0.0` - Ejecutar el contenedor Vue Container: - abrir command palette: ctrl + shift + p - Seleccionar: Reopen in container - Seleccionar: "Vue Container" - - Dentro ejecutar: `yarn dev` + - Dentro ejecutar mocked: `yarn dev` + - Dentro ejecutar api: `yarn serve:api` - navegar a 0.0.0.0:8080 para empezar a usar la app - Ejecutar tests e2e: ```bash