-
Notifications
You must be signed in to change notification settings - Fork 62
63 lines (53 loc) · 2.06 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Test Spec
on: [push, pull_request]
env:
OPENSEARCH_INITIAL_ADMIN_PASSWORD: BobgG7YrtsdKf9M
jobs:
integ-tests:
name: Build and Test
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Build
run: |-
mkdir -p ../build
npm install
npm run merge -- --source ./spec --output ./build/opensearch-openapi.yaml
npm run merge -- --source ./spec --output ./build/opensearch-openapi-tested.yaml --x-include=x-tested
- name: Build and Run Docker Container
run: |
docker build coverage --tag opensearch-with-api-plugin
docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e OPENSEARCH_INITIAL_ADMIN_PASSWORD="$OPENSEARCH_INITIAL_ADMIN_PASSWORD" opensearch-with-api-plugin
sleep 15
- name: Display OpenSearch Info
run: |
curl -ks -u "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" https://localhost:9200/ | jq
- name: Test
run: |-
npm run dredd -- --user "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" ./build/opensearch-openapi-tested.yaml https://localhost:9200
- name: Gather Test Coverage
id: test-coverage
shell: bash
run: |
current=`docker run --rm -i mikefarah/yq:latest -r '.paths | keys | length' < build/opensearch-openapi-tested.yaml`
total=`docker run --rm -i mikefarah/yq:latest -r '.paths | keys | length' < build/opensearch-openapi.yaml`
percent=$((current * 100 / total))
echo "$current/$total ($percent%) APIs tested."
cat >>"coverage-tests.json" <<EOL
{
"pull_request":${{ github.event.number }},
"current":$current,
"total":$total,
"percent":$percent
}
EOL
- uses: actions/upload-artifact@v4
with:
name: coverage-tests
path: coverage-tests.json