diff --git a/.github/workflows/_test-code-samples.yml b/.github/workflows/_test-smoke.yml similarity index 93% rename from .github/workflows/_test-code-samples.yml rename to .github/workflows/_test-smoke.yml index 1c6c587a..6f44cd7b 100644 --- a/.github/workflows/_test-code-samples.yml +++ b/.github/workflows/_test-smoke.yml @@ -1,4 +1,4 @@ -name: Test Code Samples +name: Smoke Test on: workflow_call: @@ -46,6 +46,10 @@ jobs: run: | ./tests/test_v2_code_samples.sh + - name: Tests v2 CLI commands + run: | + ./tests/test_v2_cli.sh + - name: Tests v1 sample code run: | ./tests/test_v1_code_samples.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6527968f..72fcbf18 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -14,11 +14,11 @@ jobs: uses: ./.github/workflows/_test-units.yml needs: static_analysis secrets: inherit + test_smoke: + uses: ./.github/workflows/_test-smoke.yml + needs: static_analysis + secrets: inherit test_integrations: uses: ./.github/workflows/_test-integrations.yml needs: test_units secrets: inherit - test_code_samples: - uses: ./.github/workflows/_test-code-samples.yml - needs: test_units - secrets: inherit diff --git a/src/v2/cli.ts b/src/v2/cli.ts index b499bf44..fc7fa8fd 100644 --- a/src/v2/cli.ts +++ b/src/v2/cli.ts @@ -77,11 +77,11 @@ export function cli() { .option("-k, --api-key ", "your Mindee API key"); const inferenceTypes = [ - { name: "extract", description: "Extract data from a document.", product: Extraction }, + { name: "extraction", description: "Extract data from a document.", product: Extraction }, { name: "crop", description: "Crop a document.", product: Crop }, { name: "split", description: "Split a document into pages.", product: Split }, { name: "ocr", description: "Read text from a document.", product: Ocr }, - { name: "classify", description: "Classify a document.", product: Classification }, + { name: "classification", description: "Classify a document.", product: Classification }, ]; for (const inference of inferenceTypes) { diff --git a/tests/test_v2_cli.sh b/tests/test_v2_cli.sh new file mode 100755 index 00000000..6a07b1d8 --- /dev/null +++ b/tests/test_v2_cli.sh @@ -0,0 +1,41 @@ +#!/bin/sh +set -e + +TEST_FILE='./tests/data/file_types/pdf/blank_1.pdf' + +for f in $( + find docs/code_samples -maxdepth 1 -name "v2_*.txt" | sort -h +) +do + echo "###############################################" + echo "${f}" + echo "###############################################" + echo + + if echo "${f}" | grep -q "v2_classification.txt" + then + node ./dist/bin/mindeeV2.js -d classification -m "${MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID}" "${TEST_FILE}" + fi + + if echo "${f}" | grep -q "v2_crop.txt" + then + node ./dist/bin/mindeeV2.js -d crop -m "${MINDEE_V2_SE_TESTS_CROP_MODEL_ID}" "${TEST_FILE}" + fi + + if echo "${f}" | grep -q "v2_extraction.txt" + then + node ./dist/bin/mindeeV2.js -d extraction -m "${MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID}" "${TEST_FILE}" + fi + + if echo "${f}" | grep -q "v2_ocr.txt" + then + node ./dist/bin/mindeeV2.js -d ocr -m "${MINDEE_V2_SE_TESTS_OCR_MODEL_ID}" "${TEST_FILE}" + fi + + if echo "${f}" | grep -q "v2_split.txt" + then + node ./dist/bin/mindeeV2.js -d split -m "${MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID}" "${TEST_FILE}" + fi + + sleep 0.5 # avoid too many request errors +done diff --git a/tests/test_v2_code_samples.sh b/tests/test_v2_code_samples.sh index c12fadc1..4e74e258 100755 --- a/tests/test_v2_code_samples.sh +++ b/tests/test_v2_code_samples.sh @@ -22,11 +22,6 @@ do sed "s/MY_API_KEY/${MINDEE_V2_API_KEY}/" "${f}" > $OUTPUT_FILE sed -i "s/\/path\/to\/the\/file.ext/..\/mindee-api-nodejs\/tests\/data\/file_types\/pdf\/blank_1.pdf/" $OUTPUT_FILE - if echo "${f}" | grep -q "v2_extraction.txt" - then - sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID}/" $OUTPUT_FILE - fi - if echo "${f}" | grep -q "v2_classification.txt" then sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID}/" $OUTPUT_FILE @@ -37,9 +32,9 @@ do sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_CROP_MODEL_ID}/" $OUTPUT_FILE fi - if echo "${f}" | grep -q "v2_split.txt" + if echo "${f}" | grep -q "v2_extraction.txt" then - sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID}/" $OUTPUT_FILE + sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID}/" $OUTPUT_FILE fi if echo "${f}" | grep -q "v2_ocr.txt" @@ -47,6 +42,11 @@ do sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_OCR_MODEL_ID}/" $OUTPUT_FILE fi + if echo "${f}" | grep -q "v2_split.txt" + then + sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID}/" $OUTPUT_FILE + fi + sleep 0.5 # avoid too many request errors node $OUTPUT_FILE done