Skip to content

Commit

Permalink
hopefully final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Becker committed Jun 11, 2024
1 parent c953665 commit 49f0b8d
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 752 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ jobs:
TRELLO_API_KEY: ${{ secrets.TRELLO_API_KEY }}
TRELLO_API_TOKEN: ${{ secrets.TRELLO_API_TOKEN }}
needs: unittest
if: ${{ github.event_name }} == "push"
if: ${{ github.event_name }} == "push"
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,3 @@ Unit Tests sind in der Datei `src/test_main.py` definiert. Zusätzlich sind für

Für CI/CD wird hauptsächlich das Auto DevOps System von GitLab verwendet. Zusätzlich findet sich die gesamte Integration mit Trello im `pipeline/` Verzeichnis. Dazu existiert auch eine weitere [README](./pipeline/README.md).

## Prozesses

Diese finden sich im `bpmn/` Verzeichnis.
Binary file removed bpmn/UML class.png
Binary file not shown.
483 changes: 0 additions & 483 deletions bpmn/feature_branch_process.bpmn

This file was deleted.

4 changes: 0 additions & 4 deletions bpmn/feature_branch_process.svg

This file was deleted.

Binary file removed bpmn/idee_e-business.pdf
Binary file not shown.
233 changes: 0 additions & 233 deletions bpmn/main_branch_process.bpmn

This file was deleted.

4 changes: 0 additions & 4 deletions bpmn/main_branch_process.svg

This file was deleted.

21 changes: 17 additions & 4 deletions pipeline/GitCommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@

class GitCommit:
'''
Hier muss noch eine Beschreibung rein.
Diese Klasse beinhaltet die nötigen Informationen eines Git Commits,
der für Workflow-Systeme eingesetzt wird. Diese Klasse ist nicht
Quellsystem-spezifisch und wird als Elternklasse für die spezifischen
Klassen von Gitlab und Github eingesetzt.
Parameters:
branch_name (str): Name des Git Branches des Commits
commit_hash(str): Hashwert des Commits
commit_message(str): Nachricht des Commits
image_name(str): Name des Docker-Images, das aus dem Commit erzeugt wird
project_url(str): URL zu dem konkreten Projekt bei GitHub/Lab
pipeline_id(str): ID der aktuellen CI/CD Pipeline
pipeline_link_url(str): Link zur Pipeline bei GitHub/Lab
commit_link_url(str): Link zum Commit bei GitHub/Lab
test_report_link_url(str): Link zum Unittest Report bei GitHub/Lab
'''
def __init__(self, branch_name, commit_hash, commit_message,
image_name, project_url, pipeline_id, pipeline_link_url,
Expand All @@ -29,10 +43,9 @@ def check_source_system():
'''
if os.environ.get('GITHUB_ACTIONS') in ['true', True]:
return 'Github'
elif os.environ.get('GITLAB_CI') in ['true', True]:
if os.environ.get('GITLAB_CI') in ['true', True]:
return 'Gitlab'
else:
raise GitException('Source system not recognized.')
raise GitException('Source system not recognized.')

def get_branch_name(self):
'''
Expand Down
3 changes: 3 additions & 0 deletions pipeline/GitHubCommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
class GitHubCommit(GitCommit):
'''
Die Klasse beinhaltet die relevanten Informationen eines jeden Git Commits.
Der Konstruktor bezieht alle Informationen dafür spezifisch von GitHub Actions.
Diese werden aus den Umgebungsvariablen extrahiert und dem Verwender zur
Verfügung gestellt.
Die Umgebungsvariablen werden entweder von GitHub an sich gestellt oder
werden in der CI-YAML Datei definiert.
'''
def __init__(self):
github_commit_message = os.environ.get('GH_COMMIT_MESSAGE')
Expand Down
1 change: 1 addition & 0 deletions pipeline/GitLabCommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class GitLabCommit(GitCommit):
'''
Die Klasse extrahiert alle Infomationen aus GitLab und erzeugt einen GitCommit.
Der Konstruktor bezieht alle Informationen dafür spezifisch von GitLab Runnern.
Diese werden aus den Umgebungsvariablen extrahiert und dem Verwender zur
Verfügung gestellt.
'''
Expand Down
12 changes: 1 addition & 11 deletions pipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
1. Ein Trello Board muss erstellt sein. Die ID davon muss bekannt sein. Diese wird in den GitLab CI/CD Variablen eingetragen (Name: `TRELLO_BOARD_ID`).
2. Ein PowerUp muss in Trello erstellt werden und mit dem Board verbunden werden. Der angezeigt API Key wird in die CI/CD Variablen in GitLab eingetragen (Name: `TRELLO_API_KEY`).
3. Der User muss einen API Token erstellen und in die CI/CD Variablen in GitLab eintragen (Name: `TRELLO_API_TOKEN`)
4. Das Board muss mindestens die folgenden Spalten in der exakt gleichen Benamung haben: `In Development`, `In Review`, `Ready to Deploy`, `Deployed`. Es muss ein Label mit dem Namen `gitlab` existieren.
4. Das Board muss mindestens die folgenden Spalten in der exakt gleichen Benamung haben: `In Development`, `In Review`, `Ready to Deploy`, `Deployed`. Es muss ein Label mit dem Namen `git` existieren.
5. Es kann nun eine Karte erstellt werden. Der Titel muss den Namen den zukünftigen Feature Branches beinhalten. Die Karte muss mit den Label "gitlab" versehen werden. Der Name des Feature Branches darf nur einmalig in dem Board vorkommen. Bei Duplikaten bricht das Programm ab.

## Schritte innerhalb der Feature Branch Pipelines
Expand Down Expand Up @@ -74,12 +74,6 @@ Die Klasse benötigt die folgenden (Umgebungs-)Variablen zur Initialisierung:
| board_id | ID des Trello Boards | `TRELLO_BOARD_ID` |
| api_key | API Key des Trello PowerUps | `TRELLO_API_KEY` |
| api_token | API Token des Trello Nutzers | `TRELLO_API_TOKEN` |
| gitlab_branch_name | Aktueller Branch im Git Repository | `CI_COMMIT_REF_NAME` |
| gitlab_commit_hash | (langer) Commit Hash im Git Repository | `CI_COMMIT_SHA` |
| gitlab_commit_message | Nachricht innerhalb des Commits | `CI_COMMIT_MESSAGE` |
| gitlab_pipeline_id | ID der Pipeline in GitLab | `CI_PIPELINE_ID` |
| gitlab_project_url | URL zum Repository in GitLab | `CI_PROJECT_URL` |
| gitlab_image_name | Name des Docker Images in der GitLab Registry | `CI_REGISTRY_IMAGE` |

Die folgenden Befehle werden zur Ausführung verwendet:
* Vor der Feature Branch Pipeline
Expand Down Expand Up @@ -112,7 +106,3 @@ python3 pipeline.py --step post_production

Die eigentlichen Jobs in der Pipeline sind als Templates in der `trello-ci.yaml` Datei hinterlegt.

## TODOs
- Image Name implementieren
- Prod Pipeline testen
- Anhänge implementieren
28 changes: 19 additions & 9 deletions pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'''
import os
import argparse
from sys import exit
from TrelloTask import TrelloTask
from TrelloException import TrelloException
from GitCommit import GitCommit
Expand Down Expand Up @@ -31,25 +32,34 @@
git_commit = GitLabCommit() if source_system == 'Gitlab' else git_commit
trello = TrelloTask(git_commit)

# Vor der Ausführung der Production Pipeline
if args.step == allowed_step_strings[0]:
# Vor der Ausführung der Production Pipeline
trello.pre_production_pipeline()
elif args.step == allowed_step_strings[1]:
# Nach der Ausführung der Production Pipeline
exit(0)

# Nach der Ausführung der Production Pipeline
if args.step == allowed_step_strings[1]:
IS_PIPELINE_FAILED = os.environ.get('PIPELINE_FAILED') == 'true'
trello.post_production_pipeline(IS_PIPELINE_FAILED)
elif args.step == allowed_step_strings[2]:
# Vor der Ausführung der Feature Branch Pipeline
exit(0)

# Vor der Ausführung der Feature Branch Pipeline
if args.step == allowed_step_strings[2]:
trello.pre_feature_branch_pipeline()
elif args.step == allowed_step_strings[3]:
# Während der Ausführung der Feature Branch Pipeline
exit(0)

# Während der Ausführung der Feature Branch Pipeline
if args.step == allowed_step_strings[3]:
trello.intra_feature_branch_pipeline()
elif args.step == allowed_step_strings[4]:
# Nach der Ausführung der Feature Branch Pipeline
exit(0)

# Nach der Ausführung der Feature Branch Pipeline
if args.step == allowed_step_strings[4]:
IS_PIPELINE_FAILED = os.environ.get('PIPELINE_FAILED') == 'true'
if os.environ.get('REVIEW_ACCEPTED') is not None \
and os.environ.get('REVIEW_ACCEPTED').lower() in ['yes', 'true']:
IS_REVIEW_FAILED = False
else:
IS_REVIEW_FAILED = True
trello.post_feature_branch_pipeline(IS_REVIEW_FAILED, IS_PIPELINE_FAILED)
exit(0)

0 comments on commit 49f0b8d

Please sign in to comment.