From 0855422d946ae193e3c11fdd20745395c9814df6 Mon Sep 17 00:00:00 2001 From: pweick Date: Tue, 16 Apr 2024 13:41:03 +0200 Subject: [PATCH 01/18] feat(release):[#335] Added workflow to automate release --- .github/workflows/jira-publish-release.yaml | 75 -------- .github/workflows/release.yaml | 27 ++- .github/workflows/update-docs-for-release.yml | 169 ++++++++++++++++++ 3 files changed, 180 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/jira-publish-release.yaml create mode 100644 .github/workflows/update-docs-for-release.yml diff --git a/.github/workflows/jira-publish-release.yaml b/.github/workflows/jira-publish-release.yaml deleted file mode 100644 index dc442b3705..0000000000 --- a/.github/workflows/jira-publish-release.yaml +++ /dev/null @@ -1,75 +0,0 @@ -name: Jira release publishing - -on: - workflow_dispatch: # Trigger manually - inputs: - version: - required: true - type: string - description: Version that will be released in Jira, eg. 2.0.0 - workflow_call: - inputs: - version: - required: true - type: string - description: Version that will be released in Jira, eg. 2.0.0 -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set current date as env variable - run: echo "NOW=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - - name: Echo current date - run: echo $NOW - - - name: Get Version Id Of Release - env: - JIRA_USERNAME: ${{ secrets.RELEASE_IRS_JIRA_USERNAME }} - JIRA_PASSWORD: ${{ secrets.RELEASE_IRS_JIRA_PASSWORD }} - run: | - echo "versionId=$(curl --request GET --url 'https://jira.catena-x.net/rest/api/latest/project/10211/versions' \ - --user $JIRA_USERNAME:$JIRA_PASSWORD --header 'Accept: application/json' | jq -r '.[] | select(.name == "NEXT_RELEASE").id')" >> $GITHUB_ENV - - name: Echo versionId to release - run: echo Exported $versionId as version id to release - - - name: Release Version in Jira - env: - JIRA_USERNAME: ${{ secrets.RELEASE_IRS_JIRA_USERNAME }} - JIRA_PASSWORD: ${{ secrets.RELEASE_IRS_JIRA_PASSWORD }} - VERSION: ${{ github.event.inputs.version }} - VERSION_ID: ${{ env.versionId }} - RELEASE_DATE: ${{ env.NOW }} - run: | - curl --request PUT --url "https://jira.catena-x.net/rest/api/latest/version/$VERSION_ID" \ - --user $JIRA_USERNAME:$JIRA_PASSWORD \ - --header 'Accept: application/json' \ - --header 'Content-Type: application/json' \ - --data "{ - \"archived\": false, - \"description\": \"$VERSION\", - \"id\": $VERSION_ID, - \"name\": \"$VERSION\", - \"releaseDate\": \"$RELEASE_DATE\", - \"released\": true, - \"overdue\": false, - \"projectId\": 10211 - }" - - - name: Create NEXT_RELEASE Version in Jira - env: - JIRA_USERNAME: ${{ secrets.RELEASE_IRS_JIRA_USERNAME }} - JIRA_PASSWORD: ${{ secrets.RELEASE_IRS_JIRA_PASSWORD }} - run: | - curl --request POST --url 'https://jira.catena-x.net/rest/api/latest/version' \ - --user $JIRA_USERNAME:$JIRA_PASSWORD \ - --header 'Accept: application/json' \ - --header 'Content-Type: application/json' \ - --data '{ - "archived": false, - "name": "NEXT_RELEASE", - "projectId": 10211, - "released": false - }' \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 788ffd87b0..985543932e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,10 +1,12 @@ name: Release IRS on: - workflow_dispatch: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' + workflow_call: + inputs: + irs-version: + description: 'New IRS version' + required: true + type: string jobs: release: @@ -18,7 +20,7 @@ jobs: - name: Update Chart.yaml appVersion uses: mikefarah/yq@v4.40.5 with: - cmd: yq -i eval '.appVersion = "${{ github.ref_name }}"' charts/item-relationship-service/Chart.yaml + cmd: yq -i eval '.appVersion = "${{ inputs.irs-version }}"' charts/item-relationship-service/Chart.yaml - name: Update Chart.yaml version uses: mikefarah/yq@v4.40.5 @@ -46,22 +48,15 @@ jobs: run: | EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) echo "CHANGELOG<<$EOF" >> $GITHUB_ENV - sed -n -e '/## \[${{ github.ref_name }}\]/,/## \[/ p' CHANGELOG.md | head -n -1 | tail -n +2 >> $GITHUB_ENV - echo **Full Changelog**: ${{ github.server_url }}/${{ github.repository }}/compare/${{ env.PREVIOUS_VERSION }}...${{ github.ref_name }} >> $GITHUB_ENV + sed -n -e '/## \[${{ inputs.irs-version }}\]/,/## \[/ p' CHANGELOG.md | head -n -1 | tail -n +2 >> $GITHUB_ENV + echo **Full Changelog**: ${{ github.server_url }}/${{ github.repository }}/compare/${{ env.PREVIOUS_VERSION }}...${{ inputs.irs-version }} >> $GITHUB_ENV echo "$EOF" >> "$GITHUB_ENV" - name: Create IRS release uses: softprops/action-gh-release@v1 with: body: ${{ env.CHANGELOG }} - - trigger-jira: - needs: - - release - uses: ./.github/workflows/jira-publish-release.yaml - with: - version: ${{ github.ref_name }} - secrets: inherit + tag_name: ${{ inputs.irs-version }} publish-to-swaggerhub: name: "Publish OpenAPI spec to Swaggerhub" @@ -71,5 +66,5 @@ jobs: - release uses: ./.github/workflows/publish-swagger-hub.yml with: - version: ${{ github.ref_name }} + version: ${{ inputs.irs-version }} secrets: inherit \ No newline at end of file diff --git a/.github/workflows/update-docs-for-release.yml b/.github/workflows/update-docs-for-release.yml new file mode 100644 index 0000000000..d1503083ff --- /dev/null +++ b/.github/workflows/update-docs-for-release.yml @@ -0,0 +1,169 @@ +name: Update docs for IRS release + +env: + IRS_APPLICATION_PATH: 'irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java' + TOP_LEVEL_CHANGELOG_PATH: 'CHANGELOG.md' + IRS_OPENAPI_SPEC_PATH: 'docs/src/api/irs-api.yaml' + IRS_HELM_CHANGELOG_PATH: 'charts/item-relationship-service/CHANGELOG.md' + SEMVER_PATTERN: '[0-9]+\.[0-9]+\.[0-9]+' + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +on: + workflow_dispatch: + inputs: + irs-version: + description: 'New IRS version' + required: true + type: string + helm-chart-version: + description: 'New Helm Chart version' + required: true + type: string + helm-changelog-irs-added: + description: '"Update IRS version to ..." change already present in charts/irs-helm/CHANGELOG.md for this release?' + required: true + type: choice + options: + - 'Yes' + - 'No' + default: 'No' +jobs: + update-docs-for-release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Validate that workflow inputs are SemVer strings + run: | + matched_irs_semver_string=$(echo "${{ inputs.irs-version }}" | grep -Ex "${{ env.SEMVER_PATTERN }}") + matched_helm_chart_semver_string=$(echo "${{ inputs.helm-chart-version }}" | grep -Ex "${{ env.SEMVER_PATTERN }}") + if [[ -z "$matched_irs_semver_string" || -z "$matched_helm_chart_semver_string" ]]; then + exit 1 + fi + continue-on-error: false + + - name: Validate that IRS and Helm Chart versions don't exist yet + run: | + # IRS version can be checked via git tag since every release has a tag + matched_irs_version=$(git tag | grep -Eo "${{ inputs.irs-version }}" || echo "") + # extract from Helm Chart changelog + matched_helm_chart_version=$(grep -Eo "## \[${{ inputs.helm-chart-version }}\]" ${{ env.IRS_HELM_CHANGELOG_PATH }} || echo "") + + if [[ -n "$matched_irs_version" || -n "$matched_helm_chart_version" ]]; then + echo "IRS or Helm Chart release version already exists, aborting..." + exit 1 + fi + continue-on-error: false + + - name: Update top level changelog, IRS Helm changelog, Helm repository's yaml file and IrsApplication.java + run: | + new_irs_version="${{ inputs.irs-version }}" + new_helm_chart_version="${{ inputs.helm-chart-version }}" + irs_change_present_in_helm_changelog="${{ inputs.helm-changelog-irs-added }}" + date=$(date +"%Y-%m-%d") + + semver_pattern="${{ env.SEMVER_PATTERN }}" + semver_pattern_sed="[0-9]\+\.[0-9]\+\.[0-9]\+" + + # get line numbers of "Unreleased" or "UNRELEASED" placeholders in changelogs to use them with sed + top_lvl_changelog_placeholder_line_number=$(cat -n ${{ env.TOP_LEVEL_CHANGELOG_PATH }} | grep -Eoi "[0-9]+.## \[Unreleased\]" | grep -Eo "[0-9]+") + irs_helm_changelog_placeholder_line_number=$(cat -n ${{ env.IRS_HELM_CHANGELOG_PATH }} | grep -Eoi "[0-9]+.## \[Unreleased\]" | grep -Eo "[0-9]+") + + ### update CHANGELOG.md ### + # get line number of uppermost comparison url ("[Unreleased]: https://github.com/.../version...HEAD") + latest_comparison_url_line_number=$(cat -n ${{ env.TOP_LEVEL_CHANGELOG_PATH }} | grep -Eoi "[0-9]+.\[Unreleased\]" | grep -Eo "[0-9]+") + + # previous version can be extracted from line below uppermost comparison + previous_irs_version=$(awk "NR==$((latest_comparison_url_line_number+1))" ${{ env.TOP_LEVEL_CHANGELOG_PATH }} | grep -Eo "\[$semver_pattern\]" | tr -d "[]") + + # correct uppermost comparison + sed -i "$latest_comparison_url_line_number s|$semver_pattern_sed\.\.\.HEAD|$new_irs_version...HEAD|" ${{ env.TOP_LEVEL_CHANGELOG_PATH }} + + # insert new comparison below uppermost one + sed -i "$((latest_comparison_url_line_number+1)) s|^|[$new_irs_version]: https://github.com/eclipse-tractusx/item-relationship-service/compare/$previous_irs_version...$new_irs_version\n|" ${{ env.TOP_LEVEL_CHANGELOG_PATH }} + + # replace placeholder + # get line numbers of "Unreleased" placeholder in changelogs to use them with sed + top_lvl_changelog_placeholder_line_number=$(cat -n ${{ env.TOP_LEVEL_CHANGELOG_PATH }} | grep -Eoi "[0-9]+.## \[Unreleased\]" | grep -Eo "[0-9]+") + sed -i "$((top_lvl_changelog_placeholder_line_number+1)) s|^|\n## [$new_irs_version] - $date\n|" ${{ env.TOP_LEVEL_CHANGELOG_PATH }} + + ### update irs-helm directory's CHANGELOG.md ### + if [[ "$irs_change_present_in_helm_changelog" = "No" ]]; then + # get line number of first header which is not placeholder + next_header_line_number=$(cat -n ${{ env.IRS_HELM_CHANGELOG_PATH }} | grep -Eo -m 1 "[0-9]+.## \[$semver_pattern\]" | grep -Eo "^[0-9]+") + # get line number of first "### Changed" section + first_changed_section_line_number=$(cat -n ${{ env.IRS_HELM_CHANGELOG_PATH }} | grep -Eo -m 1 "[0-9]+.### Changed" | grep -Eo "[0-9]+") + + # "### Changed" is already present for current changelog if it comes before next header -> just insert line below + if [[ $first_changed_section_line_number -lt $next_header_line_number ]]; then + sed -i "$((first_changed_section_line_number+1)) s|^|- Update IRS version to $new_irs_version\n|" ${{ env.IRS_HELM_CHANGELOG_PATH }} + # not present, insert before beginning of next header + else + sed -i "$(($next_header_line_number-1)) s|^|\n### Changed\n- Update IRS version to $new_irs_version\n|" ${{ env.IRS_HELM_CHANGELOG_PATH }} + fi + fi + + # replace placeholder + irs_helm_changelog_placeholder_line_number=$(cat -n ${{ env.IRS_HELM_CHANGELOG_PATH }} | grep -Eoi "[0-9]+.## \[Unreleased\]" | grep -Eo "[0-9]+") + sed -i "$((irs_helm_changelog_placeholder_line_number+1)) s|^|\n## [$new_helm_chart_version] - $date\n|" ${{ env.IRS_HELM_CHANGELOG_PATH }} + + ### update irs-api.yaml ### + irs_openapi_spec_irs_version_line_number=$(cat -n ${{ env.IRS_OPENAPI_SPEC_PATH }} | grep -Eo -m 1 "[0-9]+.+version: $semver_pattern" | grep -Eo "^[0-9]+") + sed -i "$irs_openapi_spec_irs_version_line_number s|$semver_pattern_sed|$new_irs_version|" ${{ env.IRS_OPENAPI_SPEC_PATH }} + + ### update IrsApplication.java ### + sed -i "s|API_VERSION = \"$semver_pattern_sed\"|API_VERSION = \"$new_irs_version\"|" ${{ env.IRS_APPLICATION_PATH }} + + - name: Create pull request + id: cpr + uses: peter-evans/create-pull-request@v5 + with: + commit-message: 'chore(docs): Update docs for release ${{ inputs.irs-version }}' + branch: chore/update-docs-for-irs-release-${{ inputs.irs-version }} + base: main + delete-branch: true + title: Updated docs for next release + body: This PR prepares the docs for IRS release version ${{ inputs.irs-version }}. + Please check whether the docs were updated correctly. Once this PR is merged, the release process will continue automatically. + + - name: Wait for pull request merge + run: | + pull_request_number=${{ steps.cpr.outputs.pull-request-number }} + pull_request_merged="False" + seconds_waited_for_merge=0 + # set duration between api requests + sleep_interval_length=30 # seconds + timeout_in_minutes=10 + + while [[ "$pull_request_merged" == "False" ]] + do + # give some time to merge pull request + sleep "$sleep_interval_length"s + + # retrieve pr status using GH API's pull requests endpoint with GH CLI + pr_status=$(gh pr view $pull_request_number --json mergedAt --jq ".mergedAt") + + # response body contains field "mergedAt": will be date time string once pr has been merged, otherwise empty string + if [[ -n "$pr_status" ]]; then + pull_request_merged="True" + else + seconds_waited_for_merge=$((seconds_waited_for_merge+sleep_interval_length)) + + # abort workflow when having waited for more than specified time + if [[ $seconds_waited_for_merge -gt $((timeout_in_minutes*60)) ]]; then + exit 1 + fi + fi + done + continue-on-error: false + + - name: Create and push new Git tag for release + run: git tag ${{ inputs.irs-version }} && git push origin ${{ inputs.irs-version }} + + call-release-workflow: + needs: + - update-docs-for-release + uses: ./.github/workflows/release.yaml + with: + irs-version: ${{ inputs.irs-version }} \ No newline at end of file From 89840096a5b3aa4098f9979432fdbb46f631c74a Mon Sep 17 00:00:00 2001 From: pweick Date: Thu, 18 Apr 2024 10:10:35 +0200 Subject: [PATCH 02/18] refactor(release): Simplified pull request status check in update-docs-for-release.yml workflow --- .github/workflows/update-docs-for-release.yml | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/update-docs-for-release.yml b/.github/workflows/update-docs-for-release.yml index d1503083ff..e27b98b8e9 100644 --- a/.github/workflows/update-docs-for-release.yml +++ b/.github/workflows/update-docs-for-release.yml @@ -142,19 +142,28 @@ jobs: sleep "$sleep_interval_length"s # retrieve pr status using GH API's pull requests endpoint with GH CLI - pr_status=$(gh pr view $pull_request_number --json mergedAt --jq ".mergedAt") + pr_status=$(gh pr view $pull_request_number --json state --jq ".state") + + case $pr_status in + + MERGED) + pull_request_merged="True" + ;; + + OPEN) + seconds_waited_for_merge=$((seconds_waited_for_merge+sleep_interval_length)) + # abort workflow when having waited for more than specified time + if [[ $seconds_waited_for_merge -gt $((timeout_in_minutes*60)) ]]; then + exit 1 + fi + ;; + + CLOSED) + exit 1 + ;; - # response body contains field "mergedAt": will be date time string once pr has been merged, otherwise empty string - if [[ -n "$pr_status" ]]; then - pull_request_merged="True" - else - seconds_waited_for_merge=$((seconds_waited_for_merge+sleep_interval_length)) + esac - # abort workflow when having waited for more than specified time - if [[ $seconds_waited_for_merge -gt $((timeout_in_minutes*60)) ]]; then - exit 1 - fi - fi done continue-on-error: false From 93bd423c937413d6d27d42ed624944d56c9ae364 Mon Sep 17 00:00:00 2001 From: pweick Date: Thu, 18 Apr 2024 13:13:58 +0200 Subject: [PATCH 03/18] refactor(release): Minuscule changes to bash syntax in update-docs-for-release.yml --- .github/workflows/update-docs-for-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-docs-for-release.yml b/.github/workflows/update-docs-for-release.yml index e27b98b8e9..9d94feffec 100644 --- a/.github/workflows/update-docs-for-release.yml +++ b/.github/workflows/update-docs-for-release.yml @@ -36,8 +36,8 @@ jobs: - name: Validate that workflow inputs are SemVer strings run: | - matched_irs_semver_string=$(echo "${{ inputs.irs-version }}" | grep -Ex "${{ env.SEMVER_PATTERN }}") - matched_helm_chart_semver_string=$(echo "${{ inputs.helm-chart-version }}" | grep -Ex "${{ env.SEMVER_PATTERN }}") + matched_irs_semver_string=$(echo "${{ inputs.irs-version }}" | grep -Ex "${{ env.SEMVER_PATTERN }}" || echo "") + matched_helm_chart_semver_string=$(echo "${{ inputs.helm-chart-version }}" | grep -Ex "${{ env.SEMVER_PATTERN }}" || echo "") if [[ -z "$matched_irs_semver_string" || -z "$matched_helm_chart_semver_string" ]]; then exit 1 fi @@ -89,7 +89,7 @@ jobs: sed -i "$((top_lvl_changelog_placeholder_line_number+1)) s|^|\n## [$new_irs_version] - $date\n|" ${{ env.TOP_LEVEL_CHANGELOG_PATH }} ### update irs-helm directory's CHANGELOG.md ### - if [[ "$irs_change_present_in_helm_changelog" = "No" ]]; then + if [[ "$irs_change_present_in_helm_changelog" == "No" ]]; then # get line number of first header which is not placeholder next_header_line_number=$(cat -n ${{ env.IRS_HELM_CHANGELOG_PATH }} | grep -Eo -m 1 "[0-9]+.## \[$semver_pattern\]" | grep -Eo "^[0-9]+") # get line number of first "### Changed" section From 0820b15c1b54c60968d51e0566cec808d10d6817 Mon Sep 17 00:00:00 2001 From: pweick Date: Mon, 22 Apr 2024 08:23:36 +0200 Subject: [PATCH 04/18] refactor(release): Change release workflow to use output of update-docs-for-release.yml workflow --- .github/workflows/release.yaml | 34 ++++++++++--------- .github/workflows/update-docs-for-release.yml | 8 ++++- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 985543932e..6169a1bd98 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,10 +3,18 @@ name: Release IRS on: workflow_call: inputs: - irs-version: + new-irs-version: description: 'New IRS version' required: true type: string + previous-irs-version: + description: 'Previous IRS version' + required: true + type: string + helm-chart-version: + description: 'New Helm Chart version' + required: true + type: string jobs: release: @@ -14,49 +22,43 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Calculate Helm release version from CHANGELOG - run: echo HELM_VERSION=$(cat charts/item-relationship-service/CHANGELOG.md | sed -n 's/.*\[\([0-9]\+\.[0-9]\+\.[0-9]\+\)\].*/\1/p' | head -n 1) >> $GITHUB_ENV - - name: Update Chart.yaml appVersion uses: mikefarah/yq@v4.40.5 with: - cmd: yq -i eval '.appVersion = "${{ inputs.irs-version }}"' charts/item-relationship-service/Chart.yaml + cmd: yq -i eval '.appVersion = "${{ inputs.new-irs-version }}"' charts/item-relationship-service/Chart.yaml - name: Update Chart.yaml version uses: mikefarah/yq@v4.40.5 with: - cmd: yq -i eval '.version = "${{ env.HELM_VERSION }}"' charts/item-relationship-service/Chart.yaml + cmd: yq -i eval '.version = "${{ inputs.helm-chart-version }}"' charts/item-relationship-service/Chart.yaml - name: Prepare Helm release uses: peter-evans/create-pull-request@v5 with: - commit-message: "chore(release): Prepare release for Helm version ${{ env.HELM_VERSION }}" - branch: chore/prepare-helm-release-${{ env.HELM_VERSION }} + commit-message: "chore(release): Prepare release for Helm version ${{ inputs.helm-chart-version }}" + branch: chore/prepare-helm-release-${{ inputs.helm-chart-version }} base: main delete-branch: true title: Prepare Helm release for next version body: | - This PR prepares the Helm chart release for version ${{ env.HELM_VERSION }}. + This PR prepares the Helm chart release for version ${{ inputs.helm-chart-version }}. Please check whether the Chart was updated correctly and that the CHANGELOG contains the relevant information for this release. Also, make sure that the values.yaml is correct before merging this PR. - - name: Get previous version - run: echo PREVIOUS_VERSION=$(git tag | grep -E ^[0-9]+\\.[0-9]+\\.[0-9]+ | tail -2 | head -n +1) >> $GITHUB_ENV - - name: Extract changelog text # See: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings run: | EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) echo "CHANGELOG<<$EOF" >> $GITHUB_ENV - sed -n -e '/## \[${{ inputs.irs-version }}\]/,/## \[/ p' CHANGELOG.md | head -n -1 | tail -n +2 >> $GITHUB_ENV - echo **Full Changelog**: ${{ github.server_url }}/${{ github.repository }}/compare/${{ env.PREVIOUS_VERSION }}...${{ inputs.irs-version }} >> $GITHUB_ENV + sed -n -e '/## \[${{ inputs.new-irs-version }}\]/,/## \[/ p' CHANGELOG.md | head -n -1 | tail -n +2 >> $GITHUB_ENV + echo **Full Changelog**: ${{ github.server_url }}/${{ github.repository }}/compare/${{ inputs.previous-irs-version }}...${{ inputs.new-irs-version }} >> $GITHUB_ENV echo "$EOF" >> "$GITHUB_ENV" - name: Create IRS release uses: softprops/action-gh-release@v1 with: body: ${{ env.CHANGELOG }} - tag_name: ${{ inputs.irs-version }} + tag_name: ${{ inputs.new-irs-version }} publish-to-swaggerhub: name: "Publish OpenAPI spec to Swaggerhub" @@ -66,5 +68,5 @@ jobs: - release uses: ./.github/workflows/publish-swagger-hub.yml with: - version: ${{ inputs.irs-version }} + version: ${{ inputs.new-irs-version }} secrets: inherit \ No newline at end of file diff --git a/.github/workflows/update-docs-for-release.yml b/.github/workflows/update-docs-for-release.yml index 9d94feffec..7471ca665e 100644 --- a/.github/workflows/update-docs-for-release.yml +++ b/.github/workflows/update-docs-for-release.yml @@ -30,6 +30,8 @@ on: jobs: update-docs-for-release: runs-on: ubuntu-latest + outputs: + previous-irs-version: $${{ steps.update-docs.outputs.previous-irs-version }} steps: - uses: actions/checkout@v4 @@ -57,6 +59,7 @@ jobs: continue-on-error: false - name: Update top level changelog, IRS Helm changelog, Helm repository's yaml file and IrsApplication.java + id: update-docs run: | new_irs_version="${{ inputs.irs-version }}" new_helm_chart_version="${{ inputs.helm-chart-version }}" @@ -76,6 +79,7 @@ jobs: # previous version can be extracted from line below uppermost comparison previous_irs_version=$(awk "NR==$((latest_comparison_url_line_number+1))" ${{ env.TOP_LEVEL_CHANGELOG_PATH }} | grep -Eo "\[$semver_pattern\]" | tr -d "[]") + echo "previous-irs-version=$previous_irs_version" >> "$GITHUB_OUTPUT" # correct uppermost comparison sed -i "$latest_comparison_url_line_number s|$semver_pattern_sed\.\.\.HEAD|$new_irs_version...HEAD|" ${{ env.TOP_LEVEL_CHANGELOG_PATH }} @@ -175,4 +179,6 @@ jobs: - update-docs-for-release uses: ./.github/workflows/release.yaml with: - irs-version: ${{ inputs.irs-version }} \ No newline at end of file + new-irs-version: ${{ inputs.irs-version }} + previous-irs-version: ${{ needs.update-docs-for-release.outputs.previous-irs-version }} + helm-chart-version: ${{ inputs.helm-chart-version }} From 2f4295e95cbc05aceba03ae79fece807dcd1abd5 Mon Sep 17 00:00:00 2001 From: pweick Date: Mon, 22 Apr 2024 08:34:32 +0200 Subject: [PATCH 05/18] refactor(release): Minuscule change in workflow to inform of existing IRS and Helm versions --- .github/workflows/update-docs-for-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-for-release.yml b/.github/workflows/update-docs-for-release.yml index 7471ca665e..c22c0877da 100644 --- a/.github/workflows/update-docs-for-release.yml +++ b/.github/workflows/update-docs-for-release.yml @@ -53,7 +53,7 @@ jobs: matched_helm_chart_version=$(grep -Eo "## \[${{ inputs.helm-chart-version }}\]" ${{ env.IRS_HELM_CHANGELOG_PATH }} || echo "") if [[ -n "$matched_irs_version" || -n "$matched_helm_chart_version" ]]; then - echo "IRS or Helm Chart release version already exists, aborting..." + echo "IRS or Helm Chart release version already exists. Previous versions: $matched_irs_version (IRS), $matched_helm_chart_version (Helm Chart). Aborting..." exit 1 fi continue-on-error: false From 5946da7c01686aec5f504729e60649fac871e577 Mon Sep 17 00:00:00 2001 From: pweick Date: Mon, 22 Apr 2024 08:41:34 +0200 Subject: [PATCH 06/18] Revert "refactor(release): Minuscule change in workflow to inform of existing IRS and Helm versions" This reverts commit 2f4295e95cbc05aceba03ae79fece807dcd1abd5. --- .github/workflows/update-docs-for-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-for-release.yml b/.github/workflows/update-docs-for-release.yml index c22c0877da..7471ca665e 100644 --- a/.github/workflows/update-docs-for-release.yml +++ b/.github/workflows/update-docs-for-release.yml @@ -53,7 +53,7 @@ jobs: matched_helm_chart_version=$(grep -Eo "## \[${{ inputs.helm-chart-version }}\]" ${{ env.IRS_HELM_CHANGELOG_PATH }} || echo "") if [[ -n "$matched_irs_version" || -n "$matched_helm_chart_version" ]]; then - echo "IRS or Helm Chart release version already exists. Previous versions: $matched_irs_version (IRS), $matched_helm_chart_version (Helm Chart). Aborting..." + echo "IRS or Helm Chart release version already exists, aborting..." exit 1 fi continue-on-error: false From 34cd14bb241fab8523bf34f8e9bbd008f28f0827 Mon Sep 17 00:00:00 2001 From: pweick Date: Mon, 22 Apr 2024 09:43:58 +0200 Subject: [PATCH 07/18] fix(release): Finally fix bug which caused wrong release comparison URL in GH releases tab --- .github/workflows/update-docs-for-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-for-release.yml b/.github/workflows/update-docs-for-release.yml index 7471ca665e..08bb3aab04 100644 --- a/.github/workflows/update-docs-for-release.yml +++ b/.github/workflows/update-docs-for-release.yml @@ -31,7 +31,7 @@ jobs: update-docs-for-release: runs-on: ubuntu-latest outputs: - previous-irs-version: $${{ steps.update-docs.outputs.previous-irs-version }} + previous-irs-version: ${{ steps.update-docs.outputs.previous-irs-version }} steps: - uses: actions/checkout@v4 From cfcfcd826729c6c9a6765fd3b8ee3b4f6f5675ab Mon Sep 17 00:00:00 2001 From: "Krzysztof Massalski (Extern)" Date: Tue, 30 Apr 2024 13:57:59 +0200 Subject: [PATCH 08/18] feat(impl):[#522] changelog log --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d66d66bd..eef6a18202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,13 +10,14 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## Changed -- Removed obsolete entries from acceptedPolicies configuration. #530 +- Removed obsolete entries from acceptedPolicies configuration. #530 - Support of building relationships based on SingleLevelUsageAsBuilt v3.0.0 #558 - Support of building relationships based on SingleLevelBomAsPlanned v3.0.0 #558 ### Fixed - Update bouncycastle to 1.78 to fix CVE's. +- Fixed validation of json-schemas - IRS is creating tombstone instead collecting Submodel payload, when it not passes validation of schema #522 ## [5.0.0] - 2024-04-16 From 4eedd50b1468d096e35fb742b1686303a8e3361b Mon Sep 17 00:00:00 2001 From: Jaro Hartmann <57985712+ds-jhartmann@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:33:12 +0200 Subject: [PATCH 09/18] chore(docs): fix changelog typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eef6a18202..1d6d48e1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] -## Changed +### Changed - Removed obsolete entries from acceptedPolicies configuration. #530 - Support of building relationships based on SingleLevelUsageAsBuilt v3.0.0 #558 From ec6ee793a9a3606901b40db771a7dd6b7d102975 Mon Sep 17 00:00:00 2001 From: ds-jhartmann Date: Tue, 30 Apr 2024 12:36:53 +0000 Subject: [PATCH 10/18] chore(docs): Update docs for release 5.1.0 --- CHANGELOG.md | 5 ++++- charts/item-relationship-service/CHANGELOG.md | 5 +++++ docs/src/api/irs-api.yaml | 2 +- .../main/java/org/eclipse/tractusx/irs/IrsApplication.java | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d6d48e1aa..9358ba02c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] +## [5.1.0] - 2024-04-30 + ### Changed - Removed obsolete entries from acceptedPolicies configuration. #530 @@ -628,7 +630,8 @@ _**For better traceability add the corresponding GitHub issue number in each cha ### Unresolved - **Select Aspects you need** You are able to select the needed aspects for which you want to collect the correct endpoint information. -[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.0.0...HEAD +[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.0...HEAD +[5.1.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.0.0...5.1.0 [5.0.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.9.0...5.0.0 [4.9.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.8.0...4.9.0 [4.8.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.7.0...4.8.0 diff --git a/charts/item-relationship-service/CHANGELOG.md b/charts/item-relationship-service/CHANGELOG.md index 13e3089fc4..99e5115634 100644 --- a/charts/item-relationship-service/CHANGELOG.md +++ b/charts/item-relationship-service/CHANGELOG.md @@ -6,12 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [7.1.0] - 2024-04-30 + ### Fixed - Fix for incomplete renaming of Helm chart (see #489) +### Changed +- Update IRS version to 5.1.0 + ## [7.0.1] - 2024-04-17 ### Fixed diff --git a/docs/src/api/irs-api.yaml b/docs/src/api/irs-api.yaml index e0704da682..52094f769b 100644 --- a/docs/src/api/irs-api.yaml +++ b/docs/src/api/irs-api.yaml @@ -3,7 +3,7 @@ info: description: The API of the Item Relationship Service (IRS) for retrieving item graphs along the value chain of CATENA-X partners. title: IRS API - version: 5.0.0 + version: 5.1.0 servers: - url: http://localhost:8080 security: diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java index 0971e3657d..4fccef412e 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java @@ -59,7 +59,7 @@ public class IrsApplication { /** * The IRS API version. */ - public static final String API_VERSION = "5.0.0"; + public static final String API_VERSION = "5.1.0"; /** * The URL prefix for IRS API URLs. From f88a33126996b8da3a1627fad98f032ee9014e37 Mon Sep 17 00:00:00 2001 From: Jaro Hartmann <57985712+ds-jhartmann@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:38:27 +0200 Subject: [PATCH 11/18] chore(docs): remove blank lines --- charts/item-relationship-service/CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/item-relationship-service/CHANGELOG.md b/charts/item-relationship-service/CHANGELOG.md index 99e5115634..1366aca855 100644 --- a/charts/item-relationship-service/CHANGELOG.md +++ b/charts/item-relationship-service/CHANGELOG.md @@ -12,9 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix for incomplete renaming of Helm chart (see #489) - - ### Changed + - Update IRS version to 5.1.0 ## [7.0.1] - 2024-04-17 From c27072a9a5cf1ad903a7f07392d8d982479e3c0d Mon Sep 17 00:00:00 2001 From: ds-jhartmann Date: Tue, 30 Apr 2024 12:43:16 +0000 Subject: [PATCH 12/18] chore(release): Prepare release for Helm version 7.1.0 --- charts/item-relationship-service/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/item-relationship-service/Chart.yaml b/charts/item-relationship-service/Chart.yaml index 4741a6a94d..9b9ee99263 100644 --- a/charts/item-relationship-service/Chart.yaml +++ b/charts/item-relationship-service/Chart.yaml @@ -35,12 +35,12 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 7.0.1 +version: 7.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "5.0.0" +appVersion: "5.1.0" dependencies: - name: common repository: https://charts.bitnami.com/bitnami From ca406f049f7eebbeb009f7e9d058a25cd72a914f Mon Sep 17 00:00:00 2001 From: "Krzysztof Massalski (Extern)" Date: Wed, 1 May 2024 10:25:37 +0200 Subject: [PATCH 13/18] feat(impl):[#567] fix message when wrong direction --- .../eclipse/tractusx/irs/component/enums/Direction.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/Direction.java b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/Direction.java index f0c5fb55a7..a2b4845a50 100644 --- a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/Direction.java +++ b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/Direction.java @@ -23,6 +23,8 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.component.enums; +import java.util.NoSuchElementException; +import java.util.stream.Collectors; import java.util.stream.Stream; import com.fasterxml.jackson.annotation.JsonCreator; @@ -62,7 +64,12 @@ public static Direction fromValue(final String value) { return Stream.of(Direction.values()) .filter(direction -> direction.name.equals(value)) .findFirst() - .orElseThrow(); + .orElseThrow(() -> new NoSuchElementException("Unsupported Direction: " + value + + ". Must be one of: " + supportedDirections())); + } + + private static String supportedDirections() { + return Stream.of(Direction.values()).map(direction -> direction.name).collect(Collectors.joining(", ")); } /** From 9c965199328f86bba94e94e76e672a58bf07e7c9 Mon Sep 17 00:00:00 2001 From: ds-kgassner Date: Thu, 2 May 2024 08:53:40 +0200 Subject: [PATCH 14/18] chore(tavern):[#503] adjusting test --- local/testing/api-tests/irs-api-tests.tavern.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/local/testing/api-tests/irs-api-tests.tavern.yaml b/local/testing/api-tests/irs-api-tests.tavern.yaml index c84b21c3ea..48aa9a7e03 100644 --- a/local/testing/api-tests/irs-api-tests.tavern.yaml +++ b/local/testing/api-tests/irs-api-tests.tavern.yaml @@ -1725,16 +1725,18 @@ stages: url: "{tavern.env_vars.IRS_HOST}/irs/jobs" json: key: - globalAssetId: "{tavern.env_vars.GLOBAL_ASSET_ID_AS_BUILT}" + globalAssetId: urn:uuid:8724338c-5c85-4c34-91eb-e2735d58fb0d #"{tavern.env_vars.GLOBAL_ASSET_ID_AS_BUILT}" bpn: "{tavern.env_vars.BPN_AS_BUILT}" aspects: - urn:samm:io.catenax.serial_part:3.0.0#SerialPart - - urn:samm:io.catenax.single_level_usage_as_built:3.0.0#SingleLevelUsageAsBuilt - - urn:samm:io.catenax.battery.battery_pass:3.0.1#BatteryPass" - - urn:samm:io.catenax.market_place_offer:1.4.0#MarketPlaceOffer + - urn:samm:io.catenax.batch:3.0.0#Batch - urn:samm:io.catenax.material_for_recycling:1.1.0#MaterialForRecycling - - urn:samm:io.catenax.return_request:1.0.1#ReturnRequest + #- urn:samm:io.catenax.single_level_usage_as_built:3.0.0#SingleLevelUsageAsBuilt + #- urn:samm:io.catenax.battery.battery_pass:3.0.1#BatteryPass" + #- urn:samm:io.catenax.market_place_offer:1.4.0#MarketPlaceOffer + #- urn:samm:io.catenax.return_request:1.0.1#ReturnRequest collectAspects: true + depth: 2 method: POST headers: content-type: application/json From 6f884c0cecebe9f13e91378c4b4ec570ee81ab6d Mon Sep 17 00:00:00 2001 From: Matthias Fischer Date: Thu, 2 May 2024 10:41:42 +0200 Subject: [PATCH 15/18] fix(documentation): [#567] update documentation --- .../sequence/ess-bottom-up-sequence-customer-highlevel.puml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/uml-diagrams/irs-recursive/ess-bottom-up/sequence/ess-bottom-up-sequence-customer-highlevel.puml b/docs/src/uml-diagrams/irs-recursive/ess-bottom-up/sequence/ess-bottom-up-sequence-customer-highlevel.puml index 756a98fd25..93763345ed 100644 --- a/docs/src/uml-diagrams/irs-recursive/ess-bottom-up/sequence/ess-bottom-up-sequence-customer-highlevel.puml +++ b/docs/src/uml-diagrams/irs-recursive/ess-bottom-up/sequence/ess-bottom-up-sequence-customer-highlevel.puml @@ -43,7 +43,7 @@ end note "bomLifecycle": "asPlannned", "collectAspects": true, "depth": 1, - "direction": "upwards", + "direction": "upward", "keys": [ { "bpn": "BPNL0123456789XX", From d881bcd455a2e28cd1cc92191a62f6465ffbfcf2 Mon Sep 17 00:00:00 2001 From: Matthias Fischer Date: Thu, 2 May 2024 12:18:32 +0200 Subject: [PATCH 16/18] fix(documentation): [#567] removed invalid user input from message and added test --- .../irs/controllers/IrsControllerTest.java | 179 +++++++++++++----- .../irs/component/enums/Direction.java | 4 +- 2 files changed, 131 insertions(+), 52 deletions(-) diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/controllers/IrsControllerTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/controllers/IrsControllerTest.java index 7808859fea..4dea897404 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/controllers/IrsControllerTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/controllers/IrsControllerTest.java @@ -31,6 +31,7 @@ import static org.eclipse.tractusx.irs.util.TestMother.registerJobWithoutDepthAndAspect; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.not; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -74,6 +75,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.BDDMockito; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @@ -91,9 +93,13 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "digitalTwinRegistry.type=central" }) -@ActiveProfiles(profiles = { "test", "local" }) +@ActiveProfiles(profiles = { "test", + "local" +}) @Import(TestConfig.class) -@ExtendWith({ MockitoExtension.class, SpringExtension.class }) +@ExtendWith({ MockitoExtension.class, + SpringExtension.class +}) class IrsControllerTest extends ControllerTest { private final UUID jobId = UUID.randomUUID(); @@ -129,25 +135,38 @@ void initiateJobForGlobalAssetId() { final UUID returnedJob = UUID.randomUUID(); Mockito.when(service.registerItemJob(any())).thenReturn(JobHandle.builder().id(returnedJob).build()); - given().port(port).contentType(ContentType.JSON).body(registerJobWithoutDepthAndAspect()).post("/irs/jobs") - .then().statusCode(CREATED.value()).body("id", is(returnedJob.toString())); + given().port(port) + .contentType(ContentType.JSON) + .body(registerJobWithoutDepthAndAspect()) + .post("/irs/jobs") + .then() + .statusCode(CREATED.value()) + .body("id", is(returnedJob.toString())); } @Test void shouldReturnUnauthorizedStatusWhenAuthenticationIsMissing() { Mockito.when(authenticationService.getAuthentication(any(HttpServletRequest.class))) - .thenThrow(new BadCredentialsException("Wrong ApiKey")); - - given().port(port).contentType(ContentType.JSON).body(registerJobWithoutDepthAndAspect()).post("/irs/jobs") - .then().statusCode(UNAUTHORIZED.value()); + .thenThrow(new BadCredentialsException("Wrong ApiKey")); + + given().port(port) + .contentType(ContentType.JSON) + .body(registerJobWithoutDepthAndAspect()) + .post("/irs/jobs") + .then() + .statusCode(UNAUTHORIZED.value()); } @Test void shouldReturnForbiddenStatusWhenRequiredAuthorityIsMissing() { authenticateWith("view_irs_wrong_authority"); - given().port(port).contentType(ContentType.JSON).body(registerJobWithoutDepthAndAspect()).post("/irs/jobs") - .then().statusCode(FORBIDDEN.value()); + given().port(port) + .contentType(ContentType.JSON) + .body(registerJobWithoutDepthAndAspect()) + .post("/irs/jobs") + .then() + .statusCode(FORBIDDEN.value()); } @ParameterizedTest @@ -155,16 +174,52 @@ void shouldReturnForbiddenStatusWhenRequiredAuthorityIsMissing() { void shouldReturnBadRequestWhenRegisterJobBodyNotValid(final RegisterJob registerJob) { authenticateWith(IrsRoles.VIEW_IRS); - given().port(port).contentType(ContentType.JSON).body(registerJob).post("/irs/jobs") - .then().statusCode(BAD_REQUEST.value()); + given().port(port) + .contentType(ContentType.JSON) + .body(registerJob) + .post("/irs/jobs") + .then() + .statusCode(BAD_REQUEST.value()); + } + + @ParameterizedTest + @ValueSource(strings = { "upwards", + "downwards" + }) + void shouldReturnBadRequestWhenRegisterJobWithInvalidDirection(String invalidDirection) { + authenticateWith(IrsRoles.VIEW_IRS); + + given().port(port) + .contentType(ContentType.JSON) + .body(""" + { + "key": { + "globalAssetId": "urn:uuid:c6d2d642-a055-4ddf-87e3-1a3b02c689e3", + "bpn": "BPNL00000000BJTL" + }, + "direction": "", + "lookupBPNs": true + } + """.replace("", invalidDirection)) + .post("/irs/jobs") + .then() + .statusCode(BAD_REQUEST.value()) + .body("error", containsString("Unsupported direction")) + .body("error", containsString("Must be one of: upward, downward")) + // error message should not contain unvalidated user input for security reasons + .body("error", not(containsString(invalidDirection))); } @Test void shouldReturnBadRequestWhenRegisterJobHasWrongCallbackUrl() { authenticateWith(IrsRoles.VIEW_IRS); - given().port(port).contentType(ContentType.JSON).body(registerJobWithUrl("hhh://example.com")).post("/irs/jobs") - .then().statusCode(BAD_REQUEST.value()); + given().port(port) + .contentType(ContentType.JSON) + .body(registerJobWithUrl("hhh://example.com")) + .post("/irs/jobs") + .then() + .statusCode(BAD_REQUEST.value()); } @Test @@ -174,8 +229,12 @@ void shouldAcceptCorrectCallbackUrl() { final UUID returnedJob = UUID.randomUUID(); Mockito.when(service.registerItemJob(any())).thenReturn(JobHandle.builder().id(returnedJob).build()); - given().port(port).contentType(ContentType.JSON).body(registerJobWithUrl("https://example.com")).post("/irs/jobs") - .then().statusCode(CREATED.value()); + given().port(port) + .contentType(ContentType.JSON) + .body(registerJobWithUrl("https://example.com")) + .post("/irs/jobs") + .then() + .statusCode(CREATED.value()); } @Test @@ -191,18 +250,20 @@ void getJobsByState() throws Exception { final String returnJobAsString = objectMapper.writeValueAsString(returnedJob); - Mockito.when(service.getJobsByState(any(), any())).thenReturn( - new PageResult(new PagedListHolder<>(List.of(returnedJob)))); + Mockito.when(service.getJobsByState(any(), any())) + .thenReturn(new PageResult(new PagedListHolder<>(List.of(returnedJob)))); - given().port(port).get("/irs/jobs") - .then().statusCode(OK.value()) + given().port(port) + .get("/irs/jobs") + .then() + .statusCode(OK.value()) .body(containsString(returnJobAsString)) .body(containsString(returnedJob.getId().toString())) .body(containsString(returnedJob.getState().toString())) - .body(containsString(returnedJob.getStartedOn().format(DateTimeFormatter.ofPattern( - "yyyy-MM-dd'T'HH:mm:ss.SSS")))) - .body(containsString(returnedJob.getCompletedOn().format(DateTimeFormatter.ofPattern( - "yyyy-MM-dd'T'HH:mm:ss.SSS")))); + .body(containsString( + returnedJob.getStartedOn().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS")))) + .body(containsString( + returnedJob.getCompletedOn().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS")))); } @Test @@ -212,19 +273,17 @@ void cancelJobById() { final Job canceledJob = Job.builder().id(jobId).state(JobState.CANCELED).build(); Mockito.when(this.service.cancelJobById(jobId)).thenReturn(canceledJob); - given().port(port).put("/irs/jobs/" + jobId) - .then().statusCode(OK.value()); + given().port(port).put("/irs/jobs/" + jobId).then().statusCode(OK.value()); } @Test void cancelJobById_throwEntityNotFoundException() { authenticateWith(IrsRoles.VIEW_IRS); - BDDMockito.given(this.service.cancelJobById(jobId)).willThrow( - new ResponseStatusException(HttpStatus.NOT_FOUND, "No job exists with id " + jobId)); + BDDMockito.given(this.service.cancelJobById(jobId)) + .willThrow(new ResponseStatusException(HttpStatus.NOT_FOUND, "No job exists with id " + jobId)); - given().port(port).put("/irs/jobs/" + jobId) - .then().statusCode(NOT_FOUND.value()); + given().port(port).put("/irs/jobs/" + jobId).then().statusCode(NOT_FOUND.value()); } @Test @@ -233,8 +292,7 @@ void getJobWithMalformedIdShouldReturnBadRequest() { final String jobIdMalformed = UUID.randomUUID() + "MALFORMED"; - given().port(port).get("/irs/jobs/" + jobIdMalformed) - .then().statusCode(BAD_REQUEST.value()); + given().port(port).get("/irs/jobs/" + jobIdMalformed).then().statusCode(BAD_REQUEST.value()); } @Test @@ -244,19 +302,23 @@ void shouldReturnBadRequestWhenRegisterJobWithMalformedAspectJson() { Mockito.when(service.registerItemJob(any())).thenThrow(IllegalArgumentException.class); final String requestBody = "{ \"aspects\": [ \"MALFORMED\" ], \"globalAssetId\": \"urn:uuid:8a61c8db-561e-4db0-84ec-a693fc5ffdf6\" }"; - given().port(port).contentType(ContentType.JSON).body(requestBody).post("/irs/jobs") - .then().statusCode(BAD_REQUEST.value()); + given().port(port) + .contentType(ContentType.JSON) + .body(requestBody) + .post("/irs/jobs") + .then() + .statusCode(BAD_REQUEST.value()); } @Test void shouldReturnBadRequestWhenCancelingAlreadyCompletedJob() { authenticateWith(IrsRoles.VIEW_IRS); - BDDMockito.given(this.service.cancelJobById(jobId)).willThrow(new IllegalStateException( - format("Cannot transition from state %s to %s", JobState.COMPLETED, JobState.CANCELED))); + BDDMockito.given(this.service.cancelJobById(jobId)) + .willThrow(new IllegalStateException( + format("Cannot transition from state %s to %s", JobState.COMPLETED, JobState.CANCELED))); - given().port(port).put("/irs/jobs/" + jobId) - .then().statusCode(BAD_REQUEST.value()); + given().port(port).put("/irs/jobs/" + jobId).then().statusCode(BAD_REQUEST.value()); } @Test @@ -278,8 +340,14 @@ void shouldReturnAspectModels() throws Exception { BDDMockito.given(this.semanticHubService.getAllAspectModels()).willReturn(aspectModels); - final AspectModels response = given().port(port).get("/irs/aspectmodels") - .then().statusCode(OK.value()).and().extract().response().as(AspectModels.class); + final AspectModels response = given().port(port) + .get("/irs/aspectmodels") + .then() + .statusCode(OK.value()) + .and() + .extract() + .response() + .as(AspectModels.class); assertEquals(aspectModels, response); } @@ -288,8 +356,7 @@ void shouldReturnAspectModels() throws Exception { void shouldReturnForbiddenStatusForAspectModelsWhenRequiredAuthorityIsMissing() { authenticateWith("view_irs_wrong_authority"); - given().port(port).get("/irs/aspectmodels") - .then().statusCode(FORBIDDEN.value()); + given().port(port).get("/irs/aspectmodels").then().statusCode(FORBIDDEN.value()); } @Test @@ -300,10 +367,16 @@ void shouldReturnPartialWhenJobCompleted() { Mockito.when(this.service.getJobForJobId(eq(jobId), anyBoolean())).thenReturn(runningJob); - given().port(port).queryParam("returnUncompletedJob", true).get("/irs/jobs/" + jobId) - .then().statusCode(PARTIAL_CONTENT.value()); - given().port(port).queryParam("returnUncompletedJob", false).get("/irs/jobs/" + jobId) - .then().statusCode(PARTIAL_CONTENT.value()); + given().port(port) + .queryParam("returnUncompletedJob", true) + .get("/irs/jobs/" + jobId) + .then() + .statusCode(PARTIAL_CONTENT.value()); + given().port(port) + .queryParam("returnUncompletedJob", false) + .get("/irs/jobs/" + jobId) + .then() + .statusCode(PARTIAL_CONTENT.value()); } @Test @@ -314,10 +387,16 @@ void shouldReturnOkWhenJobCompleted() { Mockito.when(this.service.getJobForJobId(eq(jobId), anyBoolean())).thenReturn(completedJob); - given().port(port).queryParam("returnUncompletedJob", true).get("/irs/jobs/" + jobId) - .then().statusCode(OK.value()); - given().port(port).queryParam("returnUncompletedJob", false).get("/irs/jobs/" + jobId) - .then().statusCode(OK.value()); + given().port(port) + .queryParam("returnUncompletedJob", true) + .get("/irs/jobs/" + jobId) + .then() + .statusCode(OK.value()); + given().port(port) + .queryParam("returnUncompletedJob", false) + .get("/irs/jobs/" + jobId) + .then() + .statusCode(OK.value()); } } \ No newline at end of file diff --git a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/Direction.java b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/Direction.java index a2b4845a50..dd69c51cb2 100644 --- a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/Direction.java +++ b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/Direction.java @@ -64,8 +64,8 @@ public static Direction fromValue(final String value) { return Stream.of(Direction.values()) .filter(direction -> direction.name.equals(value)) .findFirst() - .orElseThrow(() -> new NoSuchElementException("Unsupported Direction: " + value - + ". Must be one of: " + supportedDirections())); + .orElseThrow(() -> new NoSuchElementException( + "Unsupported direction. Must be one of: " + supportedDirections())); } private static String supportedDirections() { From 3fd4b443453a656d7c56cfada1d507742ede8c93 Mon Sep 17 00:00:00 2001 From: Jaro Hartmann <57985712+ds-jhartmann@users.noreply.github.com> Date: Thu, 2 May 2024 14:39:25 +0200 Subject: [PATCH 17/18] Revert "Updated docs for next release" --- CHANGELOG.md | 5 +---- charts/item-relationship-service/CHANGELOG.md | 4 ---- docs/src/api/irs-api.yaml | 2 +- .../main/java/org/eclipse/tractusx/irs/IrsApplication.java | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9358ba02c0..1d6d48e1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,6 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] -## [5.1.0] - 2024-04-30 - ### Changed - Removed obsolete entries from acceptedPolicies configuration. #530 @@ -630,8 +628,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha ### Unresolved - **Select Aspects you need** You are able to select the needed aspects for which you want to collect the correct endpoint information. -[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.0...HEAD -[5.1.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.0.0...5.1.0 +[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.0.0...HEAD [5.0.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.9.0...5.0.0 [4.9.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.8.0...4.9.0 [4.8.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.7.0...4.8.0 diff --git a/charts/item-relationship-service/CHANGELOG.md b/charts/item-relationship-service/CHANGELOG.md index 1366aca855..13e3089fc4 100644 --- a/charts/item-relationship-service/CHANGELOG.md +++ b/charts/item-relationship-service/CHANGELOG.md @@ -6,15 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [7.1.0] - 2024-04-30 - ### Fixed - Fix for incomplete renaming of Helm chart (see #489) -### Changed -- Update IRS version to 5.1.0 ## [7.0.1] - 2024-04-17 diff --git a/docs/src/api/irs-api.yaml b/docs/src/api/irs-api.yaml index 52094f769b..e0704da682 100644 --- a/docs/src/api/irs-api.yaml +++ b/docs/src/api/irs-api.yaml @@ -3,7 +3,7 @@ info: description: The API of the Item Relationship Service (IRS) for retrieving item graphs along the value chain of CATENA-X partners. title: IRS API - version: 5.1.0 + version: 5.0.0 servers: - url: http://localhost:8080 security: diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java index 4fccef412e..0971e3657d 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java @@ -59,7 +59,7 @@ public class IrsApplication { /** * The IRS API version. */ - public static final String API_VERSION = "5.1.0"; + public static final String API_VERSION = "5.0.0"; /** * The URL prefix for IRS API URLs. From 0f391d251e19db42c8a9ccc550054a3b7adcc7c0 Mon Sep 17 00:00:00 2001 From: Jaro Hartmann <57985712+ds-jhartmann@users.noreply.github.com> Date: Thu, 2 May 2024 14:39:28 +0200 Subject: [PATCH 18/18] Revert "Prepare Helm release for next version" --- charts/item-relationship-service/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/item-relationship-service/Chart.yaml b/charts/item-relationship-service/Chart.yaml index 9b9ee99263..4741a6a94d 100644 --- a/charts/item-relationship-service/Chart.yaml +++ b/charts/item-relationship-service/Chart.yaml @@ -35,12 +35,12 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 7.1.0 +version: 7.0.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "5.1.0" +appVersion: "5.0.0" dependencies: - name: common repository: https://charts.bitnami.com/bitnami