Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
Update enershare tsg client from develop

See merge request cpes/european-projects/enershare/tsg-client!85
  • Loading branch information
itsjrsa committed Jul 4, 2024
1 parent d1f5c2a commit af14f71
Show file tree
Hide file tree
Showing 7 changed files with 403 additions and 36 deletions.
67 changes: 38 additions & 29 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,61 @@
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/pipeline/#customization
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- lint
- test
- deploy

- lint
- test
- deploy
ruff:
image:
name: python:3.9-slim-bookworm
entrypoint: [ "/usr/bin/env" ]
entrypoint:
- "/usr/bin/env"
stage: lint
before_script:
- pip install poetry
- poetry install
- source "$(poetry env info --path)/bin/activate" || exit 1
script:
- ruff check .

- ruff check .
unit_tests:
image:
name: python:3.9-slim-bookworm
entrypoint: [ "/usr/bin/env" ]
entrypoint:
- "/usr/bin/env"
stage: test
before_script:
- pip install poetry
- poetry install
- pip install poetry
- poetry install
script:
- poetry run pytest unittests/

- poetry run pytest unittests/
mirror_to_github:
stage: deploy
image: docker
variables:
GIT_STRATEGY: clone
only:
- main
- main
script:
- apk add --no-cache git
- cd $CI_PROJECT_DIR # Navigate to the project directory
- git checkout main
- LAST_COMMIT_MSG=$(git log --format=%B -n 1)
- LAST_COMMIT_NAME=$(git log -1 --pretty=format:'%an')
- LAST_COMMIT_EMAIL=$(git log -1 --pretty=format:'%ae')

- git clone https://oauth2:${GITHUB_TOKEN}@github.com/CPES-Power-and-Energy-Systems/tsg-client.git github
- rm -rf .git
- mv github/.git .git
- rm -rf github
- git add -A
- git config user.email "$LAST_COMMIT_EMAIL"
- git config user.name "$LAST_COMMIT_NAME"
- git commit -m "$LAST_COMMIT_MSG"
- git push
- apk add --no-cache git
- cd $CI_PROJECT_DIR
- git checkout main
- LAST_COMMIT_MSG=$(git log --format=%B -n 1)
- LAST_COMMIT_NAME=$(git log -1 --pretty=format:'%an')
- LAST_COMMIT_EMAIL=$(git log -1 --pretty=format:'%ae')
- git clone https://oauth2:${GITHUB_TOKEN}@github.com/CPES-Power-and-Energy-Systems/tsg-client.git
github
- rm -rf .git
- mv github/.git .git
- rm -rf github
- git add -A
- git config user.email "$LAST_COMMIT_EMAIL"
- git config user.name "$LAST_COMMIT_NAME"
- git commit -m "$LAST_COMMIT_MSG"
- git push
include:
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
1 change: 1 addition & 0 deletions docs/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ print(self_description)
result = conn.query_metadata_broker()
print(result)
```
Note: `api_key` must be a key with `ROLE_ADMIN` role. This role can be added through the UI or in the file `values.yaml`.

### Set up environment variables

Expand Down
31 changes: 31 additions & 0 deletions examples/generate_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Example - Generate a contract that can be used to post artifacts
Last update: 2024-05-25
The following operations are demonstrated:
1. Generate the contract
Ensure that the required parameters are specified before executing the request:
- id: The id of the user (username).
- new_password: The new secret and secure password.
- new_roles: The new list of roles this user should have. (optional)
"""


if __name__ == "__main__":
import uuid
from tsg_client.utils.contracts import update_and_save_contract

contract_id = str(uuid.uuid4())
contract_start = "2024-01-01T00:00:00.000+00:00"
contract_end = "2024-12-31T00:00:00.000+00:00"

update_and_save_contract(
contract_id,
contract_start,
contract_end
)
Loading

0 comments on commit af14f71

Please sign in to comment.