Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
59 changes: 46 additions & 13 deletions .github/workflows/test-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,53 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install Yarn
run: npm install -g yarn
- name: Install Yarn
run: npm install -g yarn

- name: Install Dependencies
run: |
yarn install
- name: Install Docker Compose
run: |
sudo apt-get update && sudo apt-get install -y docker-compose

- name: Build
run: |
yarn test
- name: Restore Docker Image Cache
id: restore-cache
uses: actions/cache@v3
with:
path: /tmp/docker-image-cache
key: ${{ runner.os }}-docker-${{ hashFiles('**/ci/docker-compose.yml') }}

- name: Load Cached Docker Images
if: steps.restore-cache.outputs.cache-hit == 'true'
run: |
echo "Loading cached Docker images..."
for tar in /tmp/docker-image-cache/*.tar; do
echo "Loading $tar"
docker load -i "$tar"
done

- name: Install Dependencies
run: yarn install

- name: Pull Docker Images
run: docker-compose -f ci/docker-compose.yml pull

- name: Save Docker Images to Cache
run: |
mkdir -p /tmp/docker-image-cache
echo "Saving Docker images to cache..."
# List images related to your project; adjust the grep pattern as needed.
docker images --format '{{.Repository}}:{{.Tag}}' | grep "eclipsebasyx" > /tmp/docker-image-cache/images.txt
while IFS= read -r img; do
tarname=$(echo $img | tr '/:' '_').tar
echo "Saving image $img to /tmp/docker-image-cache/$tarname"
docker save "$img" -o /tmp/docker-image-cache/"$tarname"
done < /tmp/docker-image-cache/images.txt

- name: Run Tests
run: yarn test
89 changes: 89 additions & 0 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
services:
# AAS Repository
aas-repository:
image: eclipsebasyx/aas-repository:2.0.0-milestone-05
container_name: aas-repository
ports:
- '8081:8081'
environment:
# Service Configuration
SERVER_PORT: 8081
BASYX_BACKEND: "InMemory"
BASYX_CORS_ALLOWED_ORIGINS: "*"
BASYX_CORS_ALLOWED_METHODS: "GET, POST, PATCH, DELETE, PUT, OPTIONS, HEAD"

# Submodel Repository
submodel-repository:
image: eclipsebasyx/submodel-repository:2.0.0-milestone-05
container_name: submodel-repository
ports:
- '8082:8081'
environment:
# Service Configuration
SERVER_PORT: 8081
BASYX_BACKEND: "InMemory"
BASYX_CORS_ALLOWED_ORIGINS: "*"
BASYX_CORS_ALLOWED_METHODS: "GET, POST, PATCH, DELETE, PUT, OPTIONS, HEAD"

# Concept Description Repository
cd-repository:
image: eclipsebasyx/conceptdescription-repository:2.0.0-milestone-05
container_name: cd-repository
ports:
- '8083:8081'
environment:
# Service Configuration
SERVER_PORT: 8081
BASYX_BACKEND: "InMemory"
BASYX_CORS_ALLOWED_ORIGINS: "*"
BASYX_CORS_ALLOWED_METHODS: "GET, POST, PATCH, DELETE, PUT, OPTIONS, HEAD"

# AAS Registry
aas-registry:
image: eclipsebasyx/aas-registry-log-mem:2.0.0-milestone-05
container_name: aas-registry
ports:
- '8084:8080'
environment:
# Service Configuration
SERVER_PORT: 8080
BASYX_CORS_ALLOWED_ORIGINS: "*"
BASYX_CORS_ALLOWED_METHODS: "GET, POST, PATCH, DELETE, PUT, OPTIONS, HEAD"

# Submodel Registry
sm-registry:
image: eclipsebasyx/submodel-registry-log-mem:2.0.0-milestone-05
container_name: sm-registry
ports:
- '8085:8080'
environment:
# Service Configuration
SERVER_PORT: 8080
BASYX_CORS_ALLOWED_ORIGINS: "*"
BASYX_CORS_ALLOWED_METHODS: "GET, POST, PATCH, DELETE, PUT, OPTIONS, HEAD"

# AAS Discovery
aas-discovery:
image: eclipsebasyx/aas-discovery:2.0.0-milestone-05
container_name: aas-discovery
ports:
- '8086:8081'
environment:
# Service Configuration
SERVER_PORT: 8081
BASYX_BACKEND: "InMemory"
BASYX_CORS_ALLOWED_ORIGINS: "*"
BASYX_CORS_ALLOWED_METHODS: "GET, POST, PATCH, DELETE, PUT, OPTIONS, HEAD"

# AASX File Server
aasx-file-server:
image: eclipsebasyx/aasxfileserver:2.0.0-milestone-05
container_name: aasx-file-server
ports:
- '8087:8081'
environment:
# Service Configuration
SERVER_PORT: 8081
BASYX_BACKEND: "InMemory"
BASYX_CORS_ALLOWED_ORIGINS: "*"
BASYX_CORS_ALLOWED_METHODS: "GET, POST, PATCH, DELETE, PUT, OPTIONS, HEAD"
41 changes: 41 additions & 0 deletions ci/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { execSync } from 'child_process';
import path from 'path';

async function waitForContainer(containerName: string, timeoutMs = 300000, intervalMs = 1000): Promise<void> {
const start = Date.now();
while (Date.now() - start < timeoutMs) {
try {
const output = execSync(`docker inspect --format='{{json .State.Health.Status}}' ${containerName}`)
.toString()
.trim();
if (output.includes('healthy')) {
console.log(`${containerName} is healthy.`);
return;
}
} catch {
// Container might not be ready yet
console.warn(`Waiting for ${containerName} to become healthy...`);
}
await new Promise((resolve) => setTimeout(resolve, intervalMs));
}
throw new Error(`Timeout waiting for ${containerName} to become healthy.`);
}

export default async () => {
try {
const composeFilePath = path.join(process.cwd(), 'ci/docker-compose.yml');
execSync(`docker-compose -f ${composeFilePath} up -d`, { stdio: 'inherit' });

// Wait for the desired containers to be healthy.
await waitForContainer('aas-registry');
await waitForContainer('submodel-repository');
await waitForContainer('cd-repository');
await waitForContainer('aas-repository');
await waitForContainer('sm-registry');
await waitForContainer('aas-discovery');
await waitForContainer('aasx-file-server');
} catch (error) {
console.error('Error starting Docker containers:', error);
process.exit(1);
}
};
7 changes: 7 additions & 0 deletions ci/globalTeardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { execSync } from 'child_process';
import path from 'path';

export default async () => {
const composeFilePath = path.join(process.cwd(), 'ci/docker-compose.yml');
execSync(`docker-compose -f ${composeFilePath} down`, { stdio: 'inherit' });
};
45 changes: 34 additions & 11 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }],
},
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['json', 'lcov', 'text', 'clover'],
coveragePathIgnorePatterns: ['<rootDir>/src/generated/'],
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/', '<rootDir>/bundle/'],
projects: [
{
displayName: 'unit-tests',
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/unit-tests/**/*.test.ts'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }],
},
coveragePathIgnorePatterns: ['<rootDir>/src/generated/'],
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/', '<rootDir>/bundle/'],
},
{
displayName: 'integration-tests',
preset: 'ts-jest',
testEnvironment: 'node',
globalSetup: './ci/globalSetup.ts',
globalTeardown: './ci/globalTeardown.ts',
testMatch: ['**/integration-tests/**/*.test.ts'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }],
},
coveragePathIgnorePatterns: ['<rootDir>/src/generated/'],
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/', '<rootDir>/bundle/'],
},
],
};
1 change: 0 additions & 1 deletion openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defaultPlugins, defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
client: '@hey-api/client-fetch',
input: './openapi/Plattform_i40-Entire-API-Collection-V3.0.3-resolved.yaml',
output: {
format: 'prettier',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"lint:check": "eslint ./",
"lint:fix": "eslint --fix ./",
"test": "jest --coverage",
"start": "ts-node -r tsconfig-paths/register src/testFunctions.ts"
"docs": "typedoc --options typedoc.json"
},
"dependencies": {
"@hey-api/client-fetch": "^0.7.0"
Expand Down Expand Up @@ -55,6 +55,7 @@
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typedoc": "^0.28.1",
"typescript": "^5.7.3",
"typescript-eslint": "^8.21.0"
}
Expand Down
Loading