From a4d2dea29e4fa25a6829898fb78ca1ebb4452d0b Mon Sep 17 00:00:00 2001 From: JW Wesson Date: Fri, 25 Apr 2025 15:08:32 -0500 Subject: [PATCH 1/3] update CI and fix delete multiple documents method --- .github/pull_request_template.md | 5 ++ .github/release.yml | 8 +++ .github/workflows/build.yml | 52 ------------------- .../{maven-publish.yml => create-release.yml} | 52 +++++++++++++++---- .github/workflows/docs-publish.yml | 49 +++++++++++++++++ src/main/java/com/textkernel/tx/TxClient.java | 4 +- .../DeleteMultipleDocumentsRequest.java | 17 ++++++ 7 files changed, 125 insertions(+), 62 deletions(-) create mode 100644 .github/pull_request_template.md create mode 100644 .github/release.yml rename .github/workflows/{maven-publish.yml => create-release.yml} (51%) create mode 100644 .github/workflows/docs-publish.yml create mode 100644 src/main/java/com/textkernel/tx/models/api/indexes/DeleteMultipleDocumentsRequest.java diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..03c7b148c --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,5 @@ +- **This description will be used to generate release notes when the PR is merged** + - add the label `ignore-for-release` to prevent this PR from being linked to a release +- Please fill out the description of what was changed/added/fixed in this PR +- Be sure to link any issues +- Increment the version in the pom.xml if you want a release & maven publish to happen upon merge \ No newline at end of file diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 000000000..58dc470e4 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,8 @@ +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: Changes + labels: + - "*" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b700f020..cb0b64f41 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,57 +8,7 @@ on: - master jobs: - get_javadocs_status: - name: get-javadocs-status - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 10 # important for use of HEAD^2 - # find the last commit message on the source branch - - name: Get last commit message - shell: bash - run: echo "##[set-output name=commitMsg;]$(git log --format=%B -n 1 HEAD^2)" - id: extract_message - outputs: - # create an output that tells the following jobs whether or not we need to generate javadocs - generate_javadocs: ${{ steps.extract_message.outputs.commitMsg != '--- auto-generation of javadocs ---' }} - - publish-javadocs: - needs: get_javadocs_status - # only run this if we have not generated javadocs in last commit - if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'true' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - # extract the PR source branch name from the env variable where we can use it later - - name: Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_HEAD_REF#refs/heads/})" - id: extract_branch - # generate the javadocs into the target/site/apidocs folder (default) - - name: Generate javadocs with Maven - run: mvn javadoc:javadoc - # publish the generated javadocs into the /docs folder on a new commit in this branch - - name: Publish javadocs to GitHub Pages - uses: JamesIves/github-pages-deploy-action@4.1.4 - with: - branch: ${{ steps.extract_branch.outputs.branch }} - folder: target/site/apidocs - target-folder: docs - git-config-name: Continuous Integration - git-config-email: devs@sovren.com - commit-message: --- auto-generation of javadocs --- - token: ${{ secrets.JAVADOCS_CI_TOKEN }} - build: - needs: get_javadocs_status - # only run this if we have already generated javadocs in last commit - if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'false' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -70,10 +20,8 @@ jobs: run: mvn -B compile --file pom.xml unit-tests: - needs: get_javadocs_status runs-on: ubuntu-latest # only run this if we have already generated javadocs in last commit - if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'false' }} steps: - name: Checkout the latest code uses: actions/checkout@v2 diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/create-release.yml similarity index 51% rename from .github/workflows/maven-publish.yml rename to .github/workflows/create-release.yml index a1c502ab8..366efc656 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/create-release.yml @@ -1,28 +1,63 @@ # This workflow will build a package using Maven and then publish it to Maven Central when a release is created # For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path -name: maven-publish +name: create-release on: - release: - types: [published] + push: + branches: + - master workflow_dispatch: #add this option in case of a failure and we need to re-run jobs: - build: - + get-version-tag: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Get version + id: package_version + uses: PERES-Richard/maven-get-version-action@v3.0.0 + outputs: + version_tag: v${{ steps.package_version.outputs.version }} + check-tag-exists: + needs: get-version-tag + runs-on: ubuntu-latest + steps: + - uses: mukunku/tag-exists-action@v1.6.0 + id: check_tag + with: + tag: ${{ needs.get-version-tag.outputs.version_tag }} + outputs: + should_create_release: ${{ steps.check_tag.outputs.exists != 'true' }} + create-release: + needs: [check-tag-exists, get-version-tag] + if: ${{ needs.check-tag-exists.outputs.should_create_release == 'true' }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + make_latest: 'true' + tag_name: ${{ needs.get-version-tag.outputs.version_tag }} + name: ${{ needs.get-version-tag.outputs.version_tag }} + maven-publish: + needs: [create-release, check-tag-exists] + if: ${{ needs.check-tag-exists.outputs.should_create_release == 'true' }} runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: java-version: 1.8 - - name: Build with Maven run: mvn -B package -DskipTests --file pom.xml - - name: Set up Apache Maven Central uses: actions/setup-java@v1 with: # running setup-java again overwrites the settings.xml @@ -32,7 +67,6 @@ jobs: server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY_TK }} # Value of the GPG private key to import gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase - - name: Publish to Apache Maven Central run: mvn -B clean deploy -DskipTests env: diff --git a/.github/workflows/docs-publish.yml b/.github/workflows/docs-publish.yml new file mode 100644 index 000000000..8777062c8 --- /dev/null +++ b/.github/workflows/docs-publish.yml @@ -0,0 +1,49 @@ +# This workflow will generate javadocs, build, and test a package using Maven + +name: docs-publish + +on: + push: + branches: + - master + workflow_dispatch: #add this option in case of a failure and we need to re-run + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + # generate the javadocs into the target/site/apidocs folder (default) + - name: Generate javadocs with Maven + run: mvn javadoc:javadoc + # upload the generated docs into an artifact that can be used by the job below + - name: Upload Artifacts + uses: actions/upload-pages-artifact@v3 + with: + path: target/site/apidocs + deploy: + needs: build + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/src/main/java/com/textkernel/tx/TxClient.java b/src/main/java/com/textkernel/tx/TxClient.java index b6caad216..74b5dc8d9 100644 --- a/src/main/java/com/textkernel/tx/TxClient.java +++ b/src/main/java/com/textkernel/tx/TxClient.java @@ -571,7 +571,9 @@ public DeleteDocumentResponse deleteDocument(String indexId, String documentId) * @throws TxException Thrown when an API error occurs */ public DeleteMultipleDocumentsResponse deleteMultipleDocuments(String indexId, List documentIds) throws TxException { - RequestBody requestBody = createJsonBody(documentIds); + DeleteMultipleDocumentsRequest request = new DeleteMultipleDocumentsRequest(); + request.DocumentIds = documentIds; + RequestBody requestBody = createJsonBody(request); Request apiRequest = new Request.Builder() .url(_endpoints.multipleDocuments(indexId)) .delete(requestBody) diff --git a/src/main/java/com/textkernel/tx/models/api/indexes/DeleteMultipleDocumentsRequest.java b/src/main/java/com/textkernel/tx/models/api/indexes/DeleteMultipleDocumentsRequest.java new file mode 100644 index 000000000..f404e521d --- /dev/null +++ b/src/main/java/com/textkernel/tx/models/api/indexes/DeleteMultipleDocumentsRequest.java @@ -0,0 +1,17 @@ +// Copyright © 2023 Textkernel BV. All rights reserved. +// This file is provided for use by, or on behalf of, Textkernel licensees +// within the terms of their license of Textkernel products or Textkernel customers +// within the Terms of Service pertaining to the Textkernel SaaS products. + +package com.textkernel.tx.models.api.indexes; + +import java.util.List; + +/** + * Request body to delete multiple indexed documents + */ +public class DeleteMultipleDocumentsRequest { + + /** The document IDs to delete */ + public List DocumentIds; +} From 9d75d69bdb7fe898d37f0143c1a97c6b9d941392 Mon Sep 17 00:00:00 2001 From: JW Wesson Date: Fri, 25 Apr 2025 15:10:20 -0500 Subject: [PATCH 2/3] update version --- .github/pull_request_template.md | 2 +- README.md | 6 +++--- pom.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 03c7b148c..0f734ca63 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,4 +2,4 @@ - add the label `ignore-for-release` to prevent this PR from being linked to a release - Please fill out the description of what was changed/added/fixed in this PR - Be sure to link any issues -- Increment the version in the pom.xml if you want a release & maven publish to happen upon merge \ No newline at end of file +- Increment the version in the pom.xml and README.md if you want a release & maven publish to happen upon merge \ No newline at end of file diff --git a/README.md b/README.md index 73765a082..d87541f28 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The official Java SDK for the Textkernel Tx v10 API for resume/CV and job parsin ### Gradle Users Add this dependency to your project's build file: ``` -implementation "com.textkernel:tx-java:2.3.3" +implementation "com.textkernel:tx-java:2.3.4" ``` ### Maven Users @@ -22,13 +22,13 @@ Add this dependency to your project's POM: com.textkernel tx-java - 2.3.3 + 2.3.4 ``` ### Others You'll need to manually install the following JARs: -- The Textkernel Tx JAR from https://repo1.maven.org/maven2/com/textkernel/tx-java/2.3.3/tx-java-2.3.3.jar +- The Textkernel Tx JAR from https://repo1.maven.org/maven2/com/textkernel/tx-java/2.3.4/tx-java-2.3.4.jar - [Google Gson][gson_url] from https://repo1.maven.org/maven2/com/google/code/gson/gson/2.9.0/gson-2.9.0.jar - [Square OkHttp][okhttp_url] from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp/4.12.0/okhttp-4.12.0.jar diff --git a/pom.xml b/pom.xml index e29d15020..33870be42 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.textkernel tx-java - 2.3.3 + 2.3.4 jar Textkernel Tx Java SDK From d16a46d027df824d869faa0570d8f66206db98d9 Mon Sep 17 00:00:00 2001 From: JW Wesson Date: Fri, 25 Apr 2025 15:15:12 -0500 Subject: [PATCH 3/3] fix unit tests --- src/test/java/com/textkernel/tx/integration/ParsingTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/textkernel/tx/integration/ParsingTests.java b/src/test/java/com/textkernel/tx/integration/ParsingTests.java index fb1d378cd..1a96af237 100644 --- a/src/test/java/com/textkernel/tx/integration/ParsingTests.java +++ b/src/test/java/com/textkernel/tx/integration/ParsingTests.java @@ -66,7 +66,7 @@ public void testLargeDocumentParse() { Client.parseResume(new ParseRequest(new Document(new byte[40_000_000], LocalDate.now()), null)); }); - String expected = "Request body too large."; + String expected = "Request body was too large"; assertEquals(expected, e.getMessage().substring(0, expected.length())); } @@ -614,7 +614,7 @@ public void TestProfessionNormalization() throws Exception { assertNotNull(response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ISCO); assertNotNull(response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ONET); assertNotNull(response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ONET.Version); - assertEquals("2010", response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ONET.Version); + assertEquals("2019", response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ONET.Version); assertNotEquals(0, response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.Confidence); assertNotNull(response.Value.ResumeData.EmploymentHistory.Positions.get(1).NormalizedProfession);