forms-api
is the API for the GOV.UK Forms platform. It is a Ruby on Rails api app, currently using a Postgresql database for data storage and is used for storing/serving the form configurations that are created by form creators in forms-admin.
To run the project you will need to install:
- Ruby - we use version 3.1 of Ruby. Before running the project, double check the [.ruby-version] file to see the exact version.
- a running PostgreSQL database
We recommend using a version manager to install and manage these, such as:
# 1. Clone the git repository and change directory to the new folder
git clone git@github.com:alphagov/forms-api.git
cd forms-api
# 2. Run the setup command
make setup
make setup
runs bin/setup
which is idempotent, so you can also run it whenever you pull new changes.
You can run the server via make serve
# Running the server without watching for changes
make serve
make serve
runs bin/setup
which is idempotent, followed by bin/rails server
This will start the server on localhost:9292
# Run the Ruby test suite
make test
# Run rubocop and display errors
make lint
# Run rubocop with fixes and display errors
make lint-fix
Before pushing code changes, it's a good idea to run the tests and use rubocop to format your code. We have a rake task for running all of these commands in parallel:
bin/rake run_code_quality_checks
Refer to the the config gem to understand the file based settings
loading order.
To override file based via Machine based env variables settings
cat config/settings.yml
file
based
settings
env1: 'foo'
export SETTINGS__FILE__BASED__SETTINGS__ENV1="bar"
puts Settings.file.based.setting.env1
bar
Refer to the settings file for all the settings required to run this app
This repo supports the ability to set up feature flags. To do this, add your feature flag in the settings file under the features
property. eg:
features:
some_feature: true
You can then use the feature service to check whether the feature is enabled or not. Eg. FeatureService.enabled?(:some_feature)
.
You can also nest features:
features:
some:
nested_feature: true
And check with FeatureService.enabled?("some.nested_feature")
.
Rspec tests can also be tagged with feature_{name}: true
. This will turn that feature on just for the duration of that test.
Use the update_app_versions.sh script in forms-deploy
Raise a Github issue if you need support.
We welcome contributions - please read CONTRIBUTING.md and the alphagov Code of Conduct before contributing.
We use the MIT License.