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
75 changes: 75 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Test Neotoma API

on:
workflow_run:
workflows: ["Deploy Neotoma API"]
types: [completed]
branches: [develop]
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
timeout-minutes: 25

strategy:
fail-fast: false
matrix:
include:
- name: dev
flag: '-d'
host: https://api-dev.neotomadb.org
- name: production
flag: '-p'
host: https://api.neotomadb.org

name: test (${{ matrix.name }})

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

# genoatt.sh and runmochabatch.sh invoke `oatts` and `mocha` bare. Those resolve
# under `yarn run` but not under `run: bash …`, so put the bin dir on PATH.
- name: Put node_modules/.bin on PATH
run: echo "$PWD/node_modules/.bin" >> "$GITHUB_PATH"

- name: Build the OpenAPI spec
run: yarn build:openapi

- name: Wait for ${{ matrix.host }} to be ready
run: |
MAX_ATTEMPTS=10
ATTEMPT=1
until curl -sf ${{ matrix.host }}/healthcheck > /dev/null; do
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS..."
[ $ATTEMPT -eq $MAX_ATTEMPTS ] && echo "${{ matrix.host }} not ready" && exit 1
ATTEMPT=$((ATTEMPT + 1))
sleep 15
done
echo "${{ matrix.host }} is ready"

# The oatts-generated suites hardcode their target host, so they must be
# regenerated per target — APIPATH alone only redirects the hand-written suites.
- name: Generate tests targeting ${{ matrix.host }}
run: bash genoatt.sh ${{ matrix.flag }}

- name: Run tests against ${{ matrix.host }}
run: bash runmochabatch.sh ${{ matrix.flag }}

- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report-${{ matrix.name }}
path: public/tests.html
8 changes: 7 additions & 1 deletion genoatt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ HELP
run_oatt() {

rm ./test/v*.js
oatts generate --host $remote -s ./openapi.yaml -w test
oatts generate --host $remote -m $scheme -s ./openapi.yaml -w test
yarn dlx eslint --quiet --fix ./test > genoatt.log

# oatts is a bit silly in picking its variables. We need to make sure that we're
Expand Down Expand Up @@ -53,6 +53,9 @@ run_oatt() {

test=0
remote=localhost:3001
# The remote hosts 301-redirect http -> https, so generated tests must use the right
# scheme. oatts defaults to http when the flag is absent.
scheme=http

while getopts "htldpa" opt; do
case $opt in
Expand All @@ -68,12 +71,15 @@ remote=localhost:3001
;;
d)
remote=api-dev.neotomadb.org
scheme=https
;;
p)
remote=api.neotomadb.org
scheme=https
;;
a)
remote=neotomaapi-env.eba-wd29jtvf.us-east-2.elasticbeanstalk.com
scheme=https
;;
*)
echo You didn\'t use the correct flag.
Expand Down
34 changes: 34 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2345,6 +2345,8 @@ components:
type: array
geography:
$ref: '#/components/schemas/geography'
recdatecreated:
$ref: '#/components/schemas/recdatecreated'
sitedescription:
$ref: '#/components/schemas/sitedescription'
siteid:
Expand Down Expand Up @@ -3345,6 +3347,38 @@ paths:
tags:
- Lithology metadata
- v2.0
/v2.0/data/datasets/{datasetid}/assays:
get:
description: Returns the aeDNA assays (and their sequencing libraries) linked to a dataset.
parameters:
- $ref: '#/components/parameters/datasetidPath'
responses:
'200':
content:
application/json:
schema:
type: object
Comment on lines +3359 to +3360
description: Assays
summary: aeDNA assay and library metadata for a dataset.
tags:
- Assay metadata
- v2.0
/v2.0/data/datasets/{datasetid}/projects:
get:
description: Returns the research projects (and their participants) linked to a dataset.
parameters:
- $ref: '#/components/parameters/datasetidPath'
responses:
'200':
content:
application/json:
schema:
type: object
description: Projects
summary: Project and participant metadata for a dataset.
tags:
- Project metadata
- v2.0
/v2.0/data/datasets/{datasetid}/publications:
get:
description: Returns publications data associated with specific datasets.
Expand Down
2 changes: 2 additions & 0 deletions openapi/components/schemas/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,8 @@ sitesv2:
type: array
geography:
$ref: '#/components/schemas/geography'
recdatecreated:
$ref: '#/components/schemas/recdatecreated'
sitedescription:
$ref: '#/components/schemas/sitedescription'
siteid:
Expand Down
32 changes: 32 additions & 0 deletions openapi/paths/v20/data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,38 @@
tags:
- Lithology metadata
- v2.0
/v2.0/data/datasets/{datasetid}/assays:
get:
description: Returns the aeDNA assays (and their sequencing libraries) linked to a dataset.
parameters:
- $ref: '#/components/parameters/datasetidPath'
responses:
'200':
content:
application/json:
schema:
type: object
Comment on lines +345 to +346
description: Assays
summary: aeDNA assay and library metadata for a dataset.
tags:
- Assay metadata
- v2.0
/v2.0/data/datasets/{datasetid}/projects:
get:
description: Returns the research projects (and their participants) linked to a dataset.
parameters:
- $ref: '#/components/parameters/datasetidPath'
responses:
'200':
content:
application/json:
schema:
type: object
description: Projects
summary: Project and participant metadata for a dataset.
tags:
- Project metadata
- v2.0
/v2.0/data/datasets/{datasetid}/publications:
get:
description: Returns publications data associated with specific datasets.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"start": "NODE_ENV=production nodemon --legacy-watch app.js",
"dev": "NODE_ENV=development nodemon --legacy-watch app.js",
"test": "node ./node_modules/mocha/bin/mocha --config=test/.mocharc.yml --reporter-options reportDir=public,reportFilename=tests",
"test": "APIPATH=${APIPATH:-http://localhost:3001/} node ./node_modules/mocha/bin/mocha --config=test/.mocharc.yml --reporter-options reportDir=public,reportFilename=tests",
"build:openapi": "(cd ./openapi && node ./scripts/build-openapi.js)",
"validate:openapi": "yarn build:openapi && bash genoatt.sh && sleep 4 && bash runmochabatch.sh"
},
Expand Down
2 changes: 1 addition & 1 deletion public/tests.html

Large diffs are not rendered by default.

Loading
Loading