Skip to content

Commit

Permalink
Update tool to schemas 1.1.2 (#62)
Browse files Browse the repository at this point in the history
* Update root files and CI workflow

* Run openapi generator

* Update tool info

* Update target branch in dependabot config
  • Loading branch information
tschaffter authored Jun 2, 2021
1 parent 25926c4 commit 9e9c4da
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ channel that best matches the topic of your request.

<!-- Links -->

[Code of Conduct]: https://github.com/nlpsandbox/date-annotator-example/blob/develop/.github/CODE_OF_CONDUCT.md
[Code of Conduct]: CODE_OF_CONDUCT.md
[upstream remote]: https://help.github.com/en/articles/configuring-a-remote-for-a-fork
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[docs site]: https://github.com/nlpsandbox/nlpsandbox-website-synapse
Expand Down
20 changes: 5 additions & 15 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,28 @@ updates:
directory: "/"
schedule:
interval: "monthly"
target-branch: "develop"
reviewers:
- "nlpsandbox/maintainers"
target-branch: "main"

- package-ecosystem: "docker"
directory: "/server"
schedule:
interval: "monthly"
target-branch: "develop"
reviewers:
- "nlpsandbox/maintainers"
target-branch: "main"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
target-branch: "develop"
reviewers:
- "nlpsandbox/maintainers"
target-branch: "main"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
target-branch: "develop"
reviewers:
- "nlpsandbox/maintainers"
target-branch: "main"

- package-ecosystem: "pip"
directory: "/server"
schedule:
interval: "monthly"
target-branch: "develop"
reviewers:
- "nlpsandbox/maintainers"
target-branch: "main"
120 changes: 70 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,74 @@ on:
push:
branches:
- main
- develop
tags:
- '*.*.*'
pull_request:

env:
docker_repository: nlpsandbox/person-name-annotator-example
docker_repository: docker.synapse.org/syn22277123/person-name-annotator-example

jobs:
configure:
runs-on: ubuntu-latest
steps:
- name: Create configuration
run: |
DOCKER_IMAGE=${{ env.docker_repository }}
VERSION=noop
PUSH=false
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
PUSH=true
elif [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
PUSH=true
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
PUSH=true
fi
printf "%s\n" \
"version=${VERSION}" \
"tags=${TAGS}" \
"created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
"push=${PUSH}" | tee -a .github_env
- name: Upload .github_env
uses: actions/upload-artifact@v2
with:
name: GITHUB_ENV
path: .github_env

lint:
needs: [configure]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Lint Dockerfiles
uses: docker://hadolint/hadolint:latest
with:
entrypoint: hadolint
args: server/Dockerfile

- name: Validate docker-compose.yml
run: |
docker-compose -f docker-compose.yml config >/dev/null
- name: Check that packages in requirements.txt files are in asc order
run: |
sort -f --check server/requirements.txt
sort -f --check server/test-requirements.txt
- name: Lint Python code with Flake8
uses: docker://alpine/flake8:latest
with:
Expand All @@ -44,15 +87,18 @@ jobs:
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
cd server
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: |
cd server
Expand All @@ -63,68 +109,42 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=${{ env.docker_repository }}
VERSION=noop
PUSH=false
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
PUSH=true
elif [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
PUSH=true
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
PUSH=true
# elif [ "${{ github.event_name }}" = "push" ]; then
# TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=push::${PUSH}

- name: Download .github_env
uses: actions/download-artifact@v2
with:
name: GITHUB_ENV
path: .

- name: Restore $GITHUB_ENV
run: cat .github_env >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: steps.prep.outputs.push == 'true'

- name: Login to Synapse Docker Registry
if: env.push == 'true'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: docker.synapse.org
username: ${{ secrets.SYNAPSE_USERNAME }}
password: ${{ secrets.SYNAPSE_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: server
file: server/Dockerfile
platforms: linux/amd64
push: ${{ steps.prep.outputs.push }}
tags: ${{ steps.prep.outputs.tags }}
push: ${{ env.push }}
tags: ${{ env.tags }}
labels: |
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.created=${{ env.created }}
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.version=${{ env.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.name }}
- name: Docker Hub Description
if: steps.prep.outputs.push == 'true'
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ env.docker_repository }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ found in the clinical note.

### Specification

- Person Name Annotator API version: 1.1.1
- Tool version: 1.1.1
- Person Name Annotator API version: 1.1.2
- Tool version: 1.1.2
- Docker image: [nlpsandbox/person-name-annotator-example]

## Model
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ version: "3.8"

services:
person-name-annotator:
image: nlpsandbox/person-name-annotator-example:1.1.1
image: docker.synapse.org/syn22277123/person-name-annotator-example:1.1.2
build:
context: server
dockerfile: Dockerfile
container_name: person-name-annotator
networks:
- nlp-sandbox-internal
- nlpsandbox-internal

nginx:
image: nginx:1.19.6-alpine
Expand All @@ -21,14 +21,14 @@ services:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/templates:/etc/nginx/templates:ro
networks:
- nlp-sandbox
- nlp-sandbox-internal
- nlpsandbox
- nlpsandbox-internal
ports:
- "80:80"
depends_on:
- person-name-annotator

networks:
nlp-sandbox:
nlp-sandbox-internal:
nlpsandbox:
nlpsandbox-internal:
internal: true
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/openapi_server/controllers/tool_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ def get_tool(): # noqa: E501
"""
tool = Tool(
name="person-name-annotator-example",
version="1.1.1",
version="1.1.2",
license=License.APACHE_2_0,
repository="github:nlpsandbox/person-name-annotator-example",
description="Example implementation of the NLP Sandbox Person " +
"Name Annotator",
author="NLP Sandbox Team",
author_email="[email protected]",
author_email="[email protected]",
url="https://github.com/nlpsandbox/person-name-annotator-example",
type="nlpsandbox:person-name-annotator",
api_version="1.1.1"
api_version="1.1.2"
)
return tool, 200

Expand Down
8 changes: 4 additions & 4 deletions server/openapi_server/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ info:
name: Apache 2.0
url: https://github.com/nlpsandbox/nlpsandbox-schemas/blob/develop/LICENSE
title: NLP Sandbox Person Name Annotator API
version: 1.1.1
version: 1.1.2
x-logo:
url: https://nlpsandbox.github.io/nlpsandbox-schemas/logo.png
servers:
Expand Down Expand Up @@ -407,7 +407,7 @@ components:
authorEmail: [email protected]
url: https://example.com
type: nlpsandbox:date-annotator
apiVersion: 1.1.1
apiVersion: 1.1.2
properties:
name:
description: The tool name
Expand Down Expand Up @@ -478,7 +478,7 @@ components:
authorEmail: [email protected]
url: https://example.com
type: nlpsandbox:date-annotator
apiVersion: 1.1.1
apiVersion: 1.1.2
- name: awesome-nlp-tool
version: 1.0.6
license: apache-2.0
Expand All @@ -488,7 +488,7 @@ components:
authorEmail: [email protected]
url: https://example.com
type: nlpsandbox:date-annotator
apiVersion: 1.1.1
apiVersion: 1.1.2
properties:
tools:
description: A list of tools
Expand Down

0 comments on commit 9e9c4da

Please sign in to comment.