Skip to content

Commit

Permalink
Merge branch 'staging' into 1556-merge-static-pages-into-entities
Browse files Browse the repository at this point in the history
  • Loading branch information
hugotiburtino committed Jul 3, 2024
2 parents f9a8858 + 9542b53 commit a70f4c7
Show file tree
Hide file tree
Showing 165 changed files with 1,020 additions and 1,206 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SERVER_KRATOS_DB_URI=postgres://serlo:secret@localhost:5432/kratos?sslmode=disab
SERVER_SERLO_CLOUDFLARE_WORKER_SECRET=api.serlo.org-playground-secret
SERVER_SERLO_CACHE_WORKER_SECRET=api.serlo.org-cache-worker-secret
SERVER_SERLO_NOTIFICATION_EMAIL_SERVICE_SECRET=api.serlo.org-notification-email-service-secret
SERVER_SERLO_EDITOR_TESTING_SECRET=api.serlo.org-serlo-editor-testing-secret
SERVER_SWR_QUEUE_DASHBOARD_PASSWORD=secret
SERVER_SWR_QUEUE_DASHBOARD_USERNAME=secret

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build the ${{ matrix.image }} image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
push: false
load: true
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/push-migration-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Push DB migration image
on:
# not a problem if we do it at every push because it will check if the image already exists
push:

jobs:
docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: serlo/configure-repositories/actions/setup-node@main
- uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_KEY_CONTAINER_REGISTRY }}'
- run: gcloud auth configure-docker
- uses: google-github-actions/setup-gcloud@v2
- run: yarn migrate:push-image
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 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 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 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/glob-npm-8.1.0-65f64af8b1-92fbea3221.zip
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 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/read-npm-2.1.0-0e0cb8a375-e745999138.zip
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.
12 changes: 0 additions & 12 deletions __fixtures__/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ export const createEntityLinkNotificationEvent: Model<'CreateEntityLinkNotificat
childId: coursePage.id,
}

export const removeEntityLinkNotificationEvent: Model<'RemoveEntityLinkNotificationEvent'> =
{
__typename: NotificationEventType.RemoveEntityLink,
id: 55273,
instance: Instance.De,
date: '2014-03-01T20:45:56Z',
actorId: user.id,
objectId: coursePage.id,
parentId: course.id,
childId: coursePage.id,
}

export const createEntityRevisionNotificationEvent: Model<'CreateEntityRevisionNotificationEvent'> =
{
__typename: NotificationEventType.CreateEntityRevision,
Expand Down
11 changes: 0 additions & 11 deletions __tests__/schema/event-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
createTaxonomyTermNotificationEvent,
createThreadNotificationEvent,
rejectRevisionNotificationEvent,
removeEntityLinkNotificationEvent,
removeTaxonomyLinkNotificationEvent,
setLicenseNotificationEvent,
setTaxonomyParentNotificationEvent,
Expand Down Expand Up @@ -46,7 +45,6 @@ describe('creates event successfully with right payload', () => {
createTaxonomyTermNotificationEvent,
createThreadNotificationEvent,
rejectRevisionNotificationEvent,
removeEntityLinkNotificationEvent,
removeTaxonomyLinkNotificationEvent,
setLicenseNotificationEvent,
setTaxonomyParentNotificationEvent,
Expand Down Expand Up @@ -196,15 +194,6 @@ async function getLastEvent() {
reason
}
... on RemoveEntityLinkNotificationEvent {
parent {
id
}
child {
id
}
}
... on RemoveTaxonomyLinkNotificationEvent {
parent {
id
Expand Down
67 changes: 42 additions & 25 deletions __tests__/schema/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,52 @@ import gql from 'graphql-tag'

import { user } from '../../__fixtures__'
import { Client } from '../__utils__'
import { Service } from '~/context/service'

const query = new Client({ userId: user.id }).prepareQuery({
query: gql`
query {
media {
newUpload(mediaType: IMAGE_PNG) {
uploadUrl
urlAfterUpload
}
}
}
`,
test('returns url for uploading media file', async () => {
const query = setupQuery()
await query.shouldReturnData({
media: {
newUpload: {
uploadUrl: 'http://google.com/upload',
urlAfterUpload: expect.stringMatching(
/https:\/\/assets.serlo.org\/[\d\-a-f]+\/image.png/,
) as unknown,
},
},
})
})

describe('media.upload', () => {
test('returns url for uploading media file', async () => {
await query.shouldReturnData({
media: {
newUpload: {
uploadUrl: 'http://google.com/upload',
urlAfterUpload: expect.stringMatching(
/https:\/\/assets.serlo.org\/[\d\-a-f]+\/image.png/,
) as unknown,
},
test('returns url for uploading media file for Serlo Editor testing', async () => {
const query = setupQuery({ service: Service.SerloEditorTesting })
await query.shouldReturnData({
media: {
newUpload: {
uploadUrl: 'http://google.com/upload',
urlAfterUpload: expect.stringMatching(
/https:\/\/storage.googleapis.com\/serlo-editor-testing\/[\d\-a-f]+.png/,
) as unknown,
},
})
},
})
})

test('fails for unauthenticated user', async () => {
await query.forUnauthenticatedUser().shouldFailWithError('UNAUTHENTICATED')
})
test('fails for unauthenticated user', async () => {
const query = setupQuery()
await query.forUnauthenticatedUser().shouldFailWithError('UNAUTHENTICATED')
})

function setupQuery(options: { service?: Service } = {}) {
return new Client({ userId: user.id, ...options }).prepareQuery({
query: gql`
query {
media {
newUpload(mediaType: IMAGE_PNG) {
uploadUrl
urlAfterUpload
}
}
}
`,
})
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"migrate:run": "packages/db-migrations/scripts/run_migrations.sh",
"migrate:all": "lerna run --stream migrate:all",
"migrate:up": "lerna run --stream migrate:up",
"migrate:build": "lerna run --stream build:all",
"migrate:push-image": "lerna run --stream push-image",
"mysql": "docker compose exec mysql serlo-mysql",
"mysql:delete-last-migration": "yarn mysql --execute 'DELETE FROM migrations ORDER BY id DESC LIMIT 1'",
"mysql:delete-all-migrations": "yarn mysql --execute 'DELETE FROM migrations'",
Expand Down
21 changes: 21 additions & 0 deletions packages/db-migrations/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:20-alpine AS base_image
WORKDIR /app
COPY package.json .
RUN corepack enable
RUN yarn set version 3.x

FROM base_image AS build_migrations
COPY scripts scripts
COPY src src
RUN yarn
RUN yarn build:all

FROM base_image AS runner
RUN yarn plugin import workspace-tools
RUN yarn workspaces focus --production
COPY --from=build_migrations /app/migrations migrations
COPY migrations/package.json migrations/package.json
COPY database.json .

ENTRYPOINT ["yarn", "db-migrate"]
CMD ["up"]
Empty file.
41 changes: 0 additions & 41 deletions packages/db-migrations/__tests__/redis.ts

This file was deleted.

36 changes: 0 additions & 36 deletions packages/db-migrations/__tests__/transformations.ts

This file was deleted.

9 changes: 5 additions & 4 deletions packages/db-migrations/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@serlo/db-migrations",
"version": "1.1.0-staging.2",
"private": true,
"license": "Apache-2.0",
"type": "module",
Expand All @@ -12,6 +13,7 @@
"migrate:run": "scripts/run_migrations.sh",
"migrate:all": "npm-run-all build:all migrate:up",
"migrate:up": "yarn db-migrate -m migrations up",
"push-image": "tsx scripts/push-image.ts",
"new": "./scripts/touch_file.sh",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
},
Expand All @@ -27,10 +29,10 @@
"@types/node": "^18.19.31",
"@types/ramda": "^0.30.0",
"@types/semver": "^7.5.8",
"@types/uuid": "^9.0.8",
"@types/uuid": "^10.0.0",
"depcheck": "^1.4.7",
"dotenv": "^16.4.5",
"esbuild": "^0.20.2",
"esbuild": "^0.21.5",
"fp-ts": "^2.16.5",
"io-ts": "^2.2.21",
"ioredis": "^5.4.1",
Expand All @@ -44,8 +46,7 @@
"ts-node": "^10.9.2",
"ts-unused-exports": "^10.0.1",
"tsx": "^4.9.3",
"typescript": "^5.4.5",
"uuid": "^9.0.1"
"typescript": "^5.4.5"
},
"packageManager": "yarn@3.6.1",
"engines": {
Expand Down
Loading

0 comments on commit a70f4c7

Please sign in to comment.