commit psql 16 changes to schema #1031
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: RSpec & JS Tests | |
on: [push] | |
jobs: | |
tests: | |
name: Tests | |
runs-on: ubuntu-latest | |
env: | |
RAILS_ENV: test | |
POSTGRES_USER: nemo | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_HOST: localhost | |
services: | |
postgres: | |
image: postgres:11 | |
# These env vars need to be repeated here b/c they get passed as command line args to docker | |
env: | |
POSTGRES_USER: nemo | |
POSTGRES_DB: nemo_test | |
POSTGRES_PASSWORD: postgres | |
ports: ["5432:5432"] | |
# These health checks are important to ensure Postgres is ready before moving on. | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
- name: Ruby gem cache | |
id: cache-gems | |
uses: actions/cache@v2 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-v2-${{ hashFiles('**/Gemfile.lock') }} | |
# Restore keys will be matched if the main key fails. This may restore older gems to the | |
# dir but we don't care because bundle install will check the gems anyway. | |
restore-keys: | | |
${{ runner.os }}-gems-v2- | |
- name: Set bundle path | |
run: bundle config path vendor/bundle | |
- name: Install gems | |
run: bundle install --jobs 4 --retry 3 | |
- name: Setup Node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 20 | |
- name: Find yarn cache location | |
id: yarn-cache | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: JS package cache | |
id: cache-packages | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.yarn-cache.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install packages | |
run: | | |
yarn install --pure-lockfile | |
cd lib/enketo-transformer-service/ && yarn install --pure-lockfile | |
- name: Setup test database | |
run: | | |
cp config/database.yml.ci config/database.yml | |
bin/rails db:drop | |
bin/rails db:setup | |
bin/rails db:test:prepare | |
- name: Install Chromedriver | |
uses: nanasess/setup-chromedriver@master | |
- name: Configure Chromedriver | |
run: | | |
export DISPLAY=:99 | |
chromedriver --url-base=/wd/hub & | |
- name: Run all tests | |
# Run both in the same shell and return whether both of them passed by adding return values together. | |
# This way both run even if the first one fails, but if either fails, we still fail the build. | |
env: | |
# A real Google Maps key is needed for some specs. This is stored in the Github repo | |
# under Settings > Secrets. | |
NEMO_GOOGLE_MAPS_API_KEY: ${{ secrets.NEMO_GOOGLE_MAPS_API_KEY }} | |
shell: bash {0} | |
run: | | |
yarn run i18n:export | |
yarn run lint:react | |
LINT_RESULT=$? | |
yarn run test | |
JEST_RESULT=$? | |
bundle exec rspec --tag ~flapping --format RSpec::Github::Formatter --format documentation | |
RSPEC_RESULT=$? | |
bundle exec rspec --tag flapping --format RSpec::Github::Formatter --format documentation | |
RSPEC_FLAPPING_RESULT=$? | |
echo | |
echo "Final results:" | |
echo "LINT_RESULT: $LINT_RESULT" | |
echo "JEST_RESULT: $JEST_RESULT" | |
echo "RSPEC_RESULT: $RSPEC_RESULT" | |
echo "RSPEC_FLAPPING_RESULT: $RSPEC_FLAPPING_RESULT" | |
# Square each result to make sure they're all positive (and don't cancel each other out). | |
exit `expr $LINT_RESULT '*' $LINT_RESULT + $RSPEC_RESULT '*' $RSPEC_RESULT + $JEST_RESULT '*' $JEST_RESULT` |