Skip to content

Commit

Permalink
Merge branch 'dev' into feat(support-submodel-element-list-spike)
Browse files Browse the repository at this point in the history
  • Loading branch information
XAlinaGS committed Dec 17, 2024
2 parents 210916e + 9e185af commit b7280fe
Show file tree
Hide file tree
Showing 9 changed files with 1,164 additions and 129 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @GailMelanie @hofermo @JonathanXITASO @pawel-baran-se @XAlinaGS @Xmilofranke @NilsXitaso
17 changes: 0 additions & 17 deletions .github/workflows/autoAddReviewer.yaml

This file was deleted.

129 changes: 103 additions & 26 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ name: Docker

on:
push:
branches: [ '**' ]
tags: [ 'v*.*.*' ]
branches: ['main', 'dev', 'staging']
tags: ['v*.*.*']
pull_request:
branches: [ '**' ]
branches: ['main', 'dev', 'staging']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# github.repository as <account>/<repo>
Expand All @@ -17,51 +21,124 @@ env:
REGISTRY_PASS: ${{ secrets.DOCKER_API_TOKEN }}

jobs:
default:
name: build, test and push image
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Extract branch name
id: extract_branch
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT

- name: Checkout repository
uses: actions/checkout@v4

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into docker hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASS }}

- name: Test units
- name: Run unit tests
id: test_units
run: yarn install && npx jest

build-browser-image:
name: Build browser image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Build image
id: build
run: docker compose build mnestix-browser

- name: E2E test
- name: Save mnestix-browser image
run: docker save mnestix/mnestix-browser:latest -o mnestix-browser.tar

- name: Upload mnestix-browser artifact
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: mnestix-browser
path: mnestix-browser.tar

e2e-tests:
name: e2e test matrix
runs-on: ubuntu-latest
needs: ['build-browser-image']
permissions:
contents: read
strategy:
fail-fast: false
matrix:
# add more containers to run more tests in parallel
containers: [1, 2, 3, 4]

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

- name: Download mnestix-browser artifact
uses: actions/download-artifact@v4
with:
name: mnestix-browser

- name: Load mnestix-browser image
run: docker load -i mnestix-browser.tar

# image too big to be reused
- name: prepare tests
run: |
docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests build cypress-test
docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests pull
- name: Run e2e tests
id: test
run: docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests up -d &&
run: |
docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests up -d &&
docker compose -f compose.yml -f docker-compose/compose.test.yml attach cypress-test
env:
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}

- name: E2E test collect artifact
id: test_artifact
if: always()
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: cypress-artifacts
name: cypress-artifacts-${{ matrix.containers }}
path: cypress-artifacts/

push-image:
name: Push image to registry
needs: ['build-browser-image', 'unit-tests', 'e2e-tests']
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/dev'
permissions:
contents: read
packages: write

steps:
- name: Extract branch name
id: extract_branch
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT

- name: Checkout repository
uses: actions/checkout@v4

- name: Download mnestix-browser artifact
uses: actions/download-artifact@v4
with:
name: mnestix-browser

- name: Load mnestix-browser image
run: docker load -i mnestix-browser.tar

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into docker hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASS }}

- name: Push Image to Production
id: push-prod
if: github.ref == 'refs/heads/main'
Expand Down
5 changes: 5 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'cypress';
import * as dotenv from 'dotenv';
import cypressSplit from 'cypress-split';

dotenv.config();

Expand All @@ -21,6 +22,10 @@ export default defineConfig({
excludeSpecPattern: '**/ignoredTestFiles/*.js',
specPattern: 'cypress/e2e/**/*.spec.{js,jsx,ts,tsx}',
experimentalRunAllSpecs: true,
setupNodeEvents(on, config) {
cypressSplit(on, config);
return config;
},
},
env: {
AAS_REPO_API_URL: 'http://localhost:5064/repo',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import resolutions from '../fixtures/resolutions.json';
// intentionally named a_ to run this test in first batch
import resolutions from '../fixtures/resolutions.json';
import testAAS from '../fixtures/testAAS.json';
import AASBomComponent from '../fixtures/cypress_e2e/cyTestAas_BoM_Component.json';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import resolutions from '../fixtures/resolutions.json';
// intentionally named z_ to run this test in last batch
import resolutions from '../fixtures/resolutions.json';
import compareAAS from '../fixtures/cypress_e2e/CompareMockData/cy_compareAas.json';

describe('Test compare feature view', function () {
Expand Down Expand Up @@ -163,28 +164,23 @@ describe('Test compare feature view', function () {

it('Clicking the image of an AAS in compare view redirects to the detail page', function () {
cy.setResolution(resolutions[0]);

// go to compare view with all three test data
const url = `/compare?aasId=${compareAAS[0].id}&aasId=${compareAAS[1].id}&aasId=${compareAAS[2].id}`;
cy.visit(url);
cy.getByTestId('compare-aas-2').should('be.visible');

// click second image
cy.getByTestId('compare-aas-1')
.findByTestId('image-with-fallback')
.click();

cy.getByTestId('compare-aas-1').findByTestId('image-with-fallback').click();

// check if url is correct
const b64Url = btoa(compareAAS[1].id)
.replace(/=*$/, '');
const b64Url = btoa(compareAAS[1].id).replace(/=*$/, '');
cy.url().should('contain', `/viewer/${b64Url}`);

// check if loaded aas id is correct
cy.getByTestId('aas-data')
.findByTestId('data-row-value')
.should('contain', compareAAS[1].id);
cy.getByTestId('aas-data').findByTestId('data-row-value').should('contain', compareAAS[1].id);
});

after(function () {
cy.deleteCompareMockData();
});
Expand Down
6 changes: 4 additions & 2 deletions docker-compose/compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
cypress-test:
container_name: cypress-test
profiles: ["", "tests"]
profiles: ['', 'tests']
build:
dockerfile: cypress.dockerfile
environment:
Expand All @@ -12,6 +12,8 @@ services:
CYPRESS_AAS_DISCOVERY_API_URL: 'http://mnestix-api:5064/discovery'
MNESTIX_BACKEND_API_KEY: ${MNESTIX_BACKEND_API_KEY:-verySecureApiKey}
ELECTRON_ENABLE_LOGGING: 1
SPLIT: ${SPLIT:-0}
SPLIT_INDEX: ${SPLIT_INDEX:-0}
volumes:
- ./cypress-artifacts/screenshots:/cypress_Tests/cypress/screenshots
- ./cypress-artifacts/videos:/cypress_Tests/cypress/videos
Expand All @@ -28,4 +30,4 @@ services:
AAS_REPO_API_URL: 'http://mnestix-api:5064/repo'
SUBMODEL_REPO_API_URL: 'http://mnestix-api:5064/repo'
DISCOVERY_API_URL: 'http://mnestix-api:5064/discovery'
MNESTIX_BACKEND_API_URL: 'http://mnestix-api:5064'
MNESTIX_BACKEND_API_URL: 'http://mnestix-api:5064'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"cypress": "^13.8.0",
"cypress-junit-reporter": "^1.3.1",
"cypress-msal-login": "^2.0.1",
"cypress-split": "^1.24.7",
"dotenv": "^16.4.5",
"eslint-config-next": "14.2.3",
"eslint-plugin-cypress": "^3.0.0",
Expand Down
Loading

0 comments on commit b7280fe

Please sign in to comment.