Argovis's API is automatically templated from the OpenAPI specification in several specification files:
core-spec.json
: API spec for Argovis core at University of Colorado. Serves all data products except the ones enumerated below for our partner deployments.miami-spec.json
: spec for the Global Drifter Program deployment, hosted by University of Miami.
These specifications are the single source of truth for the definition of this API! By adhering to this specification, we are able to leverage the OpenAPI ecosystem of tools for automatically generating docs, server side stubs and client code. To support this, we use the following build workflow.
- After modifying the specification documents to describe how you want to update the API, build the server stubs with:
bash build.sh
-
Commit these changes to the
templates
branch. -
Merge these changes into the
server
branch; that way, we can merge new routes from the templates into previously-written custom logic, and have merge conflicts identify any places where updates to old routes may need attention. -
Implement custom logic and commit to the
server
branch, which will be the build and release branch. -
Image can be built from the local
Dockerfile
-
API endpoint testing is handled by supertest, mocha and chai, and is performed from an external test container that issues requests to a build of the main api container. See
.travis.yml
for a detailed description of how to set these tests up and run them locally.
When all tests on the server
branch are passing, releases may be made with the following procedures, assuming the base image hasn't changed (see below for when base images need an update, ie when node or package dep versions change)
-
Choose a release tag; this should typically be a standard semver, possibly suffixed with
-rc-x
for release candidates if necessary. -
Stamp a release of the
server
branch on GitHub, using the release tag you chose. -
Build the API container:
docker image build -t argovis/api:<release tag> .
-
Push to Docker Hub:
docker image push argovis/api:<release tag>
In general, the base image for the API shouldn't change often; it is meant to capture package dependencies, and should be as stable as possible. But, when dependencies need an update (most typically after package.json
changes), follow this procedure.
-
Build a new base image, tagged with the build date:
docker image build -f Dockerfile-base -t argovis/api:base-yymmdd .
-
Update
Dockerfile
to build from your new base image (very firstFROM
line). -
Build a new testing base image, tagged with the build date:
docker image build -f Dockerfile-test-base -t argovis/api:test-base-yymmdd .
-
Update
Dockerfile-test
to build from your new test base image. -
Build and test per the
.travis.yml
to make sure tests still pass with this new base. -
Push to Docker Hub:
docker image push argovis/api:base-yymmdd
anddocker image push argovis/api:test-base-yymmdd
, and push the updates to theserver
branch to GitHub.