Skip to content

Commit

Permalink
Merge pull request #542 from serlo/staging
Browse files Browse the repository at this point in the history
Deployment
  • Loading branch information
kulla authored Oct 9, 2023
2 parents 5811575 + 5cd1a8e commit 932d209
Show file tree
Hide file tree
Showing 232 changed files with 1,122 additions and 1,533 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@ jobs:
yarn:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: yarn test

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: yarn build --env production

eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: yarn lint:eslint

prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: yarn lint:prettier

tsc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: yarn lint:tsc
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: yarn deploy --env ${GITHUB_REF_NAME}
env:
Expand Down
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 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 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/msw-npm-1.2.5-3e875e19ed-652c44a100.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 removed .yarn/cache/pump-npm-3.0.0-0080bf6a7a-e42e9229fb.zip
Binary file not shown.
Binary file removed .yarn/cache/rc-npm-1.2.8-d6768ac936-2e26e052f8.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.
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,6 @@ In this case the url / file must end with the extension `.md`.
Without this file extension it is assumed that the returned file contains the page's body in HTML format.

The content of the static pages are automatically sanitized (e.g. potentially malicious JavaScript content is automatically removed).
In case you need a link which deactivates Google Analytics use the string `JS-GOOGLE-ANALYTICS-DEACTIVATE` as the `href` attribute:

```html
<a href="JS-GOOGLE-ANALYTICS-DEACTIVATE">
Click here to deactivate Google Analytics
</a>
```

To include an iframe where the user can opt out from Matomo use the string `MATOMO-OPT-OUT-FORM`:

```markdown
Use the following form to opt out from Matomo:

MATOMO-OPT-OUT-FORM
```

## Preview Images

Expand Down
1 change: 0 additions & 1 deletion __tests__/__utils__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ export * from './test-environment'

export enum Backend {
Frontend = 'frontend',
Legacy = 'legacy',
}
1 change: 0 additions & 1 deletion __tests__/__utils__/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './api'
export * from './database'
export * from './frontend'
export * from './serlo'
export * from './utils'
56 changes: 0 additions & 56 deletions __tests__/__utils__/services/serlo.ts

This file was deleted.

98 changes: 0 additions & 98 deletions __tests__/frontend-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ test('No redirect for subjects', async () => {
await expectFrontend(response)
})

test('Uses legacy frontend when cookie "useLegacyFrontend" is "true"', async () => {
const env = currentTestEnvironment()
const request = env.createRequest({ subdomain: 'en' })

request.headers.append('Cookie', 'useLegacyFrontend=true;')

await expectLegacy(await env.fetchRequest(request))
})

test('chooses frontend when request contains content api parameter', async () => {
givenUuid({
id: 1555,
Expand All @@ -57,33 +48,6 @@ test('chooses frontend when request contains content api parameter', async () =>
await expectFrontend(response)
})

describe('when request contains header X-From: legacy-serlo.org', () => {
let response: Response

beforeEach(async () => {
// TODO: Delete
// setupProbabilityFor(Backend.Frontend)

response = await currentTestEnvironment().fetch(
{
subdomain: 'en',
pathname: '/',
},
{ headers: { 'X-From': 'legacy-serlo.org' } },
)
})

test('chooses legacy backend', async () => {
await expectLegacy(response)
})

test('does not set cookie with random number', () => {
expect(response.headers.get('Set-Cookie')).not.toEqual(
expect.stringContaining('useFrontend'),
)
})
})

test('reports to sentry when frontend responded with redirect', async () => {
givenFrontend(redirectsTo('https://frontend.serlo.org/'))
mockHttpGet('https://frontend.serlo.org/', returnsText('Hello World'))
Expand Down Expand Up @@ -126,68 +90,6 @@ test('creates a copy of backend responses (otherwise there is an error in cloudf
expect(response).not.toBe(backendResponse)
})

describe('requests to /enable-frontend enable use of frontend', () => {
let response: Response

beforeEach(async () => {
response = await currentTestEnvironment().fetch({
subdomain: 'en',
pathname: '/enable-frontend',
})
})

test('shows message that frontend was enabled', async () => {
expect(response.status).toBe(200)
expect(await response.text()).toBe('Enabled: Use of new frontend')
})

test('sets cookie so that new frontend will be used', () => {
expect(response.headers.get('Set-Cookie')).toEqual(
expect.stringContaining('useLegacyFrontend=false;'),
)
})

test('main page will be loaded after 1 second', () => {
expect(response.headers.get('Refresh')).toBe('1; url=/')
})
})

describe('requests to /disable-frontend disable use of frontend', () => {
let response: Response

beforeEach(async () => {
response = await currentTestEnvironment().fetch({
subdomain: 'en',
pathname: '/disable-frontend',
})
})

test('shows message that frontend use is disabled', async () => {
expect(response.status).toBe(200)
expect(await response.text()).toBe('Disabled: Use of new frontend')
})

test('sets cookie to that legacy backend will be used', () => {
expect(response.headers.get('Set-Cookie')).toEqual(
expect.stringContaining('useLegacyFrontend=true;'),
)
})

test('main page will be loaded after 1 second', () => {
expect(response.headers.get('Refresh')).toBe('1; url=/')
})
})

async function expectLegacy(response: Response) {
expect(await response.text()).toEqual(
expect.stringContaining('<html class="fuelux"'),
)
// Tests that backend headers are transferred to client
expect(response.headers.get('x-powered-by')).toEqual(
expect.stringContaining('PHP'),
)
}

async function expectFrontend(response: Response) {
expect(await response.text()).toEqual(
expect.stringContaining('<script id="__NEXT_DATA__"'),
Expand Down
24 changes: 0 additions & 24 deletions __tests__/metadata-api.ts

This file was deleted.

3 changes: 0 additions & 3 deletions jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import {
currentTestEnvironment,
defaultApiServer,
defaultFrontendServer,
defaultSerloServer,
getDefaultCFEnvironment,
givenApi,
givenFrontend,
givenSerlo,
Uuid,
} from './__tests__/__utils__'

Expand All @@ -34,7 +32,6 @@ beforeEach(() => {

givenApi(defaultApiServer())
givenFrontend(defaultFrontendServer())
givenSerlo(defaultSerloServer())

globalThis.sentryEvents = []
mockSentryServer()
Expand Down
53 changes: 26 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"_prettier": "prettier .",
"build": "wrangler deploy --dry-run --outdir=dist",
"check:all": "scripts/run_all_checks.sh",
"check:unused-dependencies": "depcheck",
"check:unused-exports": "ts-unused-exports tsconfig.json --excludePathsFromReport=__tests__/__utils__/index.ts",
"deploy": "wrangler deploy",
"dev": "wrangler dev --env staging",
"format": "run-s --continue-on-error \"format:*\"",
Expand All @@ -23,53 +25,50 @@
"lint:eslint": "yarn _eslint",
"lint:prettier": "yarn _prettier --check",
"lint:tsc": "tsc --noEmit",
"show-unused-exports": "ts-unused-exports tsconfig.json --excludePathsFromReport=__tests__/__utils__/index.ts",
"test": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
"test:production": "cross-env TEST_ENVIRONMENT=production yarn test --runInBand",
"test:staging": "cross-env TEST_ENVIRONMENT=staging yarn test --runInBand"
},
"dependencies": {
"fp-ts": "^2.16.1",
"io-ts": "^2.2.20",
"jose": "^4.14.4",
"marked": "^7.0.5",
"preact": "^10.17.1",
"jose": "^4.15.1",
"marked": "^9.0.3",
"preact": "^10.18.0",
"preact-render-to-string": "^6.2.1",
"sanitize-html": "^2.11.0",
"toucan-js": "^3.2.2"
"toucan-js": "^3.3.0"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20230821.0",
"@cloudflare/workers-types": "^4.20231002.0",
"@iarna/toml": "^2.2.5",
"@jest/globals": "^29.6.4",
"@sentry/types": "^7.64.0",
"@testing-library/jest-dom": "^6.1.2",
"@testing-library/preact": "^3.2.3",
"@types/iarna__toml": "^2.0.2",
"@types/jest": "^29.5.4",
"@types/marked": "^5.0.1",
"@types/node": "^18.17.12",
"@types/sanitize-html": "^2.9.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@jest/globals": "^29.7.0",
"@sentry/types": "^7.72.0",
"@testing-library/jest-dom": "^6.1.3",
"@types/iarna__toml": "^2.0.3",
"@types/jest": "^29.5.5",
"@types/marked": "^5.0.2",
"@types/node": "^18.18.1",
"@types/sanitize-html": "^2.9.1",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"cross-env": "^7.0.3",
"eslint": "^8.48.0",
"depcheck": "^1.4.6",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-react": "^7.33.2",
"glob": "^10.3.3",
"jest": "^29.6.4",
"msw": "^1.2.5",
"nodemon": "^3.0.1",
"jest": "^29.7.0",
"msw": "^1.3.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.2",
"prettier-plugin-packagejson": "^2.4.5",
"prettier": "^3.0.3",
"prettier-plugin-packagejson": "^2.4.6",
"prettier-plugin-sh": "^0.13.1",
"ts-jest": "^29.1.1",
"ts-unused-exports": "^10.0.0",
"ts-unused-exports": "^10.0.1",
"typescript": "^5.2.2",
"wrangler": "^3.6.0"
"wrangler": "^3.10.1"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
Loading

0 comments on commit 932d209

Please sign in to comment.