Commit Graph

87 Commits

Author SHA1 Message Date
Ryan Ahearn
fa7b1a41b8 Add python and npm audits to checks.yml 2022-08-25 16:55:33 -04:00
Ryan Ahearn
bdee795f56 Switch first nvm source to --no-use instead of --install 2022-08-09 09:23:47 -04:00
Ryan Ahearn
3ff922bb07 Source nvm from either $HOME or /usr/local/share 2022-08-08 14:43:13 -04:00
jimmoffet
dad051a662 2767 passing 2022-08-05 00:25:03 -07:00
Jim Moffet
e17c26d1f6 config buckets 2022-06-23 14:08:29 -07:00
Jim Moffet
18eefc87c0 clean makefile 2022-06-13 14:31:51 -07:00
Jim Moffet
2b727e13b4 local dev upgrades 2022-06-13 14:26:46 -07:00
Ben Thorner
b348e8ed03 Add better-npm-audit to check production packages
This is the same as [^1].

[^1]: https://github.com/alphagov/document-download-frontend/pull/120
2022-05-09 12:05:42 +01:00
Ben Thorner
d97ed69f0b Turn off NPM auditing on installation
This isn't useful as it mostly pertains to dev dependencies, where
we're not concerned about vulnerabilities as they run in isolation.
2022-05-06 12:31:52 +01:00
Richard Baker
799949a3f4 Add .nvmrc & use NVM to manage installed Node version
We have decided to use NVM to manage installed Node versions locally
and in CI to ensure they match and produce consistent builds.

Running `nvm install` will install the Node version specified in the
`.nvmrc` file.

This is now consistent with Document Download Frontend.
See: alphagov/document-download-frontend#114

Signed-off-by: Richard Baker <richard.baker@digital.cabinet-office.gov.uk>
2022-04-05 12:09:53 +01:00
Chris Hill-Scott
795fd8f91d Add Makefile command to watch for frontend changes
When editing CSS, Javascript or other assets it’s useful to not have to
run `gulp` manually to rebuild things after making changes.

This is why we have the `npm watch` script.

However for the paths to fonts to resolve properly when running locally
it needs the `NOTIFY_ENVIRONMENT` variable set to `development`. Having
to remember to do both of these steps every time is awkward.

For a one-off build of the frontend we added a command to set
`NOTIFY_ENVIRONMENT` to the appropriate value in https://github.com/alphagov/notifications-admin/pull/4049

This commit does the same thing for the watch task, by encapsulating
both steps in one `make` command.

Happy to take alternative suggestions on command naming.
2021-11-02 15:22:57 +00:00
Ben Thorner
1869f9a53a Fix static assets in development (again)
Previous attempt: https://github.com/alphagov/notifications-admin/pull/4048

The problem with the previous attempt is that the assets built on
CI become part of the build artefact used for production [1]. This
switches back to my original approach of using environment.sh, but
with a technique to cope with it being absent on CI. I've tested it
works with and without an environment.sh file.

Note that "npm install" is fine to be on a separate line, since a
non-zero exit code will always cause "make" to stop.

[1]: https://github.com/alphagov/notifications-aws/blob/master/concourse/templates/admin.yml.j2#L47
2021-10-19 11:08:17 +01:00
Ben Thorner
f8d97821a2 Fix broken CSS links to assets in development
This depends on an environment variable being set when the assets
are built in a development context [1]. Otherwise, the assets get
their '/static' prefix stripped like they do for production, which
isn't compatible with serving them under '/static' in development.

[1]: 66e5022198/gulpfile.js (L37-L41)
2021-10-18 17:32:28 +01:00
Chris Hill-Scott
5c94aa004e Remove deprecated command line flag to isort
> Prior to version 5.0.0, isort wouldn't automatically traverse directories. The --recursive option was necessary to tell it to do so. In 5.0.0 directories are automatically traversed for all Python files, and as such this option is no longer necessary and should simply be removed.

— https://github.com/PyCQA/isort/blob/main/docs/upgrade_guides/5.0.0.md#--recursive-or--rc

***

We moved to version `> 5.0.0` of isort in March 2021: https://github.com/alphagov/notifications-admin/pull/3828/files
2021-10-04 14:58:29 +01:00
Tom Byers
5115344927 Remove rebuild of node-sass from bootstrap
We now use `sass`, a JavaScript version of Sass,
compiled from dart-sass*, so shouldn't need to
rebuild it to solve issues with C libraries.

*https://github.com/sass/dart-sass
2021-09-22 12:05:48 +01:00
Ben Thorner
ca9c28d08f Merge pull request #3897 from alphagov/remove-run-tests
Run tests directly from the Makefile
2021-06-16 14:02:44 +01:00
David McDonald
f4dc9e15e1 Add help text for new make steps
Helpful for when you run `make` as you've forgotten what the command is
and you don't want to go find the readme
2021-05-25 11:21:39 +01: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
Leo Hemsted
5d2b18e501 bump pip-tools when freezing dependencies
to stop big diffs from change in formatting of reqs.txt
2021-04-08 11:09:39 +01:00
Ben Thorner
c5e528efa2 Fix typo in Makefile (not running 'npm install') 2021-02-26 17:54:43 +00:00
Ben Thorner
86929df84e Remove other unused rules in Makefile
These aren't referenced anywhere. Some are repeated in other rules,
and if necessary it should be easy to type the commands.
2021-02-22 17:21:01 +00:00
Ben Thorner
c1cbd9c34a Remove redundant parts of the README
These aren't specific to this repo, and are covered more generally
in the Wiki [1]. Note that:

- The claim about needing multiple Python versions is not true.
- The NPM instructions should be covered by the "make bootstrap".
- The version of Node/NPM is covered by installing the latest one.

[1]: https://github.com/alphagov/notifications-manuals/wiki/Getting-Started
2021-02-22 17:04:41 +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
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
Ben Thorner
2af1d6f159 iRemove redundant Docker tasks
Nothing and no one uses these.
2021-02-22 16:38:27 +00:00
Ben Thorner
627e4e41ab Stop locking non-test dependencies twice
Currently we have a situation where we're not running tests against
new versions of dependencies, as requirements_for_test.txt is not
being kept in-sync with requirements.txt by pyup. Deploys are only
working because Concourse silently ignores version issues.

From a deployment log:

awscli 1.18.211 has requirement PyYAML<5.4,>=3.10; python_version != "3.4", but you'll have pyyaml 5.4 which is incompatible.

This switches to a single requirements file for test dependencies,
in order to keep it in-sync with requirements.txt i.e. we run our
tests against the same versions of dependencies that we deploy with,
and the build fails if we try to use package versions that are not
mutually compatible, as this example PR shows [1].

ERROR: Cannot install -r requirements_for_test.txt (line 17), -r requirements_for_test.txt (line 198) and pyyaml==5.4.1 because these package versions have conflicting dependencies.

We shouldn't need to have fine-grained locking on test dependencies,
beyond those we want to list manually in the file.

[1]: https://github.com/alphagov/notifications-admin/pull/3804
2021-02-16 18:09:47 +00:00
Chris Hill-Scott
54d3d0421b Restore and add comments 2021-01-08 17:02:39 +00:00
Chris Hill-Scott
8b1e4afd3b Install pip tools as part of freeze-requirements
Makes the command faster and more self contained.
2021-01-08 17:02:39 +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
David McDonald
36fa31563d Use cf7 commands for the cf CLI commands
As we want to upgrade from cf6 to cf7 CLI
2020-12-08 17:59:25 +00:00
Pea Tyczynska
652b627312 Update healthcheck page and remove all travis references from the repository 2020-04-24 11:54:26 +01:00
Leo Hemsted
7df45d6cce bump deployment timeout
5 minutes isn't long enough to deploy ten instances of the admin app -
it turns out it takes marginally longer than 5 minutes to roll each
instance one after the next. this can lead to confusion as the build
fails, functional tests don't run, but the code may have deployed fine
and be running on production.
2020-03-23 14:38:01 +00:00
David McDonald
d3c8b35aa9 Rearrange makefile 2020-03-03 12:05:56 +00:00
David McDonald
162734c7a7 Remove unused makefile commands
These are either not used at all or we have superseeded them with
commands written directly into concourse jobs
2020-03-03 12:05:15 +00:00
David McDonald
aa9446f752 Remove jenkins related code 2020-03-03 12:04:32 +00:00
Chris Hill-Scott
0fc1ae63e9 Add a command to fix import order
We check import order as part of our automated tests. But fixing them
means:
- manually editing them and rechecking
- remembering the parameters to `isort`
- looking up the `isort` command from the last time you ran it

Putting it in the Makefile should make life a bit easier.
2020-01-13 10:26:11 +00:00
David McDonald
224db44a9e Remove coveralls
We aren't using it
2019-12-24 15:25:34 +00:00
David McDonald
ecac52a155 Remove venv creating in makefile
Let's developer create their own virtualenvs using virtualenvwrapper as
they already do.
2019-12-24 15:24:07 +00:00
David McDonald
74b46782ff Remove pip-accel
Not sure how much benefit we are getting from this. Pip-accel has
already not been supported for 3 years now either.
2019-12-24 15:22:42 +00:00
David McDonald
8ce1917740 Revert "Remove pip-accel" 2019-12-23 11:49:32 +00:00
David McDonald
807c83c656 Remove coveralls
We don't use it
2019-12-20 16:58:45 +00:00
David McDonald
4c9c98afb4 Remove forcing of venv
Let's developers do this themselves using virtualenvwrapper
2019-12-20 16:57:25 +00:00
David McDonald
4ea46f2c71 Remove pip-accel
Not sure how much benefit we are getting from this. Pip-accel has
already not been supported for 3 years now either.
2019-12-19 16:25:01 +00:00
Leo Hemsted
6359657db8 update manifest file to use zdt-push
https://github.com/alphagov/notifications-api/pull/2498 contains some
more info
2019-05-09 16:11:26 +01:00
Leo Hemsted
4b386d36ef default CF_APP to notify-admin
(it's overriden in the calls to generate-manifest for the prototypes)
2019-04-18 14:48:23 +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
Chris Hill-Scott
cc405d7c1a Set far-future cache headers on S3 assets
So that browsers will cache them for as long as possible. We invalidate
this cache by adding the hash of each file to the query string.

There’s no way of doing this on a whole bucket; it has to be set on each
item. Adding this flag does so at the time of uploading the items.

Value of 10 years in seconds taken from:
0ee3bcb1ee/whitenoise/base.py (L19)
2018-12-21 12:00:45 +00:00
Athanasios Voutsadakis
93db0b6817 Decouple upload-static from cf-deploy
There are some permissions issues that need to be addressed before
we chain these two together.
2018-12-18 15:48:14 +00:00
Chris Hill-Scott
54638ad2e7 Copy static files to S3 when deploying
We have a nasty bug where Cloudfront is caching old files against new
URLs because the new code rolls out gradually across the ~10 admin
instances we have in production.

The way we are going to fix this is by pointing Cloudfront at S3, which
doesn’t have the concept of ‘instances’.

This commit does the work to copy the files to the new buckets. It
depends on the beuckets being set up.
2018-12-18 11:57:52 +00:00
Leo Hemsted
f279bbbd33 bump utils to fix slow notification rendering 2018-08-09 14:07:06 +01:00