Skip to content

Commit

Permalink
✨ Add status query
Browse files Browse the repository at this point in the history
  • Loading branch information
dankolbman committed Nov 4, 2019
1 parent dd36c44 commit 207b653
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ RUN pip install awscli

ADD . /app

# Bake version number
RUN COMMIT=`git rev-parse --short HEAD` && echo "COMMIT=\"${COMMIT}\"" > /app/coordinator/version_info.py \
&& VERSION=`git describe --always --tags` && echo "VERSION=\"${VERSION}\"" >> /app/coordinator/version_info.py


RUN python /app/setup.py install \
&& python /app/manage.py collectstatic -v0 --noinput

Expand Down
26 changes: 24 additions & 2 deletions coordinator/graphql/schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from graphene import relay, ObjectType, Schema
from django.core.cache import cache
from graphene import relay, ObjectType, Field, Schema, String
from graphene_django.types import DjangoObjectType
from graphene_django.filter import DjangoFilterConnectionField

Expand All @@ -14,6 +15,17 @@
from .users import Query as UserQuery


def get_version_info():
from coordinator.version_info import COMMIT, VERSION
return {"commit": COMMIT, "version": VERSION}


class Status(ObjectType):
name = String()
version = String()
commit = String()


class Query(
ObjectType,
ReleaseQuery,
Expand All @@ -24,7 +36,17 @@ class Query(
StudyQuery,
UserQuery,
):
pass
status = Field(Status)

def resolve_status(parent, info):
"""
Return status information about the coordinator.
"""
# Retrieve from cache in the case that we have to parse git commands
# to get version details.
info = cache.get_or_set("VERSION_INFO", get_version_info)

return Status(name="Kids First Release Coordinator", **info)


class Mutation(
Expand Down
10 changes: 10 additions & 0 deletions coordinator/version_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file will be re-written during the Docker build. For development, the
# following defaults are provided.
import subprocess

VERSION = subprocess.check_output(
["git", "describe", "--always", "--tags"]
).strip().decode()
COMMIT = subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"]
).strip().decode()

0 comments on commit 207b653

Please sign in to comment.