Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by .scripts/generate-dependabot.yml on 'npm run build'
# DO NOT EDIT THIS FILE

version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
root:
patterns:
- '*'
- package-ecosystem: npm
directory: /external-events
schedule:
interval: weekly
groups:
external-events:
patterns:
- '*'
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
workflows:
patterns:
- '*'
79 changes: 48 additions & 31 deletions .scripts/modules.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
const exec = require('@actions/exec');
const path = require('path');
const fs = require('fs');
const chalk = require('chalk');
const exec = require("@actions/exec");
const path = require("path");
const fs = require("fs");
const chalk = require("chalk");

const basedir = path.resolve(__dirname, '../');
const basedir = path.resolve(__dirname, "../");

const serial = (funcs) => funcs.reduce((promise, func) => promise.then((result) => func().then(
Array.prototype.concat.bind(result),
)), Promise.resolve([]));
const serial = (funcs) =>
funcs.reduce(
(promise, func) =>
promise.then((result) =>
func().then(Array.prototype.concat.bind(result))
),
Promise.resolve([])
);

/* eslint-disable no-console */
const execModule = async (dir, commands) => {
const module = path.relative(basedir, dir);
const execCommands = commands instanceof Function ? commands(module) : [commands];
process.env.FORCE_COLOR = 'true';
const execCommands =
commands instanceof Function ? commands(module) : [commands];
process.env.FORCE_COLOR = "true";

const executions = execCommands.map((command) => () => {
let output = chalk.blue(`> ${command}\n`);
return exec.exec(command, '', {
cwd: dir,
silent: true,
listeners: {
stdout: (data) => {
output += data.toString();
return exec
.exec(command, "", {
cwd: dir,
silent: true,
listeners: {
stdout: (data) => {
output += data.toString();
},
stderr: (data) => {
output += data.toString();
},
},
stderr: (data) => {
output += data.toString();
},
},
}).then(() => output)
})
.then(() => output)
.catch((err) => {
output += `${chalk.white.bgRed(`FAILED ${dir}`)} ${err.message}`;
process.exitCode = 1;
Expand All @@ -38,7 +46,7 @@ const execModule = async (dir, commands) => {

await serial(executions).then((outputs) => {
console.group(`${chalk.green(`actions/${module}`)}`);
console.log(outputs.join('\n').trim(), '\n');
console.log(outputs.join("\n").trim(), "\n");
console.groupEnd();

// Fail fast if a task has failed.
Expand All @@ -48,22 +56,31 @@ const execModule = async (dir, commands) => {
});
};

const findModules = () => fs.readdirSync(basedir)
.map((file) => path.join(basedir, file))
.filter((file) => fs.lstatSync(file).isDirectory())
.filter((dir) => fs.existsSync(path.join(dir, 'package.json')))
.sort((a, b) => a.localeCompare(b));
const findModules = () =>
fs
.readdirSync(basedir)
.map((file) => path.join(basedir, file))
.filter((file) => fs.lstatSync(file).isDirectory())
.filter((dir) => fs.existsSync(path.join(dir, "package.json")))
.sort((a, b) => a.localeCompare(b))
.filter((dir) => {
console.log(dir);
return dir.includes("ui-health");
});

const eachModules = (fn) => findModules().forEach(fn);

const execModules = async (commands) => Promise.all(
findModules().map((dir) => execModule(dir, commands)),
);
const execModules = async (commands, exitOnError = true) =>
Promise.all(
findModules().map((dir) => execModule(dir, commands, exitOnError))
);

/* eslint-enable no-console */

module.exports = {
npmArgument: JSON.parse(process.env.npm_config_argv || '{"original": []}').original.join(' '),
npmArgument: JSON.parse(
process.env.npm_config_argv || '{"original": []}'
).original.join(" "),
modules: {
each: eachModules,
exec: execModules,
Expand Down
61 changes: 61 additions & 0 deletions ui-healthcheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# UI Health Check

A simple action, that takes in config and visits by a URL to check
if the UI is up and running.

# Usage

See [action.yml](action.yml)


# Action setup example

.github/workflows/ui-healthcheck.yml

```yaml
name: UI Health Check
on:
workflow_dispatch:
schedule:
- cron: '0 * * * *'

jobs:
prod:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: UI Health Check
uses: extenda/actions/ui-healthcheck@master
with:
config-path: ./ui-health-check-config.yml
```

ui-health-check-config.yml

```yaml
cases:
- name: "Cash Management To Bank"
setup:
url: 'https://testrunner.hiiretail.com/in-store/cash-management/to-bank'
requireLogin: true
expect:
element: '[data-testid="no-data-overlay"]'
toHaveText: 'You can not proceed with this operation. No currencies found'

- name: "Reconciliation till audit"
setup:
url: 'https://testrunner.hiiretail.com/in-store/reconciliation/audit'
requireLogin: true
expect:
element: '[data-testid="page-title"]'
toInclude: 'Audit'

- name: 'Receipt journal'
setup:
url: 'https://testrunner.hiiretail.com/in-store/receipt-journal'
requireLogin: true
expect:
element: '[data-testid="txr-table"]'
to: 'exists' # 'not-exists' | 'be-visible' | 'not-be-visible'
```
19 changes: 19 additions & 0 deletions ui-healthcheck/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: UI Health Check
description: |
A simple action, that takes in config and visits by a URL to check
if the UI is up and running.
author: Extenda Retail
inputs:
config-path:
description: 'Path to the config file'
required: true
default: './config.yaml'
username:
description: 'Username for basic auth'
required: false
password:
description: 'Password for basic auth'
required: false
runs:
using: node16
main: dist/index.js
233 changes: 233 additions & 0 deletions ui-healthcheck/dist/index.js

Large diffs are not rendered by default.

Loading