diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a17399c..d815368 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -126,7 +126,7 @@ channel that best matches the topic of your request. -[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 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 147b0bf..5c3393d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7dd867d..b1af37c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 @@ -63,49 +109,30 @@ 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 @@ -113,18 +140,11 @@ jobs: 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 }} diff --git a/README.md b/README.md index 38a1545..93f2bba 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 6831460..c56d16b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -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 diff --git a/package-lock.json b/package-lock.json index b510592..cc1ef09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -288,9 +288,9 @@ } }, "node_modules/balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, "node_modules/base64-js": { @@ -1666,9 +1666,9 @@ } }, "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, "base64-js": { diff --git a/server/openapi_server/controllers/tool_controller.py b/server/openapi_server/controllers/tool_controller.py index 98f5101..08f82a5 100644 --- a/server/openapi_server/controllers/tool_controller.py +++ b/server/openapi_server/controllers/tool_controller.py @@ -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="thomas.schaffter@sagebionetworks.org", + author_email="team@nlpsandbox.io", 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 diff --git a/server/openapi_server/openapi/openapi.yaml b/server/openapi_server/openapi/openapi.yaml index 930773d..5c83eba 100644 --- a/server/openapi_server/openapi/openapi.yaml +++ b/server/openapi_server/openapi/openapi.yaml @@ -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: @@ -407,7 +407,7 @@ components: authorEmail: author@example.com url: https://example.com type: nlpsandbox:date-annotator - apiVersion: 1.1.1 + apiVersion: 1.1.2 properties: name: description: The tool name @@ -478,7 +478,7 @@ components: authorEmail: author@example.com 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 @@ -488,7 +488,7 @@ components: authorEmail: author@example.com url: https://example.com type: nlpsandbox:date-annotator - apiVersion: 1.1.1 + apiVersion: 1.1.2 properties: tools: description: A list of tools