guardian / typerighter

Even if you’re the right typer, couldn’t hurt to use Typerighter!
Apache License 2.0
276 stars 12 forks source link

Pull dictionary xml file from S3 into the Rule Manager #395

Closed rhystmills closed 1 year ago

rhystmills commented 1 year ago

What does this change?

This PR gives the Rule Manager access to a dictionary XML file from s3, and parses it to a list of unique words.

More specifically, it:

How to test

Run the rule manager locally.

Send a POST request to https://manager.typerighter.local.dev-gutools.co.uk/api/refreshDictionary - I use Postman to do this, using auth cookies from the network tab https://manager.typerighter.local.dev-gutools.co.uk/ in the browser (I think this just needs to be gutoolsAuth-assym but I tend to include PLAY_SESSION too).

This should return a list of unique words.

  1. Are the words unique?
  2. What happens if you do this before running the setup script? (you can delete the dictionary from ~/.gu/typerighter/ if you've already run it)
  3. Does it work if you deploy to CODE?
rhystmills commented 1 year ago

Code looks great! Lovely to see tests. Tested locally, works as expected – I've made a couple of changes to init-aws.sh to get the paths working that I hope makes sense in 8e06f65.

I think line 9 was sort of right (this one):

awslocal s3 cp /etc/.gu/typerighter/typerighter-dictionary.xml s3://typerighter-app-local/local/dictionary/typerighter-dictionary.xml

... it's copying the file from a location that Docker copies the file to in the localstack container (etc/.gu...) as specified in the volumes bit of the docker-compose.yml - but I've realised the convention is /etc/gu rather than /etc/.gu so I'll update that.

I should have remove line 8 because it wasn't doing anything - the localstack container was failing to access composer which led me down the Docker volumes path. Line 8 was:

aws s3 cp --profile composer --region eu-west-1 s3://typerighter-app-dev/dictionary/typerighter-dictionary.xml ~/.gu/typerighter/typerighter-dictionary.xml
rhystmills commented 1 year ago

(tested that in CODE and locally - working nicely so merged now)

jonathonherbert commented 1 year ago

Ace, thanks @rhystmills! I've a memory that adding config to the user dir ~ is more common now (I can see composer, atom workshop and workflow in there), but unsure if others can confirm, it's totally fine your way too 👍