Run NPM tests using couchbase service container #426
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run NPM tests using couchbase service container | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
- cron: "0 11 * * 0" | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- name: Update repositories | |
run: | | |
apt update || echo "apt-update failed" # && apt -y upgrade | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Setup couchbase | |
run: | | |
apt install -y iputils-ping || echo "apt-install failed" | |
ping -c 1 couchbase && ( | |
apt install -y socat | |
socat TCP-LISTEN:8091,fork TCP:couchbase:8091 & | |
socat TCP-LISTEN:8092,fork TCP:couchbase:8092 & | |
socat TCP-LISTEN:8093,fork TCP:couchbase:8093 & | |
socat TCP-LISTEN:8094,fork TCP:couchbase:8094 & | |
socat TCP-LISTEN:8095,fork TCP:couchbase:8095 & | |
socat TCP-LISTEN:8096,fork TCP:couchbase:8096 & | |
socat TCP-LISTEN:9140,fork TCP:couchbase:9140 & | |
socat TCP-LISTEN:11210,fork TCP:couchbase:11210 & | |
socat TCP-LISTEN:11211,fork TCP:couchbase:11211 & | |
socat TCP-LISTEN:11207,fork TCP:couchbase:11207 & | |
socat TCP-LISTEN:18091,fork TCP:couchbase:18091 & | |
socat TCP-LISTEN:18092,fork TCP:couchbase:18092 & | |
socat TCP-LISTEN:18093,fork TCP:couchbase:18093 & | |
socat TCP-LISTEN:18094,fork TCP:couchbase:18094 & | |
socat TCP-LISTEN:18095,fork TCP:couchbase:18095 & | |
socat TCP-LISTEN:18096,fork TCP:couchbase:18096 & | |
) && echo "Initialized couchbase port forwarding" || echo "ping couchbase failed, not forwarding ports" | |
printf "Waiting for CB startup..." | |
wget -O /dev/null http://localhost:8091/ && echo "DONE" || (echo "FAIL" && panic) | |
curl -v -X POST http://localhost:8091/node/controller/setupServices -d 'services=kv%2Cn1ql%2Cindex' | |
curl -v -X POST http://localhost:8091/pools/default -d 'memoryQuota=256' -d 'indexMemoryQuota=256' | |
curl -u Administrator:password -v -X POST http://localhost:8091/settings/web -d 'password=password&username=Administrator&port=SAME' | |
curl -v -X POST http://localhost:8091/pools/default/buckets \ | |
-u Administrator:password \ | |
-d name=user_profile \ | |
-d bucketType=couchbase\ | |
-d ramQuotaMB=512 \ | |
-d durabilityMinLevel=majorityAndPersistActive | |
curl -u Administrator:password -v -X POST http://localhost:8091/settings/indexes -d 'storageMode=memory_optimized' | |
curl -u Administrator:password -v -X GET http://localhost:8091/pools/default | jq '.' | grep hostname | |
- uses: actions/checkout@v2 | |
- name: Setup node modules | |
run: npm ci | |
- name: Setup unit tests | |
run: npm run init-test-db && npm run init-test-index | |
- name: Unit Tests | |
run: npm test | |
- name: Report Status | |
if: always() | |
uses: ravsamhq/notify-slack-action@v1 | |
with: | |
status: ${{ job.status }} | |
notify_when: 'failure,warnings' | |
notification_title: 'Repo: *{repo}*' | |
message_format: '{emoji} *{status_message}* in <{repo_url}|{repo}@{branch}> on <{commit_url}|{commit_sha}>' | |
footer: '<{run_url}|View Full Run on GitHub>' | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }} | |
services: | |
couchbase: | |
image: public.ecr.aws/z2f7n8a1/couchbase-da-containers:couchbase-neo | |
options: >- | |
--health-cmd "wget -q -O - localhost:8091" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 10 | |
ports: | |
- 8091:8091 | |
- 8092:8092 | |
- 8093:8093 | |
- 8094:8094 | |
- 8095:8095 | |
- 8096:8096 | |
- 9140:9140 | |
- 11210:11210 | |
- 11211:11211 | |
- 11207:11207 | |
- 18091:18091 | |
- 18092:18092 | |
- 18093:18093 | |
- 18094:18094 | |
- 18095:18095 | |
- 18096:18096 |