Skip to content

Commit e24be7f

Browse files
committed
feat: Integrate accent
1 parent 86d242f commit e24be7f

File tree

8 files changed

+489
-1996
lines changed

8 files changed

+489
-1996
lines changed

README.md

+51-35
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,35 @@
1414
- 4.1. [Heroku](#Heroku)
1515
- 4.2. [Abraxas](#Abraxas)
1616
- 4.3. [Docker (anywhere)](#Dockeranywhere)
17-
- 5. [E2E tests](#E2Etests)
18-
- 6. [GraphQL performance tests](#GraphQLperformancetests)
19-
- 6.1. [Automation](#Automation)
20-
- 6.2. [How to add or modify the tests](#Howtoaddormodifythetests)
21-
- 7. [Load tests](#Loadtests)
22-
- 7.1. [Automation](#Automation-1)
23-
- 7.2. [Local setup](#Localsetup)
24-
- 7.3. [Running the tests locally](#Runningthetestslocally)
25-
- 7.4. [Recording the tests using Playwright](#RecordingthetestsusingPlaywright)
26-
- 8. [Authentication](#Authentication)
27-
- 8.1. [Locally](#Locally)
17+
- 5. [Developing GitHub Actions](#DevelopingGitHubActions)
18+
- 6. [E2E tests](#E2Etests)
19+
- 7. [GraphQL performance tests](#GraphQLperformancetests)
20+
- 7.1. [Automation](#Automation)
21+
- 7.2. [How to add or modify the tests](#Howtoaddormodifythetests)
22+
- 8. [Load tests](#Loadtests)
23+
- 8.1. [Automation](#Automation-1)
24+
- 8.2. [Local setup](#Localsetup)
25+
- 8.3. [Running the tests locally](#Runningthetestslocally)
26+
- 8.4. [Recording the tests using Playwright](#RecordingthetestsusingPlaywright)
27+
- 9. [Authentication](#Authentication)
28+
- 9.1. [Locally](#Locally)
29+
- 10. [Translations](#Translations)
2830

2931
<!-- vscode-markdown-toc-config
3032
numbering=true
3133
autoSave=true
3234
/vscode-markdown-toc-config -->
3335
<!-- /vscode-markdown-toc -->
3436

35-
## Documentation
37+
## 1. <a name='Documentation'></a>Documentation
3638

3739
A public documentation is available at https://visualize.admin.ch/docs/.
3840

39-
## Development Environment
41+
## 2. <a name='DevelopmentEnvironment'></a>Development Environment
4042

4143
To start the development environment, you need a Docker runtime, e.g. [Docker Desktop](https://www.docker.com/products/docker-desktop) and [Nix](https://nixos.org).
4244

43-
### Setting up the dev environment
45+
### 2.1. <a name='Settingupthedevenvironment'></a>Setting up the dev environment
4446

4547
1. Make sure that Docker is running
4648
2. Start the Postgres database with `docker-compose up`
@@ -50,7 +52,7 @@ To start the development environment, you need a Docker runtime, e.g. [Docker De
5052
yarn setup:dev
5153
```
5254

53-
### Dev server
55+
### 2.2. <a name='Devserver'></a>Dev server
5456

5557
Once the application's set up, you can start the development server with
5658

@@ -68,15 +70,15 @@ yarn dev:ssl # If you are working with the login process
6870
6971
To run the application with debugging enabled through VSCode, make sure the dev server is running and the click the "Run and Debug" button in the sidebar (CMD-SHIFT-D). Then select the "Launch Chrome" configuration. This will open a new Chrome window with the dev tools open. You can now set breakpoints in the code and they will be hit.
7072

71-
### Postgres database
73+
### 2.3. <a name='Postgresdatabase'></a>Postgres database
7274

7375
If the database server is not running, run:
7476

7577
```sh
7678
docker-compose up
7779
```
7880

79-
### Building the Embed script `/dist/embed.js`
81+
### 2.4. <a name='BuildingtheEmbedscriptdistembed.js'></a>Building the Embed script `/dist/embed.js`
8082

8183
Currently, the embed script is not automatically built when the dev server starts.
8284

@@ -88,7 +90,7 @@ yarn dev:rollup
8890

8991
> Currently, this only bundles and initializes [iframe-resizer](https://github.com/davidjbradshaw/iframe-resizer) but could be used to render charts without iframes (using [custom elements](https://developers.google.com/web/fundamentals/web-components/customelements) or render to a generic DOM element) in the future.
9092
91-
#### Database migrations
93+
#### 2.4.1. <a name='Databasemigrations'></a>Database migrations
9294

9395
Database migrations are run automatically when a production build of the app starts. In _development_, you'll have to run them manually:
9496

@@ -112,7 +114,7 @@ After merging the branch, you can delete the environment variables scoped to the
112114

113115
[visualization-tool-postgres-dev](https://vercel.com/ixt/visualization-tool/stores/postgres/store_dV3rog1asOXO3BfC/data)
114116

115-
## Versioning
117+
## 3. <a name='Versioning'></a>Versioning
116118

117119
New versions of `package.json` are built on GitLab CI into a separate image that will be deployed to the integration env.
118120

@@ -122,9 +124,9 @@ yarn version
122124

123125
This will prompt for a new version. The `postversion` script will automatically try to push the created version tag to the origin repository.
124126

125-
## Deployment
127+
## 4. <a name='Deployment'></a>Deployment
126128

127-
### Heroku
129+
### 4.1. <a name='Heroku'></a>Heroku
128130

129131
If a Heroku app is set up (as Git remote `heroku`), deploy with
130132

@@ -136,7 +138,7 @@ Build instructions are defined in `heroku.yml`.
136138

137139
For details, see https://devcenter.heroku.com/articles/build-docker-images-heroku-yml
138140

139-
### Abraxas
141+
### 4.2. <a name='Abraxas'></a>Abraxas
140142

141143
With your Abraxas credentials ...
142144

@@ -157,7 +159,7 @@ Useful commands to use:
157159
- `sudo /usr/local/bin/docker-compose pull web` -> Pull latest web image manually (should not be needed much)
158160
- etc. (remember to use `sudo` for all Docker commands)
159161

160-
### Docker (anywhere)
162+
### 4.3. <a name='Dockeranywhere'></a>Docker (anywhere)
161163

162164
To pull the latest image from the GitLab registry, run:
163165

@@ -186,45 +188,45 @@ services:
186188
- "5432:5432"
187189
```
188190
189-
## Developing GitHub Actions
191+
## 5. <a name='DevelopingGitHubActions'></a>Developing GitHub Actions
190192
191193
Several checks are run on different types of events that happen within the repository, including E2E or GraphQL performance tests. In order to be able to build and test the actions locally, we use [act](https://github.com/nektos/act), with example mocked event payloads defined in [this folder](https://github.com/visualize-admin/visualization-tool/tree/main/act).
192194
193195
After [installing](https://nektosact.com/installation/index.html) the library, you can run a given action like e.g. `act deployment_status -W ".github/workflows/performance-tests-pr.yml" -e act/deployment_status.json`, modifying the event payload or adding a new one as needed.
194196

195-
## E2E tests
197+
## 6. <a name='E2Etests'></a>E2E tests
196198

197199
Playwright is run on every successful deployment of a branch. Screenshots are made with Percy and sent directly to their cloud service for diffing.
198200

199201
A special [test page](http://localhost:3000/en/__test) shows all the charts that are screenshotted.
200202
Those charts configurations are kept in the repository.
201203

202-
## GraphQL performance tests
204+
## 7. <a name='GraphQLperformancetests'></a>GraphQL performance tests
203205

204206
The project uses a combination of [k6](https://k6.io) and [Grafana](https://grafana.com) with [Prometheus](https://k6.io/docs/results-output/real-time/prometheus-remote-write/) for GraphQL performance testing.
205207

206-
### Automation
208+
### 7.1. <a name='Automation'></a>Automation
207209

208210
To ensure constant monitoring of the performance of selected GraphQL queries, the performance tests are run [once an hour](https://github.com/visualize-admin/visualization-tool/blob/main/.github/workflows/performance-tests.yml) against each environment of the application. The results are then sent to the governmental Grafana dashboards.
209211

210-
### How to add or modify the tests
212+
### 7.2. <a name='Howtoaddormodifythetests'></a>How to add or modify the tests
211213

212214
To add or modify the performance tests, go to the [k6/performance-tests](https://github.com/visualize-admin/visualization-tool/tree/main/k6/performance-tests) folder. The GitHub Action is generated by running the `yarn run github:codegen` command; be sure to run it after modifying the [generate-github-action.js](`https://github.com/visualize-admin/visualization-tool/blob/main/k6/performance-tests/generate-github-action.js`) file.
213215

214-
## Load tests
216+
## 8. <a name='Loadtests'></a>Load tests
215217

216218
The project uses [k6](https://k6.io) for load testing.
217219

218-
### Automation
220+
### 8.1. <a name='Automation-1'></a>Automation
219221

220222
There is a [dedicated GitHub Action](https://github.com/visualize-admin/visualization-tool/actions/workflows/manual-load-test.yml) that runs the API load tests against selected environment.
221223
You can investigate the results by going to Actions section in GitHub and checking the summary results. They are also visible in the cloud (k6.io), if you enable the cloud option.
222224

223-
### Local setup
225+
### 8.2. <a name='Localsetup'></a>Local setup
224226

225227
In order to run the tests locally, follow the [documentation](https://k6.io/docs/get-started/installation/) to install `k6` on your machine.
226228

227-
### Running the tests locally
229+
### 8.3. <a name='Runningthetestslocally'></a>Running the tests locally
228230

229231
You might want to run the script locally, for example to be able to bypass the cloud limitations of k6 (e.g. max number of VUs bigger than 50). To run a given load test, simply run
230232

@@ -237,7 +239,7 @@ by directly modifying the `options` object inside a given script and running `ya
237239

238240
For the GraphQL tests, you'll also need to pass `--env ENV=(test|int|prod)` flag to point to the proper environment and `--env ENABLE_GQL_SERVER_SIDE_CACHE=(true | false)` to control whether to use GQL server-side caching.
239241

240-
### Recording the tests using Playwright
242+
### 8.4. <a name='RecordingthetestsusingPlaywright'></a>Recording the tests using Playwright
241243

242244
While some tests are written manually, other tests come from HAR recordings that span a broad set of actions.
243245
In order to record a HAR file and convert it into k6 script, use the `testAndSaveHar` inside `e2e/har-utils.ts` file.
@@ -251,13 +253,27 @@ After the HAR file has been recorded, use [har-to-k6](https://k6.io/docs/test-au
251253

252254
> ⚠️ You might want to remove requests to Google afterwards manually, to remove false-positives of blocked requests.
253255

254-
## Authentication
256+
## 9. <a name='Authentication'></a>Authentication
255257

256258
Authentication is provided by the Swiss federal government's eIAM through ADFS.
257259
We use Next-auth to integrate our application with it, through a [custom Provider](app/auth-providers/adfs.ts).
258260

259-
### Locally
261+
### 9.1. <a name='Locally'></a>Locally
260262

261263
You can use the ref eIAM. ADFS environment variables should be configured in your
262264
`.env.local` file. You'll find those secret variables in our shared 1Password in
263265
the "Visualize.admin .env.local" entry.
266+
267+
## 10. <a name='Translations'></a>Translations
268+
269+
Translations are managed via [Accent](https://accent.interactivethings.io). Right now, you need to
270+
manually pull and push the translations. The process goes:
271+
272+
1. Edit components, add `<Trans />` and `t()`
273+
2. Run `yarn locales:extract` to write the `en/messages.po`
274+
3. Run `yarn locales:push --dry-run` to review what will be pushed to Accent
275+
4. Run `yarn locales:push` to push the new translations to Accent
276+
5. Edit the new messages in Accent web UI `yarn locales:browse`
277+
6. Run `yarn locales:pull` to get the messages.po for all translated languages
278+
279+
In the future, we might want to integrate further Accent so that it opens pull requests.

accent.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"apiUrl": "https://accent.interactivethings.io",
3+
"files": [
4+
{
5+
"namePattern": "file",
6+
"format": "gettext",
7+
"source": "app/locales/en/messages.po",
8+
"target": "app/locales/%slug%/%document_path%.po"
9+
}
10+
]
11+
}

0 commit comments

Comments
 (0)