mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-14 20:30:06 +00:00
ci: update tests for new cobalt
This commit is contained in:
parent
6d817f149e
commit
350e1d4d4f
2 changed files with 15 additions and 25 deletions
30
.github/test.sh
vendored
30
.github/test.sh
vendored
|
@ -18,14 +18,15 @@ test_api() {
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
-H "Content-Type: 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)
|
STATUS=$(echo "$API_RESPONSE" | jq -r .status)
|
||||||
STREAM_URL=$(echo "$API_RESPONSE" | jq -r .url)
|
STREAM_URL=$(echo "$API_RESPONSE" | jq -r .url)
|
||||||
[ "$STATUS" = stream ] || exit 1;
|
[ "$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 \
|
| grep -i content-length \
|
||||||
| cut -d' ' -f2 \
|
| cut -d' ' -f2 \
|
||||||
| tr -d '\r')
|
| tr -d '\r')
|
||||||
|
@ -37,34 +38,27 @@ test_api() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test_web() {
|
|
||||||
waitport 3001
|
|
||||||
curl -m 3 http://127.0.0.1:3001/onDemand?blockId=0 \
|
|
||||||
| grep -q '"status":"success"'
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_api() {
|
setup_api() {
|
||||||
export API_PORT=3000
|
export API_PORT=3000
|
||||||
export API_URL=http://localhost:3000
|
export API_URL=http://localhost:3000
|
||||||
timeout 10 npm run start
|
timeout 10 pnpm run --prefix api start &
|
||||||
|
API_PID=$!
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_web() {
|
setup_web() {
|
||||||
export WEB_PORT=3001
|
pnpm run --prefix web build
|
||||||
export WEB_URL=http://localhost:3001
|
|
||||||
export API_URL=http://localhost:3000
|
|
||||||
timeout 5 npm run start
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cd "$(git rev-parse --show-toplevel)"
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
npm i
|
pnpm install --frozen-lockfile
|
||||||
|
|
||||||
if [ "$1" = "api" ]; then
|
if [ "$1" = "api" ]; then
|
||||||
setup_api &
|
setup_api
|
||||||
test_api
|
test_api
|
||||||
|
[ "$API_PID" != "" ] \
|
||||||
|
&& kill "$API_PID"
|
||||||
elif [ "$1" = "web" ]; then
|
elif [ "$1" = "web" ]; then
|
||||||
setup_web &
|
setup_web
|
||||||
test_web
|
|
||||||
else
|
else
|
||||||
echo "usage: $0 <api/web>" >&2
|
echo "usage: $0 <api/web>" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
|
@ -12,11 +12,7 @@ jobs:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Check that lockfile does not need an update
|
- name: Check that lockfile does not need an update
|
||||||
run: |
|
run: pnpm install --frozen-lockfile
|
||||||
cp package-lock.json before.json
|
|
||||||
npm ci
|
|
||||||
npm i --package-lock-only
|
|
||||||
diff before.json package-lock.json
|
|
||||||
|
|
||||||
test-web:
|
test-web:
|
||||||
name: web sanity check
|
name: web sanity check
|
||||||
|
@ -45,7 +41,7 @@ jobs:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- id: checkServices
|
- 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:
|
test-services:
|
||||||
needs: check-services
|
needs: check-services
|
||||||
|
@ -58,4 +54,4 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- run: npm ci && node src/util/test-ci run-tests-for ${{ matrix.service }}
|
- run: npm ci && node api/src/util/test-ci run-tests-for ${{ matrix.service }}
|
Loading…
Reference in a new issue