Skip to content

Commit

Permalink
Merge pull request #419 from NASA-PDS/i415
Browse files Browse the repository at this point in the history
Reorganizes Jenkins- and Docker-specific assets into subdirectories `jenkins` and `docker`, respectively
  • Loading branch information
nutjob4life authored Oct 25, 2023
2 parents dd2d73b + a77a52c commit 20f5f7c
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 54 deletions.
9 changes: 5 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
-
package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
5 changes: 5 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ To run the server on a Docker container, please execute the following from the p

```console
$ # building the image
$ docker image build --tag pds-doi-service .
$ docker image build --tag pds-doi-service --file docker/Dockerfile .
$ # starting up a container
$ docker container run --publish 8080:8080 pds-doi-service
```

However, note that when launching the container via `docker container run`, all configuration values are derived from the default INI file bundled with the repository. To override the configuration, it is recommended to launch the service via a Docker Composition:

```console
$ cd docker
$ # Make a copy of the docker composition environment template:
$ cp doi_service.env.in doi_service.env
$ # Edit the environment file, setting the credentials within:
Expand All @@ -131,7 +132,7 @@ $ # Start the composition; on some systems, `docker compose` is `docker-compose`
$ docker compose up
```

This will launch the DOI Service container using the top-level `docker-compose.yml` file, which specifies that environment variables be imported from `doi_service.env`. Modify `doi_service.env` (after copying it from `doi_service.env.in`) to define any configuration values to override when the service is launched.
This will launch the DOI Service container using the `docker-compose.yaml` file in the `docker` subdirectory, which specifies that environment variables be imported from `doi_service.env`. Modify `doi_service.env` (after copying it from `doi_service.env.in`) to define any configuration values to override when the service is launched.

## Test

Expand All @@ -147,7 +148,13 @@ Testing details are detailed in this section.
- linting
- building the rich documentation.

To launch the full set of tests, simply run:
To launch the full set of tests, simply set the following environment variables:

- `CI` should be set to `true`
- `DATACITE_USER` should be set to the PDS username of the testing Datacite instance
- `DATACITE_PASSWORD` should be set to that username's password

Then run:

tox

Expand Down
File renamed without changes.
File renamed without changes.
69 changes: 69 additions & 0 deletions docker/doi_service.env.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright © 2021–2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# • Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# • Redistributions must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
# • Neither the name of Caltech nor its operating division, the Jet Propulsion
# Laboratory, nor the names of its contributors may be used to endorse or
# promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

# This file is used with docker-compose.yaml to specify a number of environment
# variable key/value pairs to add to the DOI Service's environment when
# launching the container via docker compose up.

# The DOI Service prioritizes environment variables over the included INI,
# so this file may be used to inject credentials or any other supported
# options into the DOI Service when in a containerized context.

# The naming convention for expected environment variables follows from the
# format of the INI, where the section name and option name are concatenated
# with an underscore and converted to uppercase, for example:

# OSTI_USER=username -> overrides the "user" option of the [OSTI] INI section.

# If the default values from the bundled INI are desired, do not specify
# environment variables for them here or they will be overridden.

# Also note that Docker performs "no special handling of quotation marks" for
# values. This means that they become part of the value provided to the DOI Service.

# [PDS4_DICTIONARY]
PDS4_DICTIONARY_URL=https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_JSON_1D00.JSON

# [LANDING_PAGES]
LANDING_PAGES_URL=https://pds.nasa.gov/ds-view/pds/view{}.jsp?identifier={}&version={}

# [OTHER]
[email protected]
OTHER_PDS_REGISTRATION_DOI_TOKEN=10.17189
OTHER_LOGGING_LEVEL=DEBUG

# [OSTI]
#
# This last 2 lines of this file *must* be OSTI_USER and OSTI_PASSWORD for
# Jenkins to work!

OSTI_URL=https://www.osti.gov/iad2test/api/records
OSTI_USER=username
OSTI_PASSWORD=secret
39 changes: 0 additions & 39 deletions doi_service.env.in

This file was deleted.

12 changes: 6 additions & 6 deletions Jenkinsfile → jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2022, California Institute of Technology ("Caltech").
* Copyright © 2022–2023, California Institute of Technology ("Caltech").
* U.S. Government sponsorship acknowledged.
*
* All rights reserved.
Expand Down Expand Up @@ -49,7 +49,7 @@ pipeline {
shutdown_timeout = "30"

// Basic composition command:
compose = "docker-compose --file ${env.WORKSPACE}/jenkins-compose.yaml"
compose = "docker-compose --file ${env.WORKSPACE}/jenkins/jenkins-compose.yaml --project-directory ${env.WORKSPACE}/jenkins"

// Network morphology
PDS_DOI_PUBLISHED_PORT = "3176"
Expand All @@ -70,10 +70,10 @@ pipeline {
withCredentials([
usernamePassword(credentialsId: 'datacite-dev', passwordVariable: 'p', usernameVariable: 'u')
]) {
sh "rm --force doi_service.env"
sh "head --lines=-2 doi_service.env.in > doi_service.env"
sh 'echo "OSTI_USER=$u" >> doi_service.env'
sh 'echo "OSTI_PASSWORD=$p" >> doi_service.env'
sh "rm --force jenkins/doi_service.env"
sh "head --lines=-2 docker/doi_service.env.in > jenkins/doi_service.env"
sh 'echo "OSTI_USER=$u" >> jenkins/doi_service.env'
sh 'echo "OSTI_PASSWORD=$p" >> jenkins/doi_service.env'
}
sh "$compose pull --quiet"
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pds_doi_service/api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _deserialize(data, klass):
return deserialize_date(data)
elif klass == datetime.datetime:
return deserialize_datetime(data)
elif type(klass) == typing.GenericMeta:
elif type(klass) is typing.GenericMeta:
if klass.__extra__ == list:
return _deserialize_list(data, klass.__args__[0])
if klass.__extra__ == dict:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ passenv = CI DATACITE_USER DATACITE_PASSWORD
[testenv:docs]
deps = .[dev]
whitelist_externals = python
commands = python setup.py build_sphinx
commands = sphinx-build docs/source docs/build

[testenv:lint]
deps = pre-commit
Expand Down

0 comments on commit 20f5f7c

Please sign in to comment.