Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Code Samples
name: Smoke Test

on:
workflow_call:
Expand Down Expand Up @@ -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 }}
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/v2/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ export function cli() {
.option("-k, --api-key <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) {
Expand Down
41 changes: 41 additions & 0 deletions tests/test_v2_cli.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions tests/test_v2_code_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,16 +32,21 @@ 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"
then
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
Loading