Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment #1449

Merged
merged 85 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
be3e3df
refactor(set-thread-status): remove from model
AndreasHuber Apr 25, 2024
8f68919
refactor(set-thread-status): move SQL query and cache handling into r…
AndreasHuber Apr 25, 2024
b941ce9
test(set-thread-status): remove mock for database-layer for the now m…
AndreasHuber Apr 25, 2024
f7c50a9
test(set-thread-status): add test that status actually changed
AndreasHuber Apr 29, 2024
1cae1ab
test(set-thread-status): format
AndreasHuber Apr 29, 2024
6829be5
test(set-thread-status): change expected result
AndreasHuber Apr 29, 2024
e4422ab
fix(set-thread-status): convert noStatus to no_status as it is in the…
AndreasHuber Apr 29, 2024
0a16b60
fix(set-thread-status): join ids with , instead of .
AndreasHuber Apr 29, 2024
7645dfb
refactor(uuid): Remove isSupportedUuid
kulla Apr 30, 2024
160b0de
fix(uuid): Use old uuid key again
kulla Apr 30, 2024
6340ff5
refactor(uuid): Remove checkUuid()
kulla Apr 30, 2024
f9e9478
WIP: Merge getUuid into UuidResolver
kulla Apr 30, 2024
3088826
test: Remove __tests__/internals/sentry.ts
kulla Apr 30, 2024
8e4bd58
fix: Fix of tests after refactoring
kulla Apr 30, 2024
26e5d9c
test: Fix tests
kulla Apr 30, 2024
669ab41
test: Remove unecessary import
kulla Apr 30, 2024
e2bc211
refactor(event)!: Remove AbstractUuid.events and User.eventsByUser
kulla Apr 30, 2024
a6e9d33
refactor: Rename "schema/notification" to "schema/events"
kulla Apr 30, 2024
9767c3f
Merge branch '6NkY1-kulla-2024-04-28-20-38' into kxV69-kulla-2024-04-…
kulla Apr 30, 2024
57d7a71
refactor(event): Move events query into API
kulla May 1, 2024
31baa75
refactor: Delete unused DB mutation
kulla May 1, 2024
b6a5c0f
test(thread): Format set-thread-state.ts
kulla May 1, 2024
51e86ff
fix(thread): Remove cache properly for set-thread-status
kulla May 1, 2024
4b8774b
test: Restructure set-thread-state.ts
kulla May 1, 2024
fb1b802
refactor: Fix lint errors
kulla May 1, 2024
1e76597
refactor: Split code for events and notifications
kulla May 1, 2024
e72eb2c
Merge pull request #1443 from serlo/kNHWA-kulla-2024-04-30-22-38
hugotiburtino May 2, 2024
645f9bc
Merge pull request #1446 from serlo/GXcOr-kulla-2024-05-01-20-07
hugotiburtino May 2, 2024
b5fb242
Merge pull request #1444 from serlo/kxV69-kulla-2024-04-30-23-01
hugotiburtino May 2, 2024
2821335
Merge pull request #1442 from serlo/9TIBE-kulla-2024-04-30-22-23
hugotiburtino May 2, 2024
192295a
Merge branch 'staging' into P0wrO-kulla-2024-04-30-17-01
hugotiburtino May 2, 2024
518c2ec
refactor(notification): Move SQL for notifications into API
kulla May 2, 2024
861c129
Merge pull request #1441 from serlo/P0wrO-kulla-2024-04-30-17-01
hugotiburtino May 2, 2024
c571e9d
build(deps): bump ejs from 3.1.9 to 3.1.10
dependabot[bot] May 2, 2024
58dc588
Merge pull request #1448 from serlo/dependabot/npm_and_yarn/ejs-3.1.10
kulla May 2, 2024
ab4d348
Merge branch 'staging' into migrate-set-thread-status-from-database-l…
AndreasHuber May 2, 2024
4faaf7b
chore(scripts): remove scripts related to old way of setting version
hugotiburtino May 2, 2024
17c949a
chore(ci): remove pipeline related to old way of deploying
hugotiburtino May 2, 2024
0d708d8
chore(scripts): remove shorthand call of inexistent script
hugotiburtino May 2, 2024
2a6e1f5
chore(scripts): remove file related to old way of deploying
hugotiburtino May 2, 2024
6670f21
docs(readme): remove old commands
hugotiburtino May 2, 2024
e71ac18
Merge pull request #1450 from serlo/remove-outdated
hugotiburtino May 2, 2024
0d56c9d
test(client): remove unused method
hugotiburtino May 2, 2024
15c292c
Merge pull request #1447 from serlo/AMQFP-kulla-2024-05-01-20-08
hugotiburtino May 2, 2024
904da29
refactor(set-thread-status): use new UuidResolver.removeCacheEntry
AndreasHuber May 2, 2024
828cbc5
test(set-thread-status): remove UuidQuery mock
AndreasHuber May 2, 2024
989a1cd
refactor(set-thread-status): use better fitting function removeCacheE…
AndreasHuber May 2, 2024
3cf0cf6
fix(set-thread-status): add missing await
AndreasHuber May 2, 2024
eb7ea0c
fix(notification): Update resolver name
kulla May 2, 2024
2e59d63
refactor: Replace NotificationSetStateMutation with SQL
kulla May 2, 2024
1b894b7
refactor(notification): Remove fetchScopeOfNotificationEvent()
kulla May 2, 2024
3af58dd
Merge pull request #1451 from serlo/crekY-kulla-2024-05-02-19-19
AndreasHuber May 3, 2024
004d8e0
Merge pull request #1452 from serlo/Xr3ZO-kulla-2024-05-02-19-38
kulla May 3, 2024
3045dca
chore(kratos): migrate user management development
hugotiburtino May 3, 2024
297eb18
chore(kratos): fix script
hugotiburtino May 3, 2024
01caf0e
chore(kratos): fix scripts
hugotiburtino May 3, 2024
b84f496
test: Make MSW to bypass to DB-Layer
kulla May 3, 2024
af1639f
Merge pull request #1457 from serlo/hNpaz-kulla-2024-05-03-21-58
kulla May 3, 2024
ec829ef
Merge branch 'staging' into migrate-set-thread-status-from-database-l…
AndreasHuber May 3, 2024
3810528
fix(uuid resolver): fix wrong SQL query
AndreasHuber May 4, 2024
0237b99
chore: Enable source-maps in "yarn start"
kulla May 4, 2024
b3b6049
Merge pull request #1461 from serlo/8W7Wq-kulla-2024-05-04-14-20
kulla May 4, 2024
c4697d1
refactor(database): Add fetchOptional() + better transaction handling
kulla May 4, 2024
8a21ca2
Merge pull request #1462 from serlo/nVYpj-kulla-2024-05-04-14-22
kulla May 4, 2024
f7991e4
fix(database): Use proper rollback()
kulla May 4, 2024
ffe44ee
Merge pull request #1463 from serlo/5PSWn-kulla-2024-05-04-15-22
kulla May 4, 2024
2a6698b
test(database): Close DB after tests
kulla May 4, 2024
f03cebe
Merge pull request #1464 from serlo/nfzli-kulla-2024-05-04-15-42
kulla May 4, 2024
8fe8eae
Merge branch 'staging' into migrate-set-thread-status-from-database-l…
AndreasHuber May 4, 2024
73013e8
fixtures: Remove empty source file
kulla May 5, 2024
dff0023
chore: Upgrade dependencies
kulla May 5, 2024
fd5a9c1
Merge pull request #1471 from serlo/cIM46-kulla-2024-05-05-21-03
kulla May 5, 2024
06b2a76
Merge pull request #1472 from serlo/eytFN-kulla-2024-05-05-21-05
kulla May 5, 2024
4dead0b
Apply suggestions from code review
kulla May 5, 2024
b71c1d4
Merge pull request #1455 from serlo/kratos-env
kulla May 5, 2024
20d2a09
fix(uuid resolver): fix comment with no_status not matching BaseComme…
AndreasHuber May 6, 2024
0e8f29d
style(uuid resolver): format SQL query
AndreasHuber May 6, 2024
fe81c0a
style(uuid resolver): run prettier
AndreasHuber May 6, 2024
09dd1cc
Merge pull request #1435 from serlo/migrate-set-thread-status-from-da…
AndreasHuber May 6, 2024
0704169
test(set-thread-status): remove dependency of test on certain ID
AndreasHuber May 6, 2024
f2e17fe
refactor(subject): use database directly for subjects query
elbotho May 6, 2024
4c1b390
chore: remove unused fixture
elbotho May 6, 2024
7c72dbe
test(set-thread-status): modify test so that it sets the thread statu…
AndreasHuber May 6, 2024
4d9fb9a
Merge pull request #1473 from serlo/refactor-subjects-sql
kulla May 6, 2024
594e630
Merge pull request #1474 from serlo/extend-set-thread-status-test
kulla May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions .github/workflows/push-version-image.yml

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/ejs-npm-3.1.9-e201b2088c-af6f10eb81.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
67 changes: 62 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ export NODE_OPTIONS=--dns-result-order=ipv4first

By default, while developing, the caching won't work. If you want to have caching, change the value `CACHE_TYPE` in `.env` to any other
value besides 'empty'.
To check the cache locally, run `yarn cache:cli`.
With `GET <key>` you get the cache value of the key that is defined in [serlo.ts](https://github.com/serlo/api.serlo.org/blob/staging/packages/server/src/model/serlo.ts).
See in `package.json` for other scripts regarding cache.
To check the cache locally, run `yarn cache:cli`.

Some other useful commands:
`redis:empty` removes the whole cache
`redis:list` lists all cached keys

### Run tests

Expand Down Expand Up @@ -101,16 +103,71 @@ We have `~` as an absolute path alias for `./src` in place, e.g. `~/internals` r
### Other commands

- `yarn build:server` builds the server (only needed for deployment)
- `yarn deploy:images` deploys the docker images to our Container Registry (only needed for deployment)
- `yarn format` formats all source code
- `yarn lint` lints all source code
- `yarn license` updates license headers in source files
- `yarn pacts` runs the contract tests
- `yarn test` runs the unit tests
- `yarn codegen` generates TypeScript types from GraphQL schema
- `yarn start` spins up the development environment
- `yarn update-version` starts the process for adding a new version (only needed for deployment)

## Changelog

Via filtering PRs by [`base:production`](https://github.com/serlo/api.serlo.org/pulls?q=is%3Apr+base%3Aproduction+) you can access the changelog of production.

## Developing with Ory Kratos

We use Ory Kratos for our user management.
Usually you won't need it, but if you do, run first:

`yarn start:kratos`

In the folder `./kratos` you find all important configuration files.
Emails sent by Kratos are going to be found at `http://localhost:4436`.

For more info about it see its [documentation](https://www.ory.sh/docs/kratos).

### Integrating Keycloak

First of all add `nbp` as host
`sudo bash -c "echo '127.0.0.1 nbp'" >> /etc/hosts`

_why do I need it? Kratos makes a request to the url of the oauth2 provider, but since it is running inside a container, it cannot easily use the host port. nbp is a dns that is discoverable for the kratos container, so the host can also use it._

Run `yarn start:nbp`.

Keycloak UI is available on `nbp:11111` (username: admin, pw: admin).
There you have to configure Serlo as a client.

> Client -> Create Client
>
> ```
> id: serlo
> home and root url: http://localhost:3000
> redirect uri: http://localhost:4433/self-service/methods/oidc/callback/nbp
> ```

Get the credentials and go to `kratos/config.yml`:

```yaml
selfservice:
methods:
oidc:
enabled: true
config:
providers:
- id: nbp
provider: generic
client_id: serlo
client_secret: <put secret here>
```

Run the local frontend (not forgetting to change environment in its `.env` to local) to test.

### Email templates

Kratos has to be rebuilt every time you change an email template. Use the following workflow:

1. Edit templates. See at `kratos/config.yml` where they are.
2. Run `yarn kratos:rebuild`
3. Test the verification or the recovery email at `localhost:4436`. Repeat the process.
Empty file.
2 changes: 2 additions & 0 deletions __tests__/__utils__/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class Client {
cache: global.cache,
swrQueue: emptySwrQueue,
authServices,
timer: global.timer,
database: global.database,
}),
},
service: this.context?.service ?? Service.SerloCloudflareWorker,
Expand Down
9 changes: 0 additions & 9 deletions __tests__/__utils__/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ const ForDefinitions = {
given('EventQuery').withPayload({ id: event.id }).returns(event)
})
},
SubjectsQuery(terms: Model<'TaxonomyTerm'>[]) {
given('SubjectsQuery')
.withPayload({})
.returns({
subjects: terms.map((term) => {
return { taxonomyTermId: term.id, instance: term.instance }
}),
})
},
UnrevisedEntitiesQuery(entities: Model<'AbstractEntity'>[]) {
given('UnrevisedEntitiesQuery')
.withPayload({})
Expand Down
2 changes: 1 addition & 1 deletion __tests__/internals/create-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
createEvent,
toGraphQLModel,
DatabaseEventRepresentation,
} from '~/schema/notification/event'
} from '~/schema/events/event'
import { Instance } from '~/types'

const basePayload = {
Expand Down
36 changes: 0 additions & 36 deletions __tests__/internals/sentry.ts

This file was deleted.

11 changes: 8 additions & 3 deletions __tests__/schema/entity/checkout-revision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
taxonomyTermSubject,
} from '../../../__fixtures__'
import { getTypenameAndId, nextUuid, given, Client } from '../../__utils__'
import { emptySubjects } from '../subject'
import { Instance } from '~/types'

const user = { ...baseUser, roles: ['de_reviewer'] }
Expand Down Expand Up @@ -121,7 +122,6 @@ test('checkout revision has trashed == false for following queries', async () =>
})

test('after the checkout mutation the cache is cleared for unrevisedEntities', async () => {
given('SubjectsQuery').for(taxonomyTermSubject)
given('UuidQuery').for(article)

const unrevisedEntitiesQuery = new Client()
Expand All @@ -145,7 +145,10 @@ test('after the checkout mutation the cache is cleared for unrevisedEntities', a

await unrevisedEntitiesQuery.shouldReturnData({
subject: {
subjects: [{ unrevisedEntities: { nodes: [getTypenameAndId(article)] } }],
subjects: [
{ unrevisedEntities: { nodes: [getTypenameAndId(article)] } },
...emptySubjects,
],
},
})

Expand All @@ -154,7 +157,9 @@ test('after the checkout mutation the cache is cleared for unrevisedEntities', a
})

await unrevisedEntitiesQuery.shouldReturnData({
subject: { subjects: [{ unrevisedEntities: { nodes: [] } }] },
subject: {
subjects: [{ unrevisedEntities: { nodes: [] } }, ...emptySubjects],
},
})
})

Expand Down
12 changes: 9 additions & 3 deletions __tests__/schema/entity/reject-revision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
user as baseUser,
} from '../../../__fixtures__'
import { given, getTypenameAndId, nextUuid, Client } from '../../__utils__'
import { emptySubjects } from '../subject'
import { Instance } from '~/types'

const user = { ...baseUser, roles: ['de_reviewer'] }
Expand All @@ -21,6 +22,7 @@ const currentRevision = {
id: nextUuid(articleRevision.id),
trashed: false,
}

const mutation = new Client({ userId: user.id })
.prepareQuery({
query: gql`
Expand All @@ -37,7 +39,6 @@ const mutation = new Client({ userId: user.id })

beforeEach(() => {
given('UuidQuery').for(user, article, articleRevision, currentRevision)
given('SubjectsQuery').for(taxonomyTermSubject)
given('UnrevisedEntitiesQuery').for([article])

given('EntityRejectRevisionMutation')
Expand Down Expand Up @@ -104,7 +105,10 @@ test('after the reject mutation the cache is cleared for unrevisedEntities', asy

await unrevisedEntitiesQuery.shouldReturnData({
subject: {
subjects: [{ unrevisedEntities: { nodes: [getTypenameAndId(article)] } }],
subjects: [
{ unrevisedEntities: { nodes: [getTypenameAndId(article)] } },
...emptySubjects,
],
},
})

Expand All @@ -113,7 +117,9 @@ test('after the reject mutation the cache is cleared for unrevisedEntities', asy
})

await unrevisedEntitiesQuery.shouldReturnData({
subject: { subjects: [{ unrevisedEntities: { nodes: [] } }] },
subject: {
subjects: [{ unrevisedEntities: { nodes: [] } }, ...emptySubjects],
},
})
})

Expand Down
Loading