Skip to content

Commit

Permalink
Merge pull request #751 from catenax-ng/main
Browse files Browse the repository at this point in the history
feature: - #652 add GitHub action to publish Swagger to Swaggerhub
  • Loading branch information
ds-mmaul authored Mar 18, 2024
2 parents eeda3f5 + 3da22bd commit 9b640e8
Show file tree
Hide file tree
Showing 30 changed files with 1,236 additions and 1,144 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/publish-swagger-hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Publish OpenAPI to Swaggerhub"

on:
workflow_call:
inputs:
version:
required: true
description: Version that will be published to Swaggerhub
type: string

jobs:
swagger-api:
runs-on: ubuntu-latest
env:
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }}
SWAGGERHUB_USER: ${{ secrets.SWAGGERHUB_USER }}
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup node
uses: actions/setup-node@v4

- name: Install Swagger CLI
run: |
npm i -g swaggerhub-cli
- name: Extract versions
run: |
export VERSION="${{ inputs.version }}"
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
# create API, will fail if exists
- name: Create API
continue-on-error: true
run: |
swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/trace-x/${{ env.VERSION }} -f tx-backend/openapi/traceability-foss-backend.json --visibility=public --published=unpublish
# Post the API to SwaggerHub as "unpublished", because published APIs cannot be overwritten
- name: Publish API Specs to SwaggerHub
run: |
if [[ ${{ env.VERSION }} != *-SNAPSHOT ]]; then
echo "[INFO] - no snapshot, will set the API to 'published'";
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/trace-x/${{ env.VERSION }} -f tx-backend/openapi/traceability-foss-backend.json --visibility=public --published=publish
swaggerhub api:setdefault ${{ env.SWAGGERHUB_USER }}/trace-x/${{ env.VERSION }}
else
echo "[INFO] - snapshot, will set the API to 'unpublished'";
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/trace-x/${{ env.VERSION }} -f tx-backend/openapi/traceability-foss-backend.json --visibility=public --published=unpublish
fi
13 changes: 9 additions & 4 deletions .github/workflows/pull-request_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
review-message: "Please add a short description of the feature/fix to the Changelog.md."
Check-Pom-update:
Check-Pom-for-snapshot-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
Expand All @@ -56,8 +56,8 @@ jobs:
- name: Check pom for -SNAPSHOT
id: pom-version
run: |
snapshot_count_root_pom=$(grep -o '\-SNAPSHOT' pom.xml | wc -l)
if [ "$snapshot_count_root_pom" > 1 ]; then
snapshot_count_root_pom=$(sed -n '/<properties>/,/properties>/p' pom.xml | grep -o '\-SNAPSHOT' | wc -l)
if (( $snapshot_count_root_pom > 1 )); then
echo "pom_changed=true" >> $GITHUB_OUTPUT
else
echo "pom_changed=false" >> $GITHUB_OUTPUT
Expand All @@ -68,7 +68,12 @@ jobs:
if: steps.pom-version.outputs.pom_changed == 'true'
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
review-message: "Please remove -SNAPSHOT from property versions "
review-message: "Please remove -SNAPSHOT from property versions. You can find them in pom.xml(tx-root)."

- name: Print environment variables
id: print-env-vars
run: |
echo ${{steps.pom-version.outputs.pom_changed}}
Test-and-Sonar:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,14 @@ jobs:
with:
version: ${{ github.ref_name }}
secrets: inherit

publish-to-swaggerhub:
name: "Publish OpenAPI spec to Swaggerhub"
permissions:
contents: read
needs:
- release
uses: ./.github/workflows/publish-swagger-hub.yml
with:
version: ${{ github.ref_name }}
secrets: inherit
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- Added a PostConstruct method in PolicyStartUpConfig to allow Integration tests to run without errors in stack traces.
- #536 added new ImportState to asset PUBLISHED_TO_CORE_SERVICES indicating edc assets and dtr shells were created for given asset
- #536 added cron job responsible to publish assets in PUBLISHED_TO_CORE_SERVICES import state to edc and dtr
- #652 add GitHub action to publish Swagger to Swaggerhub

### Changed
- Updated RELEASE.md to the latest release guide (added more steps)
Expand All @@ -38,6 +39,11 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- Bumped shedlock from 5.11.0 to 5.12.0
- Overridden transitive commons-compress version by 1.26.1 to fix CVE-2024-26308
- Overridden transitive commons-codec version by 1.16.1 to fix CVE-2024-26308
- Update irs-registry-client from version 1.6.0-SNAPSHOT to 1.6.0
- Updated review-message for check pom for -SNAPSHOT workflow
- Changed base image from eclipse-temurin:17-jre-alpine to eclipse-temurin:21-jre-alpine
- Changed build image from maven:3-openjdk-17-slim to maven:3-openjdk-18-slim
- #742 rework test management strategy for frontend and backend part

### Removed
- #625 Removed the header and breadcrumbs section from app layout
Expand Down
2 changes: 1 addition & 1 deletion DOCKER_NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DockerHub Backend: https://hub.docker.com/r/tractusx/traceability-foss
- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/traceability-foss/blob/main/LICENSE)

**Used base image**
- [eclipse-temurin:20-jre-alpine](https://github.com/adoptium/containers)
- [eclipse-temurin:21-jre-alpine](https://github.com/adoptium/containers)
- Official Eclipse Temurin DockerHub page: https://hub.docker.com/_/eclipse-temurin
- Eclipse Temurin Project: https://projects.eclipse.org/projects/adoptium.temurin
- Additional information about the Eclipse Temurin images: https://github.com/docker-library/repo-info/tree/master/repos/eclipse-temurin
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# * SPDX-License-Identifier: Apache-2.0

# Dependencies
FROM maven:3-openjdk-17-slim AS maven
FROM maven:3-openjdk-18-slim AS maven
ARG BUILD_TARGET=tx-backend

# Create Working Directory
Expand All @@ -39,7 +39,7 @@ COPY tx-backend tx-backend
RUN --mount=type=cache,target=/root/.m2 mvn -B clean package -pl :$BUILD_TARGET -am -DskipTests

# Copy the jar and build image
FROM eclipse-temurin:17-jre-alpine@sha256:c26a727c4883eb73d32351be8bacb3e70f390c2c94f078dc493495ed93c60c2f AS traceability-app
FROM eclipse-temurin:21-jre-alpine@sha256:fb4150a30569aadae9d693d949684a00653411528e62498b9900940c9b5b8a66 AS traceability-app

ARG UID=10000
ARG GID=1000
Expand Down
43 changes: 8 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
- [Getting started](https://github.com/eclipse-tractusx/traceability-foss/#getting-started)
- [Application authentication](https://github.com/eclipse-tractusx/traceability-foss/#application-authentication)
- [Application architecture & patterns](https://github.com/eclipse-tractusx/traceability-foss/#application-architecture--patterns)
- [User guide](https://github.com/eclipse-tractusx/traceability-foss/#user-guide)
- [User guide](#user-guide)
- [Frontend Testing strategy](#frontend-testing-strategy)
- [The backend application](https://github.com/eclipse-tractusx/traceability-foss/#the-backend-application)
- [Prerequisites](https://github.com/eclipse-tractusx/traceability-foss/#backend-prerequisites)
- [Installation](https://github.com/eclipse-tractusx/traceability-foss/#backend-installation)
- [Running tests](https://github.com/eclipse-tractusx/traceability-foss/#running-tests)
- [Unit tests](https://github.com/eclipse-tractusx/traceability-foss/#unit-tests)
- [Integration tests](https://github.com/eclipse-tractusx/traceability-foss/#integration-tests)
- [Running all tests](https://github.com/eclipse-tractusx/traceability-foss/#running-all-tests)
- [Backend Testing strategy](#backend-testing-strategy)
- [API documentation](https://github.com/eclipse-tractusx/traceability-foss/#api-documentation)
- [Container Image](https://github.com/eclipse-tractusx/traceability-foss/#container-image)
- [License](https://github.com/eclipse-tractusx/traceability-foss/#license)
Expand Down Expand Up @@ -104,6 +102,9 @@ so that you end up with a well-structured app.

A detailed [explanation](https://github.com/eclipse-tractusx/traceability-foss/blob/main/docs/src/docs/user/user-manual.adoc) of how to use the application.

### Frontend Testing Strategy
See [TESTING](frontend/TESTING.md).

## The backend application

### Backend Prerequisites
Expand All @@ -115,36 +116,8 @@ A detailed [explanation](https://github.com/eclipse-tractusx/traceability-foss/b

* see [Installation guide](https://github.com/eclipse-tractusx/traceability-foss/blob/main/tx-backend/INSTALL.md)

### Running tests

#### Unit tests

To run unit tests invoke following command:

```sh
mvn clean test
```

#### Integration tests

Product Traceability FOSS Backend relies on [Testcontainers library](https://www.testcontainers.org/) in order to provide
persistence layer, thus [Docker Engine](https://docs.docker.com/engine/) is required to be running.

To run integration tests via command line, invoke following command:

```sh
mvn -pl tx-models,tx-backend,tx-coverage -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B verify
```

#### Running all tests

To run all tests invoke following command:

```sh
mvn -DskipTests=false clean verify
```

*Please note that this task depends on `integrationTest` task, so it's required to have [Docker Engine](https://docs.docker.com/engine/) running.*
### Backend Testing Strategy
See [TESTING](tx-backend/TESTING.md).

## API documentation
The project follows [OpenAPI Specification](https://swagger.io/specification/) in order to document implemented REST Endpoints. The documentation can be found under [/openapi directory](https://github.com/eclipse-tractusx/traceability-foss/blob/main/tx-backend/openapi/traceability-foss-backend.json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This section describes user interaction when publishing assets fails due to EDC or DTR error ( for example services are unavailable )

[plantuml,target=import-report-receive,format=svg]
[plantuml,target=publish-assets-error,format=svg]
....
include::../../../../uml-diagrams/arc42/runtime-view/data-provisioning/publish-assets-error.puml[]
....
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This section describes user interaction when publishing assets

[plantuml,target=import-report-receive,format=svg]
[plantuml,target=publish-assets,format=svg]
....
include::../../../../uml-diagrams/arc42/runtime-view/data-provisioning/publish-assets.puml[]
....
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In this example, the user requests an import report.
include::../../../../uml-diagrams/arc42/runtime-view/data-provisioning/import-report-receive.puml[]
....

==== Overview
== Overview

When a user requests an import report, TraceX-FOSS checks if the user has an adequate role ('ROLE_ADMIN', 'ROLE_SUPERVISOR').
If yes, then the endpoint returns an import report to the given importJobId.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class QualityNotification {
closeReason: String;
acceptReason: String;
declineReason: String;
notifications: Map<String, QualityNotificationMessage>;
messages: List<QualityNotificationMessage>;
}

class QualityNotificationId {
Expand All @@ -30,6 +30,23 @@ enum QualityNotificationSide{
class BPN{
bpn: String;
}
class QualityNotificationMessage {
id: String
createdBy: String
createdByName: String
sendTo: String
sendToName: String
contractAgreementId: String
notificationReferenceId: String
targetDate: Instant
severity: QualityNotificationSeverity;
edcNotificationId: String;
created: LocalDateTime;
updated: LocalDateTime;
messageId: String;
status: QualityNotificationStatus;
errorMessage: String;
}

enum QualityNotificationStatus{
CREATED(QualityNotificationSide.SENDER, emptySet()),
Expand All @@ -42,9 +59,10 @@ enum QualityNotificationStatus{
CLOSED(QualityNotificationSide.SENDER, of(QualityNotificationSide.SENDER, QualityNotificationSide.RECEIVER));
}

QualityNotification *-- QualityNotificationId
QualityNotification *-- BPN
QualityNotification *-- QualityNotificationStatus
QualityNotification *-- QualityNotificationSide
QualityNotification --> QualityNotificationId
QualityNotification --> BPN
QualityNotification --> QualityNotificationStatus
QualityNotification --> QualityNotificationSide
QualityNotification *-- QualityNotificationMessage
@enduml

14 changes: 12 additions & 2 deletions frontend/E2E.md → frontend/TESTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
## E2E tests
# Frontend Testing Strategy

We use Cypress as e2e testing framework (https://www.cypress.io/) + https://www.npmjs.com/package/@cypress/schematic.
## Unit Tests
Unit tests are executed automatically during the GitHub workflow
[Unit Tests Frontend](.github/workflows/unit-test_frontend.yml)

#### Test Reports
https://sonarcloud.io/project/overview?id=eclipse-tractusx_traceability-foss-frontend
[sonar-scan-frontend.yml](./workflows/sonar-scan-frontend.yml)

## E2E tests with Cypress

We use Cypress as e2e testing framework [Cypress](https://www.cypress.io/) and [npmjs](https://www.npmjs.com/package/@cypress/schematic).

To be able to use Behavior-driven development (BDD) approach we have configured additional lib: https://github.com/badeball/cypress-cucumber-preprocessor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ <h4 class="policies-label">{{'publisher.policyToApply' | i18n}}:</h4>
<mat-error *ngIf="policyFormControl.invalid">{{'publisher.selectPolicyError' | i18n}}</mat-error>
</mat-form-field>

<div class="publish-action-container" [style.cursor]="checkForNonTransientPart() ? 'not-allowed' : 'default'">
<div class="publish-action-container" [style.cursor]="checkForIllegalAssetStateToPublish() ? 'not-allowed' : 'default'">
<div class="detail--action--button"
matTooltip="{{'routing.nonTransientPart' | i18n}}"
matTooltip="{{'routing.illegalAssetStateToPublish' | i18n}}"
matTooltipClass="table--header--tooltip"
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="1000"
[matTooltipDisabled]="!checkForNonTransientPart()"
[matTooltipDisabled]="!checkForIllegalAssetStateToPublish()"
>
<app-button variant="raised"
class="custom-button_import"
color="primary"
[isDisabled]="policyFormControl.invalid || checkForNonTransientPart()"
[isDisabled]="policyFormControl.invalid || checkForIllegalAssetStateToPublish()"
(click)="publish()">
{{'publisher.publish' | i18n}}
</app-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class AssetPublisherComponent {
})
}

checkForNonTransientPart(): boolean {
return this.selectedAssets.some(part => part.importState !== ImportState.TRANSIENT)
checkForIllegalAssetStateToPublish(): boolean {
return this.selectedAssets.some(part => (part.importState !== ImportState.TRANSIENT && part.importState !== ImportState.ERROR))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ <h3>{{ 'table.noResultFound' | i18n }}</h3>
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="1000"
matTooltipDisabled="{{labelId?.startsWith('dashboard')}}"
matTooltipDisabled="{{labelId?.startsWith('dashboard') || (!tableConfig?.sortableColumns?.[column])}}"
[mat-sort-header]="tableConfig.sortableColumns?.[column] ? '' : null"
[disabled]="!tableConfig.sortableColumns?.[column]"
mat-header-cell
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"notAllowedForAsPlanned": "Diese Funktion ist für Produkte im Lebenszyklus \"AsPlanned\" nicht verfügbar.",
"noChildPartsForInvestigation": "Diese Funktion ist für Produkte ohne Bauteile nicht verfügbar.",
"noCustomerAsPlannedParts": "Produkte von Kunden im Lebenszyklus \"AsPlanned\" sind nicht verfügbar.",
"nonTransientPart": "Ein oder mehrere ausgewählte Produkte befinden sich nicht im erforderlichen Importstatus \"TRANSIENT\".",
"illegalAssetStateToPublish": "Ein oder mehrere ausgewählte Produkte befinden sich nicht im erforderlichen Importstatus \"TRANSIENT\" oder \"ERROR\".",
"adminContract": "Verträge"
},
"pageTitle": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"notAllowedForAsPlanned": "This function is not available for Parts in the Lifecycle \"AsPlanned\".",
"noChildPartsForInvestigation": "This function is not available for Parts without components.",
"noCustomerAsPlannedParts": "Customer parts in lifecycle \"AsPlanned\" are not available.",
"nonTransientPart": "One or more selected parts are not in the required import state \"TRANSIENT\".",
"illegalAssetStateToPublish": "One or more selected parts are not in the required import state \"TRANSIENT\" or \"ERROR\".",
"adminContract": "Contracts"
},
"pageTitle": {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SPDX-License-Identifier: Apache-2.0
<maven-site-plugin.version>4.0.0-M11</maven-site-plugin.version>
<edc-library.version>0.2.1</edc-library.version>
<!-- versions for 3rd party dependecies -->
<eclipse-dash-ip.version>0.0.1-SNAPSHOT</eclipse-dash-ip.version>
<eclipse-dash-ip.version>1.0.2</eclipse-dash-ip.version>
<nimbus-jose-jwt.version>9.37.3</nimbus-jose-jwt.version>
<ascii-doctor-j-diagram.version>2.2.13</ascii-doctor-j-diagram.version>
<ascii-dcotor-j.version>2.5.8</ascii-dcotor-j.version>
Expand Down Expand Up @@ -100,7 +100,7 @@ SPDX-License-Identifier: Apache-2.0
<jackson.version>2.15.2</jackson.version>
<junit-bom.version>5.9.3</junit-bom.version>
<awaitility.version>3.0.0</awaitility.version>
<irs-client-lib.version>1.6.0-SNAPSHOT</irs-client-lib.version>
<irs-client-lib.version>1.6.0</irs-client-lib.version>
<json-schema-validator.version>5.4.0</json-schema-validator.version>
<!-- Sonar related properties -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
Expand Down
Loading

0 comments on commit 9b640e8

Please sign in to comment.