diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..d782030 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,64 @@ +--- +name: Unit Tests + +on: + push: + branches: + - main + - development + pull_request: + branches: + - main + - development + +jobs: + rspec: + name: Unit Tests with RSepc + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + env: + RAILS_ENV: development + RAILS_MAX_THREADS: 2 + WEB_CONCURRENCY: 2 + PGPASSFILE: /app/.pgpass + POSTGRES_PASSWORD: ephermeral_exists_during_tests + POSTGRES_USER: admin + POSTGRES_DB: blackpearl + POSTGRES_PORT: '5432' + POSTGRES_MAX_CONNECTIONS: '30' + POSTGRES_RANDOM_PAGE_COST: '1.1' + POSTGRES_EFFECTIVE_IO_CONCURRENCY: '30' + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: admin + POSTGRES_PASSWORD: ephermeral_exists_during_tests + POSTGRES_DB: blackpearl + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 3 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Dependences + run: | + sudo apt-get update -y + sudo apt-get install -y libpq-dev postgresql-client build-essential libssl-dev + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0.0 + + - name: Bundle Install + run: bundle install + + - name: Database Setup + run: bundle exec rails db:migrate + + - name: Run RSpec + run: bundle exec rspec