Skip to content
Snippets Groups Projects
Verified Commit b6f236e8 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: wip

parent ee266127
No related branches found
No related tags found
No related merge requests found
......@@ -19,13 +19,12 @@ stages:
after_script:
- if [ -f .env-gitlab-ci ]; then rm .env-gitlab-ci; fi
test:
tests:
stage: test
tags:
- nixos-gen3
script:
- nix develop .#gitlab --command run-ci-tests
# cahe node_modules
cache:
untracked: true
key:
......@@ -34,13 +33,12 @@ test:
paths:
- node_modules/
web-test:
web-tests:
stage: test
tags:
- nixos-gen3
script:
- nix develop .#gitlab --command run-ci-tests
# cahe node_modules
- nix develop .#gitlab --command run-web-tests
cache:
untracked: true
key:
......
{
"nodes": {
"common": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1,
"narHash": "sha256-VjRoAeu0HhpiJ/oCup7JyT8IEgO+CwLkxCTno3UwAK8=",
"path": "./common",
"type": "path"
},
"original": {
"path": "./common",
"type": "path"
}
},
"devFlakes": {
"inputs": {
"common": "common",
"git-commit": "git-commit",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1715272075,
"narHash": "sha256-AzweeNBIAnYohoBx6NXmSy7aayFr0H1DfEFvDnHIaLY=",
"ref": "refs/heads/master",
"rev": "4a30b23f6580958ff5e06af5534f03228f7be631",
"revCount": 28,
"type": "git",
"url": "https://gitlab.schukai.com/schukai/entwicklung/nix-flakes.git"
},
"original": {
"type": "git",
"url": "https://gitlab.schukai.com/schukai/entwicklung/nix-flakes.git"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"git-commit": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1,
"narHash": "sha256-8hXrOA8SKy//ctoL1poIhJwuT7G4rvVu7FguROzEoDg=",
"path": "./git-commit",
"type": "path"
},
"original": {
"path": "./git-commit",
"type": "path"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1714971268,
"narHash": "sha256-IKwMSwHj9+ec660l+I4tki/1NRoeGpyA2GdtdYpAgEw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "27c13997bf450a01219899f5a83bd6ffbfc70d3c",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-23.11",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1704874635,
"narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-23.11",
"type": "indirect"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1715106579,
"narHash": "sha256-gZMgKEGiK6YrwGBiccZ1gemiUwjsZ1Zv49KYOgmX2fY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8be0d8a1ed4f96d99b09aa616e2afd47acc3da89",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-23.11",
"type": "indirect"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1715542476,
"narHash": "sha256-FF593AtlzQqa8JpzrXyRws4CeKbc5W86o8tHt4nRfIg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "44072e24566c5bcc0b7aa9178a0104f4cfffab19",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1704145853,
"narHash": "sha256-G/1AMt9ibpeMlcxvD1vNaC8imGaK+g7zZ99e29BLgWw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2d2ea8eab9e400618748ab1a6a108255233b602c",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-23.11",
"type": "indirect"
}
},
"root": {
"inputs": {
"devFlakes": "devFlakes",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_4",
"version": "version"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"version": {
"inputs": {
"nixpkgs": "nixpkgs_5"
},
"locked": {
"lastModified": 1715522646,
"narHash": "sha256-Cljp1vlqLuvP5oqvFZGwbZ0ypWnLkK2t+0qDe+rX13E=",
"ref": "refs/heads/master",
"rev": "abd140ed98b8ecb71212f388260a40c8ef0e2426",
"revCount": 122,
"type": "git",
"url": "https://gitlab.schukai.com/oss/utilities/version.git"
},
"original": {
"type": "git",
"url": "https://gitlab.schukai.com/oss/utilities/version.git"
}
}
},
"root": "root",
"version": 7
}
......@@ -4,8 +4,8 @@
inputs = {
nixpkgs = {url = "github:nixos/nixpkgs/nixos-23.11";};
flake-utils = {url = "github:numtide/flake-utils";};
version = {url = "git+https://gitlab.schukai.com/oss/utilities/version.git/";};
devFlakes = {url = "git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes.git/";};
version = {url = "git+https://gitlab.schukai.com/oss/utilities/version.git";};
devFlakes = {url = "git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes.git";};
};
outputs = {
......@@ -96,13 +96,9 @@
echo_ok "Node modules are already installed"
else
echo_fail "Node modules are not installed, run task init-project"
exit 1
fi
export PLAYWRIGHT_BROWSERS_PATH="${pkgs'.playwright.browsers}"
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
echo_section "Happy hacking!"
'';
};
......
......@@ -34,5 +34,4 @@ with pkgs'; [
wget
zlib
]
......@@ -8,7 +8,8 @@
script-init-project = pkgs.callPackage ./init-project.nix {inherit commonScript versionBin;};
script-build-stylesheets = pkgs.callPackage ./build-stylesheets.nix {inherit commonScript versionBin;};
script-build-and-publish = pkgs.callPackage ./build-and-publish.nix {inherit commonScript versionBin;};
script-run-tests = pkgs.callPackage ./run-tests.nix {inherit commonScript versionBin;};
script-run-tests = pkgs.callPackage ./run-tests.nix {inherit commonScript;};
script-run-web-tests = pkgs.callPackage ./run-web-tests.nix {inherit commonScript;};
taskfile = pkgs.writeTextFile {
name = "taskfile.yml";
......@@ -72,6 +73,16 @@
cmds:
- ${script-run-tests}/bin/run-tests
run-web-tests:
silent: true
aliases:
- rt
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
desc: Run the tests
cmds:
- ${script-run-web-tests}/bin/run-web-tests
build-and-publish:
silent: true
aliases:
......
{
pkgs,
lib,
commonScript,
...
}: let
in
pkgs.writeShellScriptBin "run-web-tests" ''
source ${commonScript}
echo_section "run web tests"
echo_hint "This script will run web tests in the current working directory."
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
if ! ${pkgs.nodejs_21}/bin/node "$(pwd)/test/web/puppeteer.mjs" --browser ${pkgs.ungoogled-chromium}/bin/chromium --path "$(pwd)/test/web/test.html"
then
echo_fail "Tests failed, check your JS!"
exit 1
fi
exit 0
''
import { chromium } from 'playwright';
import path from 'path';
import { fileURLToPath } from 'url';
// Nötig, um __dirname in ES-Modulen zu verwenden
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
(async () => {
// Starten Sie den Browser
const browser = await chromium.launch({ headless: false }); // Setzen Sie headless auf false, um den Browser sichtbar zu machen
const page = await browser.newPage();
// Navigieren Sie zur lokalen HTML-Datei
const filePath = path.resolve(__dirname, 'test.html');
const fileUrl = 'file://' + filePath;
await page.goto(fileUrl);
// Überprüfen Sie den Titel der Seite
const title = await page.title();
console.log(`Title: ${title}`);
// Machen Sie einen Screenshot
await page.screenshot({ path: 'example.png' });
// Browser schließen
await browser.close();
})();
import path from "path";
import puppeteer from 'puppeteer';
// args auswerten mit --path und --browser, get from args
const args = process.argv;
const config = {};
for (let i = 0; i < args.length; i++) {
if (args[i] === '--path') {
config.path = args[i + 1];
}
if (args[i] === '--browser') {
config.browser = args[i + 1];
}
}
if (!config.path) {
console.error('Path is required, please provide --path');
process.exit(1);
}
if (!config.browser) {
console.error('Browser is required, please provide --browser');
process.exit(1);
}
(async () => {
// Launch the browser and open a new blank page
const browser = await puppeteer.launch({
headless: 'new',
});
const page = await browser.newPage();
// Navigate the page to a URL
const filePath = path.resolve(__dirname, 'test.html');
const fileUrl = 'file://' + filePath;
headless: 'new', // if you want to see the browser, set this to false
executablePath: config.browser,
args: ['--no-sandbox'],
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36',
});
const page = await browser.newPage();
const fileUrl = 'file://' + config.path;
await page.goto(fileUrl);
const searchResultSelector = '#mocha-done';
await page.waitForSelector(searchResultSelector);
// Set screen size
await page.setViewport({width: 1080, height: 1024});
await page.waitForFunction('document.getElementById("mocha-done").textContent.length > 0');
// Type into search box
await page.type('.devsite-search-field', 'automate beyond recorder');
const passes = await page.evaluate(() => document.getElementById('mocha-stats').querySelector('li.passes').textContent);
const failures = await page.evaluate(() => document.getElementById('mocha-stats').querySelector('li.failures').textContent);
const duration = await page.evaluate(() => document.getElementById('mocha-stats').querySelector('li.duration').textContent);
// Wait and click on first result
const searchResultSelector = '.devsite-result-item-link';
await page.waitForSelector(searchResultSelector);
await page.click(searchResultSelector);
const error = await page.evaluate(() => document.getElementById('mocha-errors').textContent);
// Locate the full title with a unique string
const textSelector = await page.waitForSelector(
'text/Customize and automate'
);
const fullTitle = await textSelector?.evaluate(el => el.textContent);
console.log('Tests passed:', passes);
console.log('Tests failed:', failures);
console.log('Duration:', duration);
// Print the full title
console.log('The title of this blog post is "%s".', fullTitle);
if (error.length > 0) {
console.error('Tests failed: ', error);
} else {
console.log('Tests passed');
}
await browser.close();
})();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment