-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e06e15b
commit 694d2ea
Showing
17 changed files
with
565 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Integration Test | ||
on: [push] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Version and Update Item | ||
id: version-update-item | ||
uses: provena/version-update-item-action@main | ||
with: | ||
offline_token: ${{ secrets.PROVENA_OFFLINE_TOKEN }} | ||
domain: "dev.rrap-is.com" | ||
realm_name: "rrap" | ||
item_id: "10378.1/1925572" | ||
version_reason: "Testing GitHub Action which can version and update items" | ||
update_reason: "Updating git custom attributes, as well as source URL." | ||
attribute_updates: | | ||
{ | ||
"user_metadata": { | ||
"git_hash": "${{ github.sha }}", | ||
"git_branch": "${{ github.ref_name }}", | ||
"git_release": "${{ github.ref_type == 'tag' && github.ref_name || '' }}" | ||
}, | ||
"source_url": "https://github.com/${{ github.repository }}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Lint | ||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: "3.7" | ||
|
||
- uses: actions/checkout@v1 | ||
|
||
- name: Lint | ||
run: | | ||
pip install flake8 | ||
flake8 main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"." | ||
], | ||
"python.analysis.diagnosticMode": "workspace", | ||
"mypy.runUsingActiveInterpreter": true, | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3-slim AS builder | ||
|
||
# Just dependencies to minimise rebuilds | ||
COPY requirements.txt /app | ||
|
||
# We are installing a dependency here directly into our app source dir | ||
RUN pip install --target=/app -r requirements.txt | ||
|
||
ADD . /app | ||
WORKDIR /app | ||
|
||
# A distroless container image with Python and some basics like SSL certificates | ||
# https://github.com/GoogleContainerTools/distroless | ||
FROM gcr.io/distroless/python3-debian10 | ||
COPY --from=builder /app /app | ||
WORKDIR /app | ||
ENV PYTHONPATH /app | ||
CMD ["/app/main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 GitHub, Inc. and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# version-update-item-action | ||
|
||
Docker GitHub action which produces a new version of an existing registry item, and updates metadata attributes if supplied. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: "Update Provena registry item" | ||
description: "Creates a new version of an existing item in a Provena deployment, providing a reason and an optional set of attribute updates." | ||
author: "Peter Baker" | ||
inputs: | ||
offline_token: | ||
description: "Offline token which is suitable for the specified provena domain, realm and client." | ||
required: true | ||
secret: true | ||
domain: | ||
description: "The base domain for the provena deployment" | ||
required: true | ||
realm_name: | ||
description: "The realm name for the keycloak instance for this deployment - contact administrator if unsure." | ||
required: true | ||
item_id: | ||
description: "The id of the item to create a new version for." | ||
required: true | ||
version_reason: | ||
description: "What reason should be provided for the creation of the new version?" | ||
required: true | ||
update_reason: | ||
description: "What reason should be provided for the update of metadata attributes?" | ||
required: false | ||
attribute_updates: | ||
description: "Would you like to apply a set of updates after versioning? If so this JSON will be merged with the updated item domain info and an update applied. Please ensure this is a valid serialised JSON string." | ||
required: false | ||
outputs: | ||
new_id: | ||
description: "The ID of the new version of the item" | ||
runs: | ||
using: "docker" | ||
image: "Dockerfile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pydantic import BaseSettings | ||
from logging import WARNING | ||
|
||
|
||
class GithubInputs(BaseSettings): | ||
# The offline token to use for the client auth | ||
input_offline_token: str | ||
# The domain for the provena deployment | ||
input_domain: str | ||
# The auth realm name | ||
input_realm_name: str | ||
# The item id to create new version for | ||
input_item_id: str | ||
# The reason to provide | ||
input_version_reason: str | ||
# The reason to provide | ||
input_update_reason: str | None | ||
# The set of attribute updates to apply after versioning, if any | ||
input_attribute_updates: str | None | ||
# The log level to display - defaults to WARNING - see https://docs.python.org/3/library/logging.html#levels | ||
input_log_level: int = WARNING | ||
|
||
# use .env file optionally for local testing | ||
class Config: | ||
env_file = ".env" | ||
env_file_encoding = "utf-8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mypy | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import logging | ||
import sys | ||
|
||
def setup_logger(name : str, level: int = logging.INFO) -> logging.Logger: | ||
"""Function to setup as many loggers as you want""" | ||
|
||
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') | ||
|
||
# Console handler | ||
console_handler = logging.StreamHandler(sys.stdout) | ||
console_handler.setFormatter(formatter) | ||
|
||
# Create logger and set level | ||
logger = logging.getLogger(name) | ||
logger.setLevel(level) | ||
|
||
# Add handlers to logger | ||
logger.addHandler(console_handler) | ||
|
||
return logger |
Oops, something went wrong.