-
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.
Merge pull request #62 from Clochette-AbsINThe/dev
Test of the new CI/CD and integration of patch
- Loading branch information
Showing
26 changed files
with
690 additions
and
196 deletions.
There are no files selected for viewing
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,38 @@ | ||
name: deploy | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
release-on-push: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- id: release | ||
uses: rymndhng/release-on-push-action@master | ||
with: | ||
bump_version_scheme: patch | ||
tag_prefix: v | ||
release_name: <RELEASE_TAG> | ||
max_commits: 50 | ||
- name: Check Output Parameters | ||
run: | | ||
echo "Got tag name ${{ steps.release.outputs.tag_name }}" | ||
echo "Got release version ${{ steps.release.outputs.version }}" | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: release-on-push | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Deploy | ||
uses: appleboy/ssh-action@dce9d565de8d876c11d93fa4fe677c0285a66d78 | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
script: | | ||
cd clochette | ||
./DeployDocker.sh |
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,41 @@ | ||
name: frontend-checks | ||
|
||
on: | ||
push: | ||
branches: [dev] | ||
|
||
defaults: | ||
run: | ||
working-directory: frontend | ||
|
||
jobs: | ||
frontend-checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
cache-dependency-path: frontend/package.json | ||
cache: "npm" | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Verify lint | ||
run: npm run lint | ||
|
||
- name: Verify format | ||
run: npm run format -- -c | ||
|
||
- name: Test frontend and get coverage | ||
run: npm run coverage | ||
|
||
- name: Upload coverage reports to Codecov with GitHub Action | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: ./coverage/coverage-final.json | ||
fail_ci_if_error: true | ||
working-directory: frontend |
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
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
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,9 +1,91 @@ | ||
from collections.abc import Callable | ||
from devtools import pprint | ||
from traceback import format_exception | ||
|
||
from app.core.config import settings | ||
|
||
|
||
def alert_backend() -> Callable[[Exception, dict], None]: | ||
if settings.ALERT_BACKEND == "terminal": | ||
return alert_to_terminal | ||
elif settings.ALERT_BACKEND == "github": | ||
return alert_to_github_issues | ||
else: | ||
print("Invalid alert backend: {backend}".format( | ||
backend=settings.ALERT_BACKEND | ||
)) | ||
print("Falling back to terminal alert") | ||
return alert_to_terminal | ||
|
||
|
||
def alert_to_terminal(exception: Exception, **request: dict) -> None: | ||
print("### An exception has been raised! ###") | ||
print("############## Request ##############") | ||
pprint(request) | ||
print("############# Exception #############") | ||
pprint(exception) | ||
#format_exception(type(exception), exception, exception.__traceback__) | ||
pprint(exception) | ||
|
||
|
||
def alert_to_github_issues(exception: Exception, **request: dict) -> None: | ||
# Format the exception and request to markdown | ||
body = "# {type}: {msg}\n\n".format( | ||
type=exception.__class__.__name__, | ||
msg=str(exception) | ||
) | ||
body += "{method} {url}\n\n".format( | ||
method=request["method"], | ||
url=request["url"] | ||
) | ||
body += "## Request headers\n" | ||
body += "\n".join( | ||
"- **{key}**: {value}".format( | ||
key=key, | ||
value=value | ||
) | ||
for key, value in request["headers"].items() | ||
) | ||
body += "\n\n" | ||
body += "## Request body\n" | ||
body += "```\n" | ||
body += request["body"].decode() | ||
body += "\n```\n\n" | ||
body += "## Exception traceback\n" | ||
body += "```\n" | ||
body += "".join(format_exception(type(exception), exception, exception.__traceback__)) | ||
body += "\n```\n\n" | ||
|
||
# Create the issue on github | ||
import requests | ||
import json | ||
|
||
url = "https://api.github.com/repos/{owner}/{repo}/issues".format( | ||
owner=settings.REPOSITORY_OWNER, | ||
repo=settings.REPOSITORY_NAME | ||
) | ||
|
||
session = requests.Session() | ||
session.auth = (settings.GITHUB_USER, settings.GITHUB_TOKEN) | ||
|
||
payload = { | ||
"title": "[bug] [production] {type}: {msg}".format( | ||
type=exception.__class__.__name__, | ||
msg=str(exception) | ||
), | ||
"body": body, | ||
"labels": [label for label in settings.ISSUE_LABELS.split(",") if label], | ||
} | ||
|
||
response = session.post(url, data=json.dumps(payload)) | ||
|
||
if response.status_code != 201: | ||
print("Failed to create issue on github: {status_code}".format( | ||
status_code=response.status_code | ||
)) | ||
print(response.content) | ||
print("Falling back to terminal alert") | ||
alert_to_terminal(exception, **request) | ||
else: | ||
print("Issue created on github: {url}".format( | ||
url=response.json()["html_url"] | ||
)) |
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
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
Oops, something went wrong.