Skip to content

Commit

Permalink
Merge branch 'feature/distributed-demo' into authdemo
Browse files Browse the repository at this point in the history
  • Loading branch information
astitva1905 authored Feb 15, 2024
2 parents 2e5c8dc + 5e795ef commit ab84395
Show file tree
Hide file tree
Showing 45 changed files with 6,576 additions and 307 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,33 @@ jobs:
with:
files: client/coverage/clover.xml
flags: client-unit-integration-tests

get_version:
name: Get version
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install jq
run: sudo apt-get install -y jq
- name: get version
id: get_version
run: |
version=`cat ./client/package.json | jq -r '.version'`
echo "version=$version" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.get_version.outputs.version }}

publish-docker-image:
if: |
github.event_name == 'push' &&
(startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/release-v'))
name: Publish Docker image
needs: [client, get_version]
uses: ./.github/workflows/docker.yml
with:
registry: ghcr.io
image-name: into-cps-association/dtaas-web
version: ${{ needs.get_version.outputs.version }}
dockerfile: client.dockerfile
46 changes: 46 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Push Docker Image

on:
workflow_call:
inputs:
registry:
required: false
type: string
default: 'ghcr.io'
image-name:
required: true
type: string
version:
required: true
type: string
default: 'latest'
dockerfile:
required: true
type: string

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/${{ inputs.dockerfile }}
push: true
tags: ${{ inputs.registry }}/${{ inputs.image-name }}:${{ inputs.version }}
46 changes: 45 additions & 1 deletion .github/workflows/lib-ms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: "yarn"
cache-dependency-path: "**/yarn.lock"

# - name: Install pm2
# run: |
# npm install -g pm2

- name: Run the linting checks
run: |
cd servers/lib
Expand All @@ -43,6 +47,7 @@ jobs:
run: |
cd servers/lib
yarn install
yarn build
yarn test:all
env:
PORT: 4001
Expand All @@ -51,6 +56,19 @@ jobs:
LOG_LEVEL: debug
APOLLO_PATH: /lib

# - name: Run http mode tests
# run: |
# cd servers/lib
# yarn install
# yarn build
# yarn test:http-github
# env:
# PORT: 4002
# LOCAL_PATH: ${{ github.workspace }}/files
# MODE: local
# LOG_LEVEL: debug
# APOLLO_PATH: /lib

- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down Expand Up @@ -92,3 +110,29 @@ jobs:
yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

get_version:
name: Get version
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install jq
run: sudo apt-get install -y jq
- name: get version
id: get_version
run: |
version=`cat ./client/package.json | jq -r '.version'`
echo "version=$version" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.get_version.outputs.version }}

publish-docker-image:
name: Publish Docker image
needs: [ publish-package, get_version]
uses: ./.github/workflows/docker.yml
with:
registry: ghcr.io
image-name: into-cps-association/dtaas-libms
version: ${{ needs.get_version.outputs.version }}
dockerfile: libms.dockerfile
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ repos:
files: "^servers/execution/runner/.*"
args: ["-c", "cd servers/execution/runner && yarn test:nocov"]
stages: [pre-push]
# - id: yarn-test-lib
# name: yarn test lib
# entry: bash
# language: system
# files: "^servers/lib/.*"
# args: ["-c", "cd servers/lib && yarn jest . --coverage=false"]
# stages: [pre-push]
- id: yarn-test-lib
name: yarn test lib
entry: bash
language: system
files: "^servers/lib/.*"
args: ["-c", "cd servers/lib && yarn test:nocov"]
stages: [pre-push]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
Expand Down
3 changes: 3 additions & 0 deletions client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*/node_modules
*/build
*/test
2 changes: 0 additions & 2 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ window.env = {
REACT_APP_URL_BASENAME: '',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
Expand All @@ -121,7 +120,6 @@ window.env = {
REACT_APP_URL_BASENAME: 'au',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
Expand Down
1 change: 0 additions & 1 deletion client/config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if (typeof window !== 'undefined') {
REACT_APP_URL_BASENAME: 'dtaas',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
Expand Down
1 change: 0 additions & 1 deletion client/config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if (typeof window !== 'undefined') {
REACT_APP_URL_BASENAME: 'dtaas',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
Expand Down
1 change: 0 additions & 1 deletion client/config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if (typeof window !== 'undefined') {
REACT_APP_URL_BASENAME: '',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
Expand Down
1 change: 0 additions & 1 deletion client/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ declare global {
REACT_APP_URL_BASENAME: string;
REACT_APP_URL_DTLINK: string;
REACT_APP_URL_LIBLINK: string;
REACT_APP_WORKBENCHLINK_TERMINAL: string;
REACT_APP_WORKBENCHLINK_VNCDESKTOP: string;
REACT_APP_WORKBENCHLINK_VSCODE: string;
REACT_APP_WORKBENCHLINK_JUPYTERLAB: string;
Expand Down
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@into-cps-association/dtaas-web",
"version": "0.3.1",
"version": "0.3.2",
"description": "Web client for Digital Twin as a Service (DTaaS)",
"main": "index.tsx",
"author": "prasadtalasila <[email protected]> (http://prasad.talasila.in/)",
Expand Down Expand Up @@ -89,7 +89,7 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"playwright": "^1.32.1",
"prettier": "3.1.0",
"prettier": "^3.2.4",
"shx": "^0.3.4",
"ts-jest": "^29.1.1"
},
Expand Down
5 changes: 0 additions & 5 deletions client/src/components/LinkIconsLib.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import TerminalOutlinedIcon from '@mui/icons-material/TerminalOutlined';
import DesktopWindowsOutlinedIcon from '@mui/icons-material/DesktopWindowsOutlined';
import CodeOutlinedIcon from '@mui/icons-material/CodeOutlined';
import ScienceOutlinedIcon from '@mui/icons-material/ScienceOutlined';
Expand All @@ -11,10 +10,6 @@ type LinkIconsType = {
};

const LinkIcons: LinkIconsType = {
TERMINAL: {
icon: <TerminalOutlinedIcon />,
name: 'Terminal',
},
VNCDESKTOP: {
icon: <DesktopWindowsOutlinedIcon />,
name: 'Desktop',
Expand Down
2 changes: 0 additions & 2 deletions client/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ window.env = {
REACT_APP_URL_BASENAME: '',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
Expand Down Expand Up @@ -142,7 +141,6 @@ window.env = {
REACT_APP_URL_BASENAME: '',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
Expand Down
9 changes: 4 additions & 5 deletions client/test/unitTests/Components/Linkbuttons.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ import userEvent from '@testing-library/user-event';
jest.deepUnmock('components/LinkButtons');

const buttons: KeyLinkPair[] = [
{ key: 'TERMINAL', link: 'https://example.com/terminal' },
{ key: 'VNCDESKTOP', link: 'https://example.com/desktop' },
{ key: 'NO_ICON', link: 'https://example.com/noicon' },
];

const getButton = (key: string) =>
screen.getByRole('link', { name: `${LinkIcons[key].name ?? key}-btn` });
screen.getByRole('link', { name: `${LinkIcons[key]?.name ?? key}-btn` });

const getLabel = (key: string) =>
screen.getByRole('heading', { level: 6, name: LinkIcons[key].name ?? key });
screen.getByRole('heading', { level: 6, name: LinkIcons[key]?.name ?? key });

const getButtonIcon = (key: string) =>
screen.getByTitle(`${LinkIcons[key].name ?? key}-btn`).children[0];
screen.getByTitle(`${LinkIcons[key]?.name ?? key}-btn`).children[0];

const evaluateButtonSize = (expectedSize: number) => {
buttons.forEach((button) => {
Expand Down Expand Up @@ -66,7 +65,7 @@ describe('LinkButtons component default size', () => {

it('should use name from iconLib as label when avaiable', () => {
expect(getLabel(buttons[0].key).textContent).toBe(
LinkIcons[buttons[0].key].name,
LinkIcons[buttons[0].key]?.name,
);
});
});
Expand Down
17 changes: 5 additions & 12 deletions client/test/unitTests/Util/envUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ describe('envUtil', () => {
const testLIB = '';
const testAppURL = 'https://example.com';
const testBasename = 'testBasename';
const testWorkbenchEndpoints = [
'one',
'/two',
'three/',
'/four/',
'/five/guy/',
];
const testWorkbenchEndpoints = ['one', '/two', 'three/', '/four/postfix'];
const testUsername = 'username';
const testAppID = 'testAppID';
const testAuthority = 'https://example.com';
Expand All @@ -34,11 +28,10 @@ describe('envUtil', () => {
REACT_APP_URL_BASENAME: testBasename,
REACT_APP_URL_DTLINK: testDT,
REACT_APP_URL_LIBLINK: testLIB,
REACT_APP_WORKBENCHLINK_TERMINAL: testWorkbenchEndpoints[0],
REACT_APP_WORKBENCHLINK_VNCDESKTOP: testWorkbenchEndpoints[1],
REACT_APP_WORKBENCHLINK_VSCODE: testWorkbenchEndpoints[2],
REACT_APP_WORKBENCHLINK_JUPYTERLAB: testWorkbenchEndpoints[3],
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: testWorkbenchEndpoints[4],
REACT_APP_WORKBENCHLINK_VNCDESKTOP: testWorkbenchEndpoints[0],
REACT_APP_WORKBENCHLINK_VSCODE: testWorkbenchEndpoints[1],
REACT_APP_WORKBENCHLINK_JUPYTERLAB: testWorkbenchEndpoints[2],
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: testWorkbenchEndpoints[3],

REACT_APP_CLIENT_ID: testAppID,
REACT_APP_AUTH_AUTHORITY: testAuthority,
Expand Down
Loading

0 comments on commit ab84395

Please sign in to comment.