Commit Graph

116 Commits

Author SHA1 Message Date
Christa Hartsock
6d3f67fb9b Initial config for local deployments
Not yet working properly on cloud.gov
2022-06-23 15:53:23 -07:00
Jim Moffet
e17c26d1f6 config buckets 2022-06-23 14:08:29 -07:00
Ben Thorner
66ffc0e29b Run tests directly from the Makefile
Depends on: https://github.com/alphagov/notifications-aws/pull/905

Previously this would print some custom text with each step, and
as optionally loading a virtual environment. This moves the actual
test commands to the Makefile. While this no longer prints custom
text, it does print the command that was run:

Before (skipping other output):

  ./scripts/run_tests.sh
  Code style check passed
  Import order check passed
  ...
  JavaScript tests have passed
  ...
  Unit tests have passed

After (skipping other output):

  flake8 .
  isort --check-only ./app ./tests
  npm test
  ...
  py.test -n auto --maxfail=10 tests/
  ...

I think it's more useful to see the command being run, rather than
having to wait until it succeeds to know what was happening. Having
the command also makes it easier to run it again if it fails, rather
than having to go and find it in a script.
2021-05-24 15:39:36 +01:00
David McDonald
3e80ba4734 Fix flake8 and isort errors
Note, isort now has default behaviour of searching recursively so we no
longer need the `-rc` flag
2021-03-08 18:48:56 +00:00
Ben Thorner
dfb767d57e Move bootstrap tasks into the Makefile
This is more consistent with how we run all other tasks. Note that
the virtual env setup is not generally applicable, and developers
of this repo should follow the guidance in the README.
2021-02-22 16:53:54 +00:00
Ben Thorner
f6cdf999fe Remove unused files in scripts/ 2021-02-22 16:48:16 +00:00
Ben Thorner
36a806e8bf Switch to 'make' for running app processes
These are simple enough that they don't need their own scripts.
2021-02-22 16:41:30 +00:00
Chris Hill-Scott
0f68d25265 Replace custom pip freeze script with pip-tools
In the past we've avoided using out-of-the-box solutions for Python
dependency resolution because a) they haven't been very mature and b)
we've had lots of issues with version conflicts. See [[1]], [[2]] for
details. Instead, we've been using a custom Python script that
under-the-hood runs `pip freeze` and saves the output to
`requirements.txt`.

This script works well for us, but it doesn't integrate well with other
tools. On the other hand [`pip-tools`](https://github.com/jazzband/pip-tools)
as of 2020 seems to be well-supported by its maintainers and other
tools; for instance, GitHub's automated update service
[Dependabot](https://dependabot.com) supports `requirements.in` files.

This commit replaces our `freeze-requirements` make command with
`pip-compile`.

The Digital Marketplace team have made this change and seem happy with
the results.
2021-01-08 17:02:39 +00:00
Chris Hill-Scott
4d43354473 Remove strict argument to pytest
We set it in pytest.ini anyway.
2020-02-24 17:28:29 +00:00
Chris Hill-Scott
f871fc4b5f Remove code coverage report
We don’t use it any more as of https://github.com/alphagov/notifications-admin/pull/3228
2020-02-24 17:26:09 +00:00
Katie Smith
1c23784767 Pytest 5 🎉
Also updates the Pytest command in `run_tests.sh` to remove junit,
which we stopped using.
2020-01-09 09:50:37 +00:00
Tom Byers
5c11d89792 Fix console output for JS tests
The string identifying the tests run shouldn't
include their status, that's added by
`display_result`.
2019-11-28 15:26:24 +00:00
Rebecca Law
0bd844a961 Update puralisation 2019-09-25 16:09:36 +01:00
Rebecca Law
d902ac3b44 Added the url for api docs.
Updated error message when js tests fail
2019-09-25 15:47:35 +01:00
Chris Hill-Scott
1a353d90eb Create the app once per run, not once per test
Turns out our tests spent a lot of time recreating the app for each test
case, which is quite intense.

This commit makes the fixture sessions level, so the app is only created
once per test session, not once per test function.

This cuts down the time taken to run the test suite to about 50 seconds.

It also makes the tests more parallelizable. Before this change going
from 4 to 8 processes made the tests slower. Now it cuts them down from
about 50 seconds to about 35 seconds[1]. So this commit also lets Pytest
choose the best number of processes to run, since on my machine it
chooses 8, which is the fastest.

Overall this means the

1. With a 2.2GHz quad-core Intel Core i7 processor on a 2015 MacBook Pro
2019-09-18 15:58:25 +01:00
Leo Hemsted
9547fedcc3 move manifest to single jinja template
uses the same pattern as other apps. Infers route based on app name,
you can declare more in the dict at the top if you need to.
2019-04-16 14:46:00 +01:00
Pea Tyczynska
7f4580cb82 Update content following review 2018-11-16 15:15:40 +00:00
Alexey Bezhan
2f876243ae Pin all requirements in requirements.txt
The list of top-level dependencies is moved to requirements-app.txt,
which is used by `make freeze-requirements` to generate the full
list of requirements in requirements.txt.

(See alphagov/notifications-api#1938 for details.)
2018-07-30 16:43:03 +01:00
Chris Hill-Scott
f3a0c505bd Enforce order and style of imports
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```

Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.

Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
    lib1,
    lib2,
    lib3,
    lib4,
)
```

1. https://pypi.python.org/pypi/isort
2018-02-27 16:35:13 +00:00
Leo Hemsted
5005a0db51 Merge pull request #1864 from alphagov/pytest-env
Automatically set environment vars before tests
2018-02-14 15:11:53 +00:00
Chris Hill-Scott
14b5f9e778 Allow up to 10 tests to fail before stopping
This is a sensible compromise between 1 test and ALL THE TESTS.

Uses the `maxfail` option as documented here:
https://docs.pytest.org/en/latest/usage.html#stopping-after-the-first-or-n-failures
2018-02-14 13:25:41 +00:00
Chris Hill-Scott
9f275d2a0b Stop pytest on first failing test
If a PR is going to fail because tests aren’t passing then you:
- should know about it as quick as possible
- shouldn’t waste precious Jenkins CPU running subsequent tests

This commit adds the `-x` flag to pytest, which stops the test run as
soon as one failing test is discovered.
2018-02-14 11:50:51 +00:00
Chris Hill-Scott
513c64be64 Remove environment_test.sh
These config variables are now set in `pytest.ini` instead.
2018-02-14 11:28:15 +00:00
Chris Hill-Scott
5efc86bbcc Remove flag from flake8 command
This flag was only needed because of a bug in flake8. This bug is fixed
now.
2018-02-12 10:26:55 +00:00
Alexey Bezhan
945c967250 Don't parse AWS credentials from VCAP_SERVICES in run_app_paas
AWS credentials are provided in the environment variables directly,
so we don't need to parse them from VCAP_SERVICES
2018-01-09 14:20:18 +00:00
Alexey Bezhan
ab55bf49b2 Add generate_manifest.py script and update deployment tasks
Brings in the new environment variables deployment process introduced
in alphagov/notifications-api#1543.

The script is a copy of the API one and make steps are modified to
fit with the existing admin deployment targets.
2018-01-09 14:14:47 +00:00
Chris Hill-Scott
b24c23fe3b Lint for print statements
flake8-print is a flake8 plugin that checks for `print()` statements in
Python files.

This should save us having to manually spot these when reviewing pull
requests.

The `--enable=T` flag needs to be set until this bug is fixed:
https://github.com/JBKahn/flake8-print/issues/27
2018-01-05 12:14:28 +00:00
Athanasios Voutsadakis
d8dabcfbbf Remove appspec and related files
These have not been used since the migration to paas, so they can be
removed.
2018-01-02 14:24:26 +00:00
Leo Hemsted
4aeb57567a remove flask-script
flask-script has been deprecated by the internal flask.cli module, but
making this carries a few changes with it

* you should add FLASK_APP=application.py and FLASK_DEBUG=1 to your
  environment.sh.
* instead of using `python app.py runserver`, now you must run
  `flask run -p 6012`. The -p command is important - the port must be
  set before the config is loaded, so that it can live reload nicely.
  (https://github.com/pallets/flask/issues/2113#issuecomment-268014481)
* find available commands by just running `flask`.
* run them using flask. eg `flask list_routes`
* define new tasks by giving them the decorator
  `@app.cli.command('task-name')`. Task name isn't needed if it's just
  the same as the function name. Alternatively, if app isn't available
  in the current scope, you can invoke the decorator directly, as seen
  in app/commands.py
2017-11-06 17:33:04 +00:00
Chris Hill-Scott
1530613fb4 Remove references to pycodestyle
We’re using flake8 now instead.
2017-10-20 11:02:39 +01:00
Chris Hill-Scott
eb2eea2e0b Use more processors when running tests
Back on my old 2013 Macbook Pro, 2 was the optimum number of cores for the fastest test runs. Which is why I chose `-n2` when I originally introduced this flag (see 9ced677ec7).

Now I have a faster Macbook (same as every other developer), which has more cores to take advantage of.

We also use 4 cores when running the API tests.

Cores | Time taken to run tests
--- | ---
1 | 28.31s
2 | 18.15s
3 | 14.33s
4 | 12.32s
5 | 12.98s
6 | 13.49s
8 | 15.37s
2017-10-18 11:15:09 +01:00
Athanasios Voutsadakis
79752d2754 Configure gunicorn errorlog
Related: alphagov/notifications-api/pull/1274
2017-09-22 15:41:41 +01:00
Leo Hemsted
8dc9d1205b typo 2017-08-22 15:05:10 +01:00
Leo Hemsted
56746e6f0f don't capture logs directly from stdout
previously in run_app_paas.sh, we captured stdout from the app and
piped that into the log file. However, this came up with a bunch of
problems, mainly that exceptions with stack traces often weren't
formatted properly, and kibana could not parse them

instead, with the updated utils library, we can use that to log json
straight to the appropriate directory directly.
2017-08-09 15:41:33 +01:00
Imdad Ahad
d06a72224e Don't create wheels for dependencies but store offline:
Previously we used AWS which meant that we could create wheels
from our requirements and then install them offline which made
deployments quicker.

We're no longer using AWS so let's remove that.

Although CloudFoundry supports installing dependencies in an offline
environment as documented here:
http://docs.cloudfoundry.org/buildpacks/python/#vendoring

To achieve this we create a vendor/ directory which will contain
the packages to install. This uses --no-index and --find-links so will
not resolve for any dependencies from pypi. For this reason there is
assumed confidence that the vendor/ directory will contain all
of the dependencies we need.
2017-07-20 14:17:10 +01:00
Martyn Inglis
e233c3868d Added some whitespace 2017-04-25 17:02:06 +01:00
Martyn Inglis
e7d6fd3293 updated run_tests to not use venv in the app if VIRTUAL_ENV is set 2017-04-25 15:32:12 +01:00
bandesz
0f0d567ae6 PaaS run script: redirect stderr to stdout 2017-03-21 15:04:08 +00:00
Leo Hemsted
1cacd92411 Merge pull request #1153 from alphagov/forget-me
Remove remember me cookie
2017-03-06 09:39:52 +00:00
bandesz
55f2d49e25 Add termination timeout to run_app_paas.sh 2017-02-28 17:38:50 +00:00
Leo Hemsted
9fda5d1847 remove remember_me cookie and related code 2017-02-27 15:18:18 +00:00
bandesz
b148a0a6a0 Add awslogs logging for PaaS 2017-02-16 14:19:37 +00:00
Imdad Ahad
4110d06e1f Cancel uninstalling python packages 2017-02-14 12:17:03 +00:00
Imdad Ahad
4ffc6e360c Remove notify app folder and installed python packages before we deploy the app 2017-02-13 17:32:51 +00:00
Chris Hill-Scott
f048b918a0 Use pycodestyle instead of PEP8
PEP8 was renamed to pycodestyle; this issue explains why:
PyCQA/pycodestyle#466

This commit changes our tests to use pycodestyle instead of pep8.

No changes to our code were required as a result.
2017-02-02 10:50:26 +00:00
Jenny Duckett
5eca69882a Generate the version file in the bootstrap script
This file needs to exist before the app can run, so create it automatically
rather than including it as an extra setup step in the README. The API app
already does this.
2016-11-29 16:25:50 +00:00
bandesz
0c00f3aae8 Add AGS elb to AWS scripts 2016-11-22 16:19:51 +00:00
Imdad Ahad
75854d91fc Use python wheels to speed up deployments 2016-11-07 17:56:08 +00:00
Leo Hemsted
008c88e42c add junit xml reporting to pytest 2016-08-31 15:15:28 +01:00
bandesz
cf34aff673 Travis cleanup: remove deploy + functest trigger 2016-08-25 16:20:17 +01:00