add ci files

This commit is contained in:
Girish Ramakrishnan 2024-10-09 09:08:28 +02:00
parent 9c4088e812
commit 9b773524ce
2 changed files with 24 additions and 28 deletions

5
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,5 @@
include:
- project: devops/pipeline-components
ref: main
file: cloudron-app.gitlab-ci.yml

View file

@ -1,11 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
/* jshint esversion: 8 */ /* jshint esversion: 8 */
/* global it:false */ /* global it, xit, describe, before, after, afterEach */
/* global xit:false */
/* global describe:false */
/* global before:false */
/* global after:false */
'use strict'; 'use strict';
@ -29,21 +25,23 @@ describe('Application life cycle test', function () {
const TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000; const TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000;
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
const LOCATION = 'test'; const LOCATION = process.env.LOCATION || 'test';
const SSH_PORT = 29420; const SSH_PORT = 29420;
let app, browser; let app, browser;
var athenticated_by_oidc = false; let athenticated_by_oidc = false;
const repodir = '/tmp/testrepo'; const repodir = '/tmp/testrepo';
const reponame = 'testrepo'; const reponame = 'testrepo';
const username = process.env.USERNAME; const username = process.env.USERNAME;
const password = process.env.PASSWORD; const password = process.env.PASSWORD;
const email = process.env.EMAIL;
before(function () { before(function () {
browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).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 () { after(function () {
@ -51,8 +49,19 @@ describe('Application life cycle test', function () {
fs.rmSync(repodir, { recursive: true, force: true }); fs.rmSync(repodir, { recursive: true, force: true });
}); });
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');
});
function getAppInfo() { function getAppInfo() {
var inspect = JSON.parse(execSync('cloudron inspect')); const inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location.indexOf(LOCATION) === 0; })[0]; app = inspect.apps.filter(function (a) { return a.location.indexOf(LOCATION) === 0; })[0];
expect(app).to.be.an('object'); expect(app).to.be.an('object');
} }
@ -147,25 +156,7 @@ describe('Application life cycle test', function () {
await browser.wait(until.elementLocated(By.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT); await browser.wait(until.elementLocated(By.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT);
} }
async function addPublicKeyOld() {
var publicKey = fs.readFileSync(__dirname + '/id_ed25519.pub', 'utf8');
await browser.get('https://' + app.fqdn + '/user/settings/keys');
await browser.wait(until.elementLocated(By.id('add-ssh-button')), TIMEOUT);
await browser.findElement(By.id('add-ssh-button')).click();
await browser.findElement(By.id('ssh-key-title')).sendKeys('testkey');
await browser.findElement(By.id('ssh-key-content')).sendKeys(publicKey.trim()); // #3480
var button = browser.findElement(By.xpath('//button[contains(text(), "Add Key")]'));
await browser.executeScript('arguments[0].scrollIntoView(false)', button);
await browser.findElement(By.xpath('//button[contains(text(), "Add Key") and contains(@class, "green")]')).click();
await browser.wait(until.elementLocated(By.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT);
}
async function createRepo() { async function createRepo() {
var getRepoPage = await browser.get('https://' + app.fqdn + '/repo/create');
await browser.findElement(By.id('repo_name')).sendKeys(reponame); await browser.findElement(By.id('repo_name')).sendKeys(reponame);
var button = browser.findElement(By.xpath('//button[contains(text(), "Create Repository")]')); var button = browser.findElement(By.xpath('//button[contains(text(), "Create Repository")]'));
await browser.executeScript('arguments[0].scrollIntoView(true)', button); await browser.executeScript('arguments[0].scrollIntoView(true)', button);