Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinGroscheTT committed Nov 27, 2023
0 parents commit 8754803
Show file tree
Hide file tree
Showing 63 changed files with 5,016 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2022-2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

.github
.reuse
config
LICENSES
LICENSE
.gitignore
default.pylintrc
example_TestSuite.py
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/1-feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

name: '💡 Feature Request'
description: 'Feature request template for TEST-GUIDE Json Generator development'
labels: ['feature']

body:
- type: textarea
id: description
attributes:
label: Describe the feature request
description: Describe the main value of the feature request.
validations:
required: true
- type: textarea
id: upstream
attributes:
label: Upstream changes
description: Add upstream changes as checkboxes (if needed).
placeholder: Type "no changes" if no changes are needed.
validations:
required: true
- type: textarea
id: criteria
attributes:
label: Acceptance criteria
description: Add the expected results after task completion as checkboxes.
validations:
required: true
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/2-bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

name: '🐛 Bug Report'
description: 'Create a report to help us improve'
labels: ['bug']

body:
- type: textarea
id: description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is about.
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Steps for reproduction
description: List of steps to reproduce the behavior.
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: versions
attributes:
label: Versions
description: Which software versions are affected by the bug?
validations:
required: true
- type: textarea
id: context
attributes:
label: Additional context
description: Add any other context about the problem here.
validations:
required: false
- type: markdown
attributes:
value: |
**Never report security issues on GitHub or other public channels (Gitter/Twitter/etc.).**
Instead, use our [TraceTronic Support Center](https://support.tracetronic.com). For reporting issues
containing NDA relevant information please also use our [TraceTronic Support Center](https://support.tracetronic.com).
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

blank_issues_enabled: false
contact_links:
- name: TraceTronic Support Center
url: https://support.tracetronic.com
about: Please report security vulnerabilities and non-public issues (i.e. NDA relevant information) here.
81 changes: 81 additions & 0 deletions .github/automation_scripts/scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright (c) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

import argparse
import toml
import requests
import json

REPO_USER = "tracetronic"
REPO_NAME = "testguide_report-generator"


def _bump_up_version():
try:
with open("pyproject.toml", "r") as file:
toml_obj = toml.load(file)

current_version = toml_obj.get("tool").get("poetry").get("version")
versions = current_version.split(".")

next_version = versions[0] + "." + str(int(versions[1]) + 1) + "-beta"
print(next_version) # echo

toml_obj["tool"]["poetry"]["version"] = next_version
with open("pyproject.toml", "w") as file:
toml.dump(toml_obj, file)

return 0

except OSError:
print("Something went wrong during .toml processing. Aborting...")
return 1


def _publish_latest_release_draft(token):
if token is None:
raise TypeError("Argument 'token' must not be None! Aborting...")

headers = {"Accept": "application/vnd.github+json", "Authorization": f"Bearer {token}",
"X-GitHub-Api-Version": "2022-11-28"}

# first, get the latest Release (which should be set to "draft" - otherwise, something is wrong)
url = f"https://api.github.com/repos/{REPO_USER}/{REPO_NAME}/releases"

response = requests.get(url + "?per_page=1", allow_redirects=True, headers=headers).json()

release_id = response[0].get("id")
is_draft = response[0].get("draft")

if not is_draft:
raise ValueError("Release is not a draft. Cannot publish. Aborting...")

########################################

# set this Release not to be a draft
data_dict = {"draft": "false", "prerelease": "false"}

response = requests.patch(url=url + f"/{release_id}", headers=headers, data=json.dumps(data_dict),
allow_redirects=True)

return 0 if response.status_code == 200 else 1


if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog='Automation Scripts for GitHub repositories',
description='Helps doing some GitHub workflows automatically.'
)
parser.add_argument('-n', '--name', required=True)
parser.add_argument('-t', '--token', required=False)
args = parser.parse_args()

if args.name == "bump_up_version":
_bump_up_version()

elif args.name == "publish_latest_release_draft":
_publish_latest_release_draft(args.token)

else:
raise ValueError("Unknown script name. Aborting...")
43 changes: 43 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

- name: bug
description: Something isn't working
color: b60205
- name: chore
color: f2cb4b
description: Maintenance changes and refactoring
- name: dependencies
description: Dependabot
color: 5b8eff
- name: deprecated
description: Deprecated code
color: cfd3d7
- name: documentation
description: Improvements or additions to documentation
color: 0075ca
- name: duplicate
description: This issue or pull request already exists
color: cfd3d7
- name: feature
description: New feature request
color: 92d050
- name: removed
description: Remove code
color: aa0f1c
- name: security
description: Security related issue
color: 7f0e6f
- name: test-guide
description: TEST-GUIDE related issue
color: 208ca3
- name: test
description: Testing
color: 63666a
- name: wontfix
description: No further work
color: 0b3972
- name: major
description: Major version update
color: 000000
41 changes: 41 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: $NEXT_MINOR_VERSION
tag-template: $NEXT_MINOR_VERSION

version-template: $MAJOR.$MINOR

# Emoji reference: https://gitmoji.carloscuesta.me/
categories:
- title: 💡 New features and improvements
labels:
- feature
- title: 🐛 Bug fixes
labels:
- bug
- title: 🏠 Maintenance
labels:
- chore
- title: ✍ Other changes
# Default label used by Dependabot
- title: 📦 Dependency updates
labels:
- dependencies
collapse-after: 15

template: |
<!-- Optional: add a release summary here -->
$CHANGES
replacers:
- search: '@dependabot-preview'
replace: '@dependabot'

version-resolver:
major:
labels:
- 'major'
default: minor
21 changes: 21 additions & 0 deletions .github/workflows/auto-merge-actions-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

name: Auto merge for GH Action Updates
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' && contains( github.event.pull_request.labels.*.name, 'github_actions') }}
steps:
- name: Enable auto-merge for Dependabot GitHub Actions PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
22 changes: 22 additions & 0 deletions .github/workflows/close-fork-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

name: Auto-close Pull Requests from Forks

on:
pull_request:
types: [opened, reopened]
schedule:
- cron: '0 0 * * *'

jobs:
close-prs:
runs-on: ubuntu-latest
steps:
- name: Close Pull Requests
uses: peter-evans/close-fork-pulls@v2
with:
comment: |
We do not accept any external pull requests. Auto-closing this pull request.
If you have any questions, please contact us at [[email protected]](mailto:[email protected]).
43 changes: 43 additions & 0 deletions .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

name: Ensure 3rd Party License Compliance

on:
push:
branches:
- main
pull_request:

jobs:

validate-sbom:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7.9' # latest binary release of v3.7
- name: Install poetry
run: pip3 install poetry
- name: Active Python version
run: |
echo "Active Python version is..."
python --version
- name: Export dependencies to requirements file
run: poetry export --only main -f requirements.txt -o requirements.txt --without-hashes --without-urls
- name: Install pipenv environment
run: pip3 install pipenv
- name: Create Pipfile.lock
run: pipenv install -r requirements.txt
- name: Install dev dependencies
run: poetry install --only dev --no-root
- name: check license compliance against allowlist
run: |
poetry run python config/license/check_dependencies.py `
--allowlist="config/license/allowlist.json" `
--sbom="cyclonedx.json" `
--schema="config/license/allowlist_schema.json"
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) 2023 TraceTronic GmbH
#
# SPDX-License-Identifier: MIT

name: Lint
run-name: Linting code

on:
push:
branches:
- main
pull_request:

jobs:
lint:
runs-on: ubuntu-22.04
env:
PY_VERSION: '3.9'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PY_VERSION }}
- name: Install virtual environment
run: pip3 install poetry
- name: Ensure Python version
run: poetry env use ${{ env.PY_VERSION }}
- name: Install dependencies
run: poetry install --without workflow --no-root
- name: Execute Linting
run: poetry run pylint --rcfile default.pylintrc testguide_report_generator
Loading

0 comments on commit 8754803

Please sign in to comment.