Prepare for ci

This commit is contained in:
Johannes Zellner 2024-10-22 21:02:19 +02:00
parent 40828825aa
commit 6c9de57937
2 changed files with 21 additions and 12 deletions

View file

@ -3,9 +3,10 @@ FROM cloudron/base:4.2.0@sha256:46da2fffb36353ef714f97ae8e962bd2c212ca091108d768
RUN mkdir -p /app/code /app/pkg
WORKDIR /app/code
ARG VERSION=2.54.1
# renovate: datasource=github-releases depName=prometheus/prometheus versioning=semver extractVersion=^v(?<version>.+)$
ARG PROMETHEUS_VERSION=2.54.1
RUN curl -L https://github.com/prometheus/prometheus/releases/download/v${VERSION}/prometheus-${VERSION}.linux-amd64.tar.gz | tar zxvf - --strip-components 1
RUN curl -L https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz | tar zxvf - --strip-components 1
COPY env.sh.template start.sh /app/pkg/

View file

@ -1,10 +1,6 @@
#!/usr/bin/env node
/* jshint esversion: 8 */
/* global describe */
/* global before */
/* global after */
/* global it */
/* global it, xit, describe, before, after, afterEach */
'use strict';
@ -12,6 +8,7 @@ require('chromedriver');
var execSync = require('child_process').execSync,
expect = require('expect.js'),
fs = require('fs'),
path = require('path'),
{ Builder, By, Key, until } = require('selenium-webdriver'),
{ Options } = require('selenium-webdriver/chrome');
@ -24,7 +21,7 @@ if (!process.env.USERNAME || !process.env.PASSWORD) {
describe('Application life cycle test', function () {
this.timeout(0);
const LOCATION = 'test';
const LOCATION = process.env.LOCATION || 'test';
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
const TEST_TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 50000;
@ -35,16 +32,27 @@ describe('Application life cycle test', function () {
var app;
before(function () {
const options = new Options().windowSize({ width: 1280, height: 1024 });
if (process.env.HEADLESS) options.addArguments('headless');
browser = new Builder().forBrowser('chrome').setChromeOptions(options).build();
const chromeOptions = new Options().windowSize({ width: 1280, height: 1024 });
if (process.env.CI) chromeOptions.addArguments('no-sandbox', 'disable-dev-shm-usage', 'headless');
browser = new Builder().forBrowser('chrome').setChromeOptions(chromeOptions).build();
if (!fs.existsSync('./screenshots')) fs.mkdirSync('./screenshots');
});
after(function () {
browser.quit();
});
afterEach(async function () {
if (!process.env.CI || !app) return;
const currentUrl = await browser.getCurrentUrl();
if (!currentUrl.includes(app.domain)) return;
expect(this.currentTest.title).to.be.a('string');
const screenshotData = await browser.takeScreenshot();
fs.writeFileSync(`./screenshots/${new Date().getTime()}-${this.currentTest.title.replaceAll(' ', '_')}.png`, screenshotData, 'base64');
});
async function waitForElement(elem) {
await browser.wait(until.elementLocated(elem), TEST_TIMEOUT);
await browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);