Skip to content

6239-rate-limiting-prep #17418

6239-rate-limiting-prep

6239-rate-limiting-prep #17418

Workflow file for this run

name: Rails Tests
on:
push:
branches:
- '*'
- '**/*'
# NOTE: you don't need to build all PRs if you are also building all branches
# pull_request:
# branches:
# - '*'
# - '**/*'
concurrency:
group: ${{ github.ref }}-tests
cancel-in-progress: true
jobs:
# Label of the container job
tests:
strategy:
fail-fast: false
matrix:
test_group:
- {id: 'ci_bucket_1', tag: 'ci_bucket:bucket-1'}
- {id: 'ci_bucket_2', tag: 'ci_bucket:bucket-2'}
- {id: 'ci_bucket_3', tag: 'ci_bucket:bucket-3'}
- {id: 'ci_bucket_4', tag: 'ci_bucket:bucket-4'}
- {id: 'ci_bucket_default', tag: '~ci_bucket', system_tests: true, logging_tests: true, okta_tests: true}
# Containers must run in Linux based operating systems
runs-on: ubuntu-20.04
# Docker Hub image that the job executes in
# $RUBY_VERSION
container: ruby:3.1.6-alpine3.20
# Service containers to run with job
services:
postgres:
image: postgis/postgis:12-3.1-alpine
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_PASS: postgres
POSTGRES_MULTIPLE_EXTENSIONS: postgis,hstore
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:alpine
ports:
- 6379:6379
hmis-warehouse-sftp:
image: ghcr.io/greenriver/openpath-sftp:1.0
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
ports:
- '2222:22'
minio:
image: ghcr.io/greenriver/openpath-minio:1.0
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
MINIO_ACCESS_KEY: local_access_key
MINIO_SECRET_KEY: local_secret_key
ports:
- '9000:9000'
chrome:
image: browserless/chrome:1-chrome-stable
ports:
- 3333:3333
env:
PORT: 3333
CONNECTION_TIMEOUT: 600000
env:
CLIENT: test
DATABASE_ADAPTER: postgresql
DATABASE_APP_DB_TEST: warehouse_app_test
DATABASE_DB_TEST: warehouse_test
DATABASE_APP_DB: warehouse_app_test
DATABASE_HOST: postgres
DATABASE_PASS: postgres
DATABASE_USER: postgres
DATABASE_WAREHOUSE_DB_TEST: warehouse_test
DEFAULT_FROM: greenriver.testing@mailinator.com
ENCRYPTION_KEY: strongEncryptionstrongEncryptionstrongEncryption
FQDN: openpath.host
HEALTH_DATABASE_ADAPTER: postgresql
HEALTH_DATABASE_DB_TEST: health_test
HEALTH_DATABASE_HOST: postgres
HEALTH_DATABASE_PASS: postgres
HEALTH_DATABASE_USER: postgres
HEALTH_FROM: greenriver.testing@mailinator.com
HOSTNAME: openpath.host
MINIO_ENDPOINT: http://minio:9000
USE_MINIO_ENDPOINT: true
PORT: 80
RAILS_ENV: test
REPORTING_DATABASE_ADAPTER: postgresql
REPORTING_DATABASE_DB_TEST: reporting_test
REPORTING_DATABASE_HOST: postgres
REPORTING_DATABASE_PASS: postgres
REPORTING_DATABASE_USER: postgres
WAREHOUSE_DATABASE_ADAPTER: postgis
WAREHOUSE_DATABASE_DB_TEST: warehouse_test
WAREHOUSE_DATABASE_HOST: postgres
WAREHOUSE_DATABASE_PASS: postgres
WAREHOUSE_DATABASE_USER: postgres
WAREHOUSE_DATABASE_DB: warehouse_test
HEALTH_DATABASE_DB: health_test
REPORTING_DATABASE_DB: reporting_test
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
PUPPETEER_EXECUTABLE_PATH: /usr/bin/chromium-browser
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up dependencies
run: |
apk add --no-cache $(cat .github/dependencies.txt)
echo "postgres:5432:*:postgres:postgres" > ~/.pgpass
chmod 600 ~/.pgpass
- name: cache gems
uses: actions/cache@v4
id: gemcache
with:
path: |
vendor/bundle
/usr/local/bundle/
key: ${{ runner.os }}-gemcache-${{ hashFiles('**/Gemfile.lock') }}-${{ hashFiles('**/.ruby-version') }}
- name: Install gems
run: |
gem install bundler --version=2.5.7
bundle config set --local without 'production staging development'
bundle install --jobs 4 --retry 3
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Node.js modules
run: yarn install --frozen-lockfile
- name: 'App setup'
run: |
cp config/secrets.yml.sample config/secrets.yml
mkdir app/assets/stylesheets/theme/styles
touch app/assets/stylesheets/theme/styles/_variables.scss
cp .rspec.sample .rspec
cp config/database.yml.ci config/database.yml
- name: Prepare test db
run: |
pg_isready -h postgres -U postgres
bin/db_prep
echo "Setting up .pgpass"
echo "postgres:*:*:postgres:postgres" > ~/.pgpass
chmod 600 ~/.pgpass
- name: Precompile assets
run: bundle exec rails assets:precompile
# fetch some closed source files
- name: 'Fetch testkit source files'
uses: keithweaver/aws-s3-github-action@v1.0.0
with:
command: cp
source: ${{ secrets.AWS_S3_ACTION_BUCKET }}${{ vars.AWS_S3_ACTIONS_SOURCE_PATH_FY_2024 }}
destination: ./drivers/datalab_testkit/spec/fixtures/inputs/
aws_access_key_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws_region: us-east-1
flags: --recursive
# fetch pre-processed FY2024 data set; note that we need to update this whenever the test kit source
# data changes. To update:
# 1. Remove the fixtures from `drivers/datalab_testkit/spec/fixpoints/`
# 2. Replace the source and result files in `drivers/datalab_testkit/spec/fixtures` and on S3
# 3. Re-run the tests rspec drivers/hud_apr/spec/models/fy2024/datalab_2_0_spec.rb
# 4. Update the fixpoint in S3 from the newly generated file
- name: 'Fetch testkit fixpoint files'
uses: keithweaver/aws-s3-github-action@v1.0.0
with:
command: cp
source: ${{ secrets.AWS_S3_ACTION_BUCKET }}${{ vars.AWS_S3_ACTIONS_FIXPOINT_PATH_FY_2024 }}
destination: ./drivers/datalab_testkit/spec/fixpoints/
aws_access_key_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws_region: us-east-1
flags: --recursive
- name: 'Fetch result files'
uses: keithweaver/aws-s3-github-action@v1.0.0
with:
command: cp
source: ${{ secrets.AWS_S3_ACTION_BUCKET }}${{ vars.AWS_S3_ACTIONS_RESULTS_PATH_FY_2024 }}
destination: ./drivers/datalab_testkit/spec/fixtures/results/
aws_access_key_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws_region: us-east-1
flags: --recursive
- name: 'Fetch 2022 -> 2024 source files'
uses: keithweaver/aws-s3-github-action@v1.0.0
with:
command: cp
source: ${{ secrets.AWS_S3_ACTION_BUCKET }}${{ vars.AWS_S3_ACTIONS_SOURCE_PATH_FY_2024 }}/merged/source
destination: ./drivers/hud_twenty_twenty_two_to_twenty_twenty_four/spec/fixtures/in/
aws_access_key_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws_region: us-east-1
flags: --recursive
# Regenerate the graphql schema and fail if it has changed
- name: 'Check HMIS GraphQL schema'
if: matrix.test_group.system_tests
run: |
bundle exec rake driver:hmis:dump_graphql_schema
- name: Run tests
if: matrix.test_group.tag
env:
AWS_ACCESS_KEY_ID: local_access_key
AWS_SECRET_ACCESS_KEY: local_secret_key
GROVER_NO_SANDBOX: true
CHROMIUM_PATH: /usr/bin/chromium-browser
MAX_FAILURES: 60
LOG_LEVEL: INFO
run: |
bundle exec rails ci:update_spec_tags[.github/rspec_buckets.json]
# capture rspec profiling information
# mkdir -p tmp/rspec_profiles
# bundle exec rspec --format json --out "tmp/rspec_profiles/rspec_results.json" --profile 100000 --fail-fast=$MAX_FAILURES --color --pattern "spec/**/*_spec.rb,drivers/*/spec/**/*_spec.rb" --tag ${{ matrix.test_group.tag }} --tag ~type:system
bundle exec rspec --fail-fast=$MAX_FAILURES --color --pattern "spec/**/*_spec.rb,drivers/*/spec/**/*_spec.rb" --tag ${{ matrix.test_group.tag }} --tag ~type:system
- name: Run okta tests
if: matrix.test_group.okta_tests
env:
AWS_ACCESS_KEY_ID: local_access_key
AWS_SECRET_ACCESS_KEY: local_secret_key
GROVER_NO_SANDBOX: true
CHROMIUM_PATH: /usr/bin/chromium-browser
MAX_FAILURES: 60
LOG_LEVEL: INFO
run: |
OKTA_DOMAIN=localhost OKTA_CLIENT_ID=x OKTA_CLIENT_SECRET=x bundle exec rspec --fail-fast=$MAX_FAILURES --color -fd spec/requests/omniauth_spec.rb spec/requests/sessions_controller_spec.rb # these tests need okta enabled
- name: Run logging tests
if: matrix.test_group.logging_tests
env:
AWS_ACCESS_KEY_ID: local_access_key
AWS_SECRET_ACCESS_KEY: local_secret_key
LOG_LEVEL: INFO
run: |
TEST_DEVELOPMENT_LOGGING_CONFIG=true RAILS_LOG_TO_STDOUT=true LOGRAGE=true bundle exec rspec --color --format p spec/models/logging_spec.rb
TEST_DEVELOPMENT_LOGGING_CONFIG=true RAILS_LOG_TO_STDOUT=true LOGRAGE=false bundle exec rspec --color --format p spec/models/logging_spec.rb
TEST_DEVELOPMENT_LOGGING_CONFIG=true RAILS_LOG_TO_STDOUT=false LOGRAGE=true bundle exec rspec --color --format p spec/models/logging_spec.rb
TEST_DEVELOPMENT_LOGGING_CONFIG=true RAILS_LOG_TO_STDOUT=false LOGRAGE=false bundle exec rspec --color --format p spec/models/logging_spec.rb
TEST_STAGING_LOGGING_CONFIG=true bundle exec rspec --color --format p spec/models/logging_spec.rb
- name: Build front end and run tests
if: matrix.test_group.system_tests
env:
AWS_ACCESS_KEY_ID: local_access_key
AWS_SECRET_ACCESS_KEY: local_secret_key
MAX_FAILURES: 60
LOG_LEVEL: INFO
RUN_SYSTEM_TESTS: true
BRANCH_NAME: "${{ github.head_ref || github.ref_name }}:${{ github.base_ref || 'stable' }}:stable"
CHROME_URL: http://chrome:3333
run:
bash ./bin/run_hmis_system_tests.sh
- name: Archive artifacts
if: always()
uses: actions/upload-artifact@v4
with:
if-no-files-found: ignore
name: artifacts-${{ matrix.test_group.id}}
path: |
tmp/rspec_profiles/
tmp/capybara/screenshots/
var/deprecations/*.yml