diff --git a/.github/test.sh b/.github/test.sh index 80de1fcd..4ae96541 100755 --- a/.github/test.sh +++ b/.github/test.sh @@ -18,14 +18,15 @@ test_api() { -X POST \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ - -d '{"url":"https://vine.co/v/huwVJIEJW50", "isAudioOnly": true}') + -d '{"url":"https://www.tiktok.com/@fatfatmillycat/video/7195741644585454894"}') - echo "$API_RESPONSE" + echo "API_RESPONSE=$API_RESPONSE" STATUS=$(echo "$API_RESPONSE" | jq -r .status) STREAM_URL=$(echo "$API_RESPONSE" | jq -r .url) [ "$STATUS" = stream ] || exit 1; + S=$(curl -I -m 3 "$STREAM_URL") - CONTENT_LENGTH=$(curl -I -m 3 "$STREAM_URL" \ + CONTENT_LENGTH=$(echo "$S" \ | grep -i content-length \ | cut -d' ' -f2 \ | tr -d '\r') @@ -37,34 +38,27 @@ test_api() { fi } -test_web() { - waitport 3001 - curl -m 3 http://127.0.0.1:3001/onDemand?blockId=0 \ - | grep -q '"status":"success"' -} - setup_api() { export API_PORT=3000 export API_URL=http://localhost:3000 - timeout 10 npm run start + timeout 10 pnpm run --prefix api start & + API_PID=$! } setup_web() { - export WEB_PORT=3001 - export WEB_URL=http://localhost:3001 - export API_URL=http://localhost:3000 - timeout 5 npm run start + pnpm run --prefix web build } cd "$(git rev-parse --show-toplevel)" -npm i +pnpm install --frozen-lockfile if [ "$1" = "api" ]; then - setup_api & + setup_api test_api + [ "$API_PID" != "" ] \ + && kill "$API_PID" elif [ "$1" = "web" ]; then - setup_web & - test_web + setup_web else echo "usage: $0 " >&2 exit 1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0dd28cb9..652f2a47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,11 +12,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Check that lockfile does not need an update - run: | - cp package-lock.json before.json - npm ci - npm i --package-lock-only - diff before.json package-lock.json + run: pnpm install --frozen-lockfile test-web: name: web sanity check @@ -45,7 +41,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - id: checkServices - run: npm ci && echo "service_list=$(node src/util/test-ci get-services)" >> "$GITHUB_OUTPUT" + run: npm ci && echo "service_list=$(node api/src/util/test-ci get-services)" >> "$GITHUB_OUTPUT" test-services: needs: check-services @@ -58,4 +54,4 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - run: npm ci && node src/util/test-ci run-tests-for ${{ matrix.service }} \ No newline at end of file + - run: npm ci && node api/src/util/test-ci run-tests-for ${{ matrix.service }} \ No newline at end of file