Add elasticsearch github actions configuration #33
Workflow file for this run
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
name: CI | |
on: [push, pull_request] | |
jobs: | |
lint: | |
name: Linters | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'yarn' | |
node-version-file: '.node-version' | |
- name: Install Yarn packages | |
run: yarn install --check-files --pure-lockfile | |
- name: Lint files | |
run: bin/lint | |
scan: | |
name: Security Analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Scan code vulnerabilities | |
run: bin/scan | |
test: | |
name: Test | |
needs: | |
- lint | |
- scan | |
runs-on: ubuntu-latest | |
env: | |
ELASTICSEARCH_HOST: http://localhost:9200 | |
DATABASE_URL: postgres://postgres:example@localhost:5432/app_test | |
services: | |
postgres: | |
image: postgres:14.2 | |
ports: ['5432:5432'] | |
env: | |
POSTGRES_DB: app_test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: example | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Install postgres client | |
run: sudo apt-get install libpq-dev | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'yarn' | |
node-version-file: '.node-version' | |
- name: Install Yarn packages | |
run: yarn install --check-files --pure-lockfile | |
- name: Configure sysctl limits | |
run: | | |
sudo swapoff -a | |
sudo sysctl -w vm.swappiness=1 | |
sudo sysctl -w fs.file-max=262144 | |
sudo sysctl -w vm.max_map_count=262144 | |
- name: Runs Elasticsearch | |
uses: elastic/elastic-github-actions/elasticsearch@master | |
with: | |
stack-version: 8.10.2 | |
security-enabled: false | |
- name: Elasticsearch is reachable | |
run: | | |
curl --verbose --show-error --insecure http://localhost:9200 | |
- name: Create database structure | |
run: RAILS_ENV=test bundle exec rails db:create db:schema:load | |
- name: Run tests | |
run: bundle exec bin/rspec spec --format progress |