Test in jenkins - attempt #1

Reviewers: #reviewers

Subscribers: jenkins-user

Differential Revision: https://hub.sealcode.org/D1522
This commit is contained in:
Kuba Orlik 2024-07-04 20:56:50 +02:00
parent ea65ae01a9
commit b46ba714c3
13 changed files with 4756 additions and 71 deletions

View File

@ -1,8 +1,5 @@
{ {
"phabricator.uri": "https://hub.sealcode.org/", "phabricator.uri": "https://hub.sealcode.org/",
"arc.land.onto.default": "master", "arc.land.onto.default": "master",
"load": ["arcanist-linters", "arc-unit-mocha/src"], "load": []
"unit.engine": "MochaEngine",
"unit.mocha.include": ["./lib/**/*.test.js"],
"unit.mocha.dockerRoot": "/opt/sealious-app"
} }

View File

@ -1,13 +1,3 @@
{ {
"linters": { "linters": {}
"prettier": {
"type": "prettier",
"bin": "./node_modules/.bin/prettier",
"include": ["(\\.[tj]sx?$)", "(\\.s?css$)"]
},
"eslint": {
"type": "eslint",
"include": ["(src/.*\\.tsx?$)", "(src/.*\\.js$)"]
}
}
} }

2
.gitignore vendored
View File

@ -43,3 +43,5 @@ src/back/jdd-components/components.ts
src/back/routes/routes.ts src/back/routes/routes.ts
src/back/routes/urls.ts src/back/routes/urls.ts
src/includes.css src/includes.css
.eslint-result.json
lint-report.json

View File

@ -1,2 +1,2 @@
mkdir -p docker_node_modules mkdir -p docker_node_modules
docker-compose up -d docker compose up -d

View File

@ -1,7 +1,7 @@
#!/bin/bash -xe #!/bin/bash -xe
set -e set -e
docker-compose down docker compose down
npm install @sealcode/sealgen npm install @sealcode/sealgen
npx sealgen make-env npx sealgen make-env
@ -10,15 +10,15 @@ cp secrets.example.json secrets.json
export SEALIOUS_PORT="${PORT}0" export SEALIOUS_PORT="${PORT}0"
SEALIOUS_BASE_URL=$(cat .base_url) SEALIOUS_BASE_URL=$(cat .base_url)
export SEALIOUS_BASE_URL export SEALIOUS_BASE_URL
echo "PORT=$PORT" >> .env echo "PORT=$PORT" >>.env
mkdir -p node_modules mkdir -p node_modules
mkdir -p docker_node_modules mkdir -p docker_node_modules
# https://github.com/docker/compose/issues/4725 # https://github.com/docker/compose/issues/4725
docker-compose build docker compose build
docker-compose up -d db docker compose up -d db
./npm.sh --no-TTY ci && ./npm.sh --no-TTY run build ./npm.sh --no-TTY ci && ./npm.sh --no-TTY run build
rm -f log.html rm -f log.html

View File

@ -4,13 +4,31 @@ export SEALIOUS_PORT=$PORT
SEALIOUS_BASE_URL=$(cat .base_url) SEALIOUS_BASE_URL=$(cat .base_url)
export SEALIOUS_BASE_URL export SEALIOUS_BASE_URL
./npm.sh --no-TTY --user="$UID" run typecheck:front ./npm.sh ci --no-progress --no-color
./npm.sh --no-TTY --user="$UID" run typecheck:back ./npm.sh run install-test-deps --no-progress --no-color
./npm.sh run build --no-progress --no-color --ignore-scripts
./npm.sh run typecheck --no-progress --no-color --ignore-scripts
docker-compose run --user="$UID" \ # no need to run build, it's automatically ran after ci
#./npm.sh --no-TTY --user="$UID" run build
./npm.sh run lint-report
node -e 'console.log(JSON.stringify(JSON.parse(fs.readFileSync("./.eslint-result.json")).map(fileResult => fileResult.messages.map(message=>({...message, path: fileResult.filePath.replace("/opt/sealious-app/", "")}))).flat().map(message=>({name: message.ruleId, code: message.ruleId, severity: message.severity==1 ? "warning" : "error", path: message.path, line: message.line, char: message.column, description: message.message}))))' \
>lint-report.json
CONTAINER_ID=$(docker compose run -d --user="$UID" \
-e "SEALIOUS_MONGO_PORT=27017" \ -e "SEALIOUS_MONGO_PORT=27017" \
-e "SEALIOUS_MONGO_HOST=db" \ -e "SEALIOUS_MONGO_HOST=db" \
-e "SEALIOUS_PORT=$SEALIOUS_PORT" \ -e "SEALIOUS_PORT=8080" \
-e "SEALIOUS_BASE_URL=$SEALIOUS_BASE_URL" \ -e "SEALIOUS_BASE_URL=$SEALIOUS_BASE_URL" \
-e "SEALIOUS_SANITY=true" \ -e "SEALIOUS_MAILCATCHER_HOST=mailcatcher" \
test -e "SEALIOUS_MAILCATCHER_API_PORT=1080" \
-e "SEALIOUS_MAILCATCHER_SMTP_PORT=1025" \
-e "WITH_WEBHINT=TRUE" \
-e "FORCE_COLOR=0" \
test npm run test-reports)
docker logs -f $CONTAINER_ID
exit $(docker inspect $CONTAINER_ID --format='{{.State.ExitCode}}')

View File

@ -6,9 +6,9 @@ export SEALIOUS_BASE_URL
./npm.sh --no-TTY --user="$UID" run build:front ./npm.sh --no-TTY --user="$UID" run build:front
docker-compose up -d mailcatcher docker compose up -d mailcatcher
docker-compose run --user="$UID" \ docker compose run --user="$UID" \
-e "SEALIOUS_MONGO_PORT=27017" \ -e "SEALIOUS_MONGO_PORT=27017" \
-e "SEALIOUS_MONGO_HOST=db" \ -e "SEALIOUS_MONGO_HOST=db" \
-e "SEALIOUS_PORT=$SEALIOUS_PORT" \ -e "SEALIOUS_PORT=$SEALIOUS_PORT" \

View File

@ -4,6 +4,5 @@ export SEALIOUS_PORT="${PORT}0"
SEALIOUS_BASE_URL=$(cat .base_url) SEALIOUS_BASE_URL=$(cat .base_url)
export SEALIOUS_BASE_URL export SEALIOUS_BASE_URL
docker-compose down --volumes docker compose down --volumes
rm -rf node_modules rm -rf node_modules

19
package-lock.json generated
View File

@ -14,7 +14,7 @@
"@koa/router": "^12.0.1", "@koa/router": "^12.0.1",
"@sealcode/file-manager": "^1.0.2", "@sealcode/file-manager": "^1.0.2",
"@sealcode/jdd": "^0.4.10", "@sealcode/jdd": "^0.4.10",
"@sealcode/sealgen": "^0.15.30", "@sealcode/sealgen": "^0.15.45",
"@sealcode/ts-predicates": "^0.6.2", "@sealcode/ts-predicates": "^0.6.2",
"@types/kill-port": "^2.0.0", "@types/kill-port": "^2.0.0",
"@types/leaflet": "^1.9.8", "@types/leaflet": "^1.9.8",
@ -844,13 +844,14 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/@sealcode/sealgen": { "node_modules/@sealcode/sealgen": {
"version": "0.15.30", "version": "0.15.45",
"resolved": "https://registry.npmjs.org/@sealcode/sealgen/-/sealgen-0.15.30.tgz", "resolved": "https://registry.npmjs.org/@sealcode/sealgen/-/sealgen-0.15.45.tgz",
"integrity": "sha512-Smj73M9pNhfTgSjP4bwHokU1HTHMdcixgy2fGEO9bDKH/2e19XVGcCUBYHBiFB/i8OBuwJYBcDfH4wt2U/TEUA==", "integrity": "sha512-E4jeaeNaMQvhD8AUc/BzXDr85l6MaON7gHuZxUtEnJ7z0Qogf0UBmMd0HECoUAOPeiGbcTM8aKB0cZ1oJrCpdw==",
"dependencies": { "dependencies": {
"@koa/router": "^12.0.1", "@koa/router": "^12.0.1",
"@sealcode/file-manager": "^1.0.2", "@sealcode/file-manager": "^1.0.2",
"@sealcode/ts-predicates": "^0.4.3", "@sealcode/ts-predicates": "^0.4.3",
"chokidar": "^3.6.0",
"deepmerge": "^4.3.1", "deepmerge": "^4.3.1",
"esbuild": "^0.20.0", "esbuild": "^0.20.0",
"escape-goat": "^4.0.0", "escape-goat": "^4.0.0",
@ -863,7 +864,7 @@
"prettier": "^2.7.1", "prettier": "^2.7.1",
"prompts": "^2.4.2", "prompts": "^2.4.2",
"recursive-readdir": "^2.2.3", "recursive-readdir": "^2.2.3",
"tempstream": "^0.3.4", "tempstream": "^0.4.0",
"tiny-glob": "^0.2.9", "tiny-glob": "^0.2.9",
"ws": "^8.16.0", "ws": "^8.16.0",
"yargs": "^17.6.2" "yargs": "^17.6.2"
@ -882,6 +883,14 @@
"resolved": "https://registry.npmjs.org/@sealcode/ts-predicates/-/ts-predicates-0.4.3.tgz", "resolved": "https://registry.npmjs.org/@sealcode/ts-predicates/-/ts-predicates-0.4.3.tgz",
"integrity": "sha512-UNSEacu7Ye8q0N8AJCJy37oJvv3w2OXKGkUnP7xO5lOY9DQviDPRDQhVaZdJ3/xMzXLm4UE3389ihctrPaov/A==" "integrity": "sha512-UNSEacu7Ye8q0N8AJCJy37oJvv3w2OXKGkUnP7xO5lOY9DQviDPRDQhVaZdJ3/xMzXLm4UE3389ihctrPaov/A=="
}, },
"node_modules/@sealcode/sealgen/node_modules/tempstream": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/tempstream/-/tempstream-0.4.0.tgz",
"integrity": "sha512-NkO6l6LUvZEnxTicz143PbHHHLLJvp8yQy1UgIkNU5S0eGxyf0eKv2C81rAnyrff1Ehk8KzqDOhjaMTa6U0N4w==",
"dependencies": {
"classnames": "^2.5.1"
}
},
"node_modules/@sealcode/ts-predicates": { "node_modules/@sealcode/ts-predicates": {
"version": "0.6.2", "version": "0.6.2",
"license": "ISC", "license": "ISC",

View File

@ -5,25 +5,27 @@
"main": "./dist/back/index.js", "main": "./dist/back/index.js",
"type": "module", "type": "module",
"scripts": { "scripts": {
"start": "docker-compose up -d db && node .", "start": "docker compose up -d db && node .",
"start-watch": "SEALIOUS_PORT=$SEALIOUS_PORT SEALIOUS_BASE_URL=$SEALIOUS_BASE_URL nodemon --enable-source-maps --ignore ./uploaded_files . --ignore ./cache", "start-watch": "SEALIOUS_PORT=$SEALIOUS_PORT SEALIOUS_BASE_URL=$SEALIOUS_BASE_URL nodemon --enable-source-maps --ignore ./uploaded_files --ignore ./cache .",
"typecheck:back": "tsc --noEmit --target es6 --lib es2021,dom -p tsconfig-back.json", "typecheck:back": "tsc --noEmit --target es6 --lib es2021,dom -p tsconfig-back.json",
"typecheck:front": "tsc --noEmit --target es6 --lib es2015,dom -p tsconfig-front.json", "typecheck:front": "tsc --noEmit --target es6 --lib es2021,dom -p tsconfig-front.json",
"typecheck": "npm run typecheck:back && npm run typecheck:front", "typecheck": "npm run typecheck:back && npm run typecheck:front",
"prewatch": "rm -rf dist/* && npm run build --ignore-scripts", "prewatch": "rm -rf dist/* && npm run build --ignore-scripts",
"build": "rm -rf dist && sealgen build ", "build": "rm -rf dist && sealgen build ",
"postbuild": "npm run typecheck && npm run lint", "postbuild": "npm run typecheck && npm run lint",
"watch": "multiple-scripts-tmux -p watch", "watch": "multiple-scripts-tmux -p watch",
"reset-db": "docker-compose down && docker-compose up -d", "reset-db": "docker compose down -v && docker compose up -d",
"install-test-deps": "npx playwright install firefox && cd webhint && npm install && ./use-fork.sh", "install-test-deps": "npx playwright install firefox && cd webhint && npm install && ./use-fork.sh",
"pretest": "npm run build && docker-compose up -d", "pretest": "npm run build && docker compose up -d",
"test": "node test.cjs", "test": "node test.cjs",
"full-test": "WITH_WEBHINT=TRUE npm run test",
"prepare": "npm run build && npm run install-test-deps", "prepare": "npm run build && npm run install-test-deps",
"lint": "eslint src", "lint": "eslint src",
"preinstrument": "npm run build && rm -fr .xunit coverage dist-instrumented", "lint-report": "npm run --silent lint -- --format json > .eslint-result.json",
"preinstrument": "npm run build --ignore-scripts && rm -fr .xunit coverage dist-instrumented",
"instrument": "npx nyc instrument --exclude \"\" dist dist-instrumented", "instrument": "npx nyc instrument --exclude \"\" dist dist-instrumented",
"pretest-reports": "npm run instrument && docker-compose up -d", "pretest-reports": "npm run instrument",
"test-reports": "npx nyc --exclude \"\" ./node_modules/.bin/mocha --recursive --timeout=10000 --require source-map-support/register --reporter xunit --reporter-option output=.xunit 'dist-instrumented/**/*.test.js' --exit && nyc report --reporter clover --exclude \"\"", "test-reports": "npx nyc --exclude \"\" ./node_modules/.bin/mocha --recursive --timeout=10000 --require source-map-support/register 'dist-instrumented/**/*.test.js' --exit && nyc report --reporter cobertura --exclude \"\"",
"precover-html": "rm -rf coverate/lcov-report", "precover-html": "rm -rf coverate/lcov-report",
"cover-html": "npm run test-reports && nyc report --reporter lcov --exclude \"\" && xdg-open coverage/lcov-report/index.html" "cover-html": "npm run test-reports && nyc report --reporter lcov --exclude \"\" && xdg-open coverage/lcov-report/index.html"
}, },
@ -43,7 +45,7 @@
"@koa/router": "^12.0.1", "@koa/router": "^12.0.1",
"@sealcode/file-manager": "^1.0.2", "@sealcode/file-manager": "^1.0.2",
"@sealcode/jdd": "^0.4.10", "@sealcode/jdd": "^0.4.10",
"@sealcode/sealgen": "^0.15.30", "@sealcode/sealgen": "^0.15.45",
"@sealcode/ts-predicates": "^0.6.2", "@sealcode/ts-predicates": "^0.6.2",
"@types/kill-port": "^2.0.0", "@types/kill-port": "^2.0.0",
"@types/leaflet": "^1.9.8", "@types/leaflet": "^1.9.8",

View File

@ -26,6 +26,7 @@ export default new (class HorizontalScrollerDemoPage extends Page {
<div> <div>
<button <button
class="prev-button" class="prev-button"
type="button"
data-action="horizontal-scroller#scrollLeft" data-action="horizontal-scroller#scrollLeft"
> >
{" "} {" "}
@ -33,6 +34,7 @@ export default new (class HorizontalScrollerDemoPage extends Page {
</button> </button>
<button <button
class="next-button" class="next-button"
type="button"
data-action="horizontal-scroller#scrollRight" data-action="horizontal-scroller#scrollRight"
> >
{" "} {" "}

View File

@ -1,8 +1,6 @@
import { withProdApp } from "../test_utils/with-prod-app.js"; import { withProdApp } from "../test_utils/with-prod-app.js";
import { VERY_LONG_TEST_TIMEOUT, webhintURL } from "../test_utils/webhint.js"; import { VERY_LONG_TEST_TIMEOUT, webhintURL } from "../test_utils/webhint.js";
import { HorizontalScrollerDemoURL } from "./urls.js"; import { HorizontalScrollerDemoURL } from "./urls.js";
import { getBrowser } from "../test_utils/browser-creator.js";
import type { Browser, BrowserContext, Page } from "@playwright/test";
describe("HorizontalScrollerDemo webhint", () => { describe("HorizontalScrollerDemo webhint", () => {
it("doesn't crash", async function () { it("doesn't crash", async function () {
@ -16,25 +14,3 @@ describe("HorizontalScrollerDemo webhint", () => {
}); });
}).timeout(VERY_LONG_TEST_TIMEOUT); }).timeout(VERY_LONG_TEST_TIMEOUT);
}); });
describe("HorizontalScrollerDemo", () => {
let page: Page;
let browser: Browser;
let context: BrowserContext;
beforeEach(async () => {
browser = await getBrowser();
context = await browser.newContext();
page = await context.newPage();
});
afterEach(async () => {
await context.close();
});
it("works as expected", async function () {
return withProdApp(async ({ base_url }) => {
await page.goto(base_url + HorizontalScrollerDemoURL);
});
}).timeout(VERY_LONG_TEST_TIMEOUT);
});

4692
webhint/package-lock.json generated

File diff suppressed because it is too large Load Diff