OHS-Hosting-Infrastructure / complaint-tracker

**This repo is currently not in active development.** Increasing visibility into complaint status by connecting data across the OHS ecosystem
Other
4 stars 0 forks source link

Complaint Tracker

The Complaint Tracker is intended to connect complaints data across the OHS ecosystem for greater visibility into status and actions taken to address a complaint.

Development

Local Setup

Local Configuration

Environment variables can be set in development using the dotenv gem.

Consistent but sensitive credentials should be added to config/credentials.yml.env by using $ rails credentials:edit

Any changes to variables in .env that should not be checked into git should be set in .env.local.

If you wish to override a config globally for the test Rails environment you can set it in .env.test.local. However, any config that should be set on other machines should either go into .env or be explicitely set as part of the test.

Authentication

The Complaint Tracker is utilizing the HSES Staging environment for non-production authentication. If you need an account reach out in the #ph-ohs-oneteam Slack channel for help in requesting one.

Bypassing HSES Authentication

HSES Authentication can be bypassed depending on the value of RAILS_ENV

Environment HSES Bypass
test always bypassed
development set CT_BYPASS_AUTH environment variable to true
ci always bypassed
production never bypassed

When bypassing auth, you may use CT_CURRENT_USER_UID and/or CT_CURRENT_USER_NAME to override the current user's HSES name or username.

API Connections

API data will come from real APIs or the Api::FakeData depending on the value of RAILS_ENV

Environment Connects to Real API Endpoints
test when CT_USE_REAL_API_DATA environment variable is true
development when CT_USE_REAL_API_DATA environment variable is true
ci never connects to real APIs
production always attempts to connect to real APIs

Documentation about the API specifications is available in docs/api_integrations.

Inline <script> and <style> security

The system's Content-Security-Policy header prevents <script> and <style> tags from working without further configuration. See the CSP compliant script tag helpers ADR for more information on setting these up successfully.

Testing

Running tests

Run everything: bundle exec rake

Manual tests

If you are testing manually, there are a couple features built into the fake data behavior to help you imitate errors.

Set up automatic linting and testing

If you would like the linter to run before you commit, symlink .githooks/pre-commit to .git/hooks/pre-commit.

cd .git/hooks
ln -s ../../.githooks/pre-commit pre-commit

To bypass the hook in order to commit something that's not perfect yet, run one of the following:

git commit -n  # --no-verify

CI/CD

GitHub actions are used to run all tests and scans as part of pull requests.

Security scans are also run on a scheduled basis. Weekly for static code scans, and daily for dependency scans.

Deployment

Staging

GitHub Actions are used to deploy to staging after any PR is merged into main.

Branch protection rules prevent any direct pushes to main or PRs from being merged into main until all tests and scans pass.

Production

TBD

Configuring ENV variables in cloud.gov

All configuration that needs to be added to the deployed application's ENV should be added to the env: block in manifest.yml

Items that are both public and consistent across staging and production can be set directly there.

Otherwise, they are set as a ((variable)) within manifest.yml and the variable is defined depending on sensitivity:

Credentials and other Secrets

  1. Store variables that must be secret using GitHub Environment Secrets
  2. Add the secret to the env: block of the deploy action as in this example
  3. Add the appropriate --var addition to the push_arguments line on the deploy action as in this example

Non-secrets

Configuration that changes from staging to production, but is public, should be added to config/deployment/stage.yml and config/deployment/production.yml

Documentation

Architectural Decision Records (ADR) are stored in doc/adr To create a new ADR, first install ADR-tools if you don't already have it installed.

Then create the ADR:

This will create a new, numbered ADR in the doc/adr directory.

Contributing

~This will continue to evolve as the project moves forward.~

Story Acceptance

TBD