Skip to content

Commit

Permalink
Merge pull request #129 from Zerohertz/chore-v0.5.0
Browse files Browse the repository at this point in the history
[v0.5.0] Chore Update
  • Loading branch information
Zerohertz authored Nov 29, 2023
2 parents a6c6aa2 + 7493b3b commit ee06a10
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 25 deletions.
34 changes: 20 additions & 14 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,26 @@ spec:
}
}
steps {
script {
try {
def startTime = System.currentTimeMillis()
setBuildStatus("Test...", "PENDING", "$STAGE_NAME")
container("python") {
sh "pip install pytest"
sh "pytest"
withCredentials([string(credentialsId: "OpenAI_Token", variable: "OPENAI_TOKEN"),
string(credentialsId: "Discord_Webhook_URL", variable: "DISCORD_WEBHOOK_URL"),
string(credentialsId: "Slack_Webhook_URL", variable: "SLACK_WEBHOOK_URL"),
string(credentialsId: "Slack_Bot_Token", variable: "SLACK_BOT_TOKEN")]) {
script {
try {
def startTime = System.currentTimeMillis()
setBuildStatus("Test...", "PENDING", "$STAGE_NAME")
container("python") {
sh "pip install pytest"
sh "pytest"
}
def endTime = System.currentTimeMillis()
def DURATION = (endTime - startTime) / 1000
setBuildStatus("Successful in ${DURATION}s", "SUCCESS", "$STAGE_NAME")
} catch (Exception e) {
def STAGE_ERROR_MESSAGE = e.getMessage().split("\n")[0]
setBuildStatus(STAGE_ERROR_MESSAGE, "FAILURE", "$STAGE_NAME")
throw e
}
def endTime = System.currentTimeMillis()
def DURATION = (endTime - startTime) / 1000
setBuildStatus("Successful in ${DURATION}s", "SUCCESS", "$STAGE_NAME")
} catch (Exception e) {
def STAGE_ERROR_MESSAGE = e.getMessage().split("\n")[0]
setBuildStatus(STAGE_ERROR_MESSAGE, "FAILURE", "$STAGE_NAME")
throw e
}
}
}
Expand Down Expand Up @@ -316,6 +321,7 @@ spec:
setBuildStatus("Deploy...", "PENDING", "$STAGE_NAME")
def PACKAGE_VERSION = ""
container("python") {
sh "pip install .'[all]'"
PACKAGE_VERSION = sh(
script: 'python -c "import zerohertzLib; print(zerohertzLib.__version__)"',
returnStdout: true
Expand Down
19 changes: 19 additions & 0 deletions docs/_sources/release/v0.5.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

## v0.5.0

<h3>[v0.5.0] Chore Update (<a href=https://github.com/Zerohertz/zerohertzLib/pull/129>#129</a>)</h3>

```{admonition} Release Date
:class: tip

2023/11/29
```

<p align="center">
<a href="https://github.com/Zerohertz/zerohertzLib/pulls?q=is:pr label:chore"><img src="https://img.shields.io/badge/chore-fef2c0?style=flat-square&logo=github" alt="chore"/></a>
<a href="https://github.com/Zerohertz/zerohertzLib/pulls?q=is:pr label:release/chore"><img src="https://img.shields.io/badge/release/chore-22FD7F?style=flat-square&logo=github" alt="release/chore"/></a>
</p>


<h4>Chore</h4>

+ `api` submodule의 PyTest를 위한 Jenkins의 credentials 추가
+ `GitHub` stage의 package 전체 설치 code 추가

<h3>[v0.5.0] Release (<a href=https://github.com/Zerohertz/zerohertzLib/pull/127>#127</a>)</h3>

```{admonition} Release Date
Expand Down
18 changes: 16 additions & 2 deletions docs/release/v0.5.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<meta property="og:type" content="website" />
<meta property="og:url" content="https://zerohertz.github.io/zerohertzLib/release/v0.5.html" />
<meta property="og:site_name" content="Zerohertz's Library v0.5.0 Documents" />
<meta property="og:description" content="v0.5.0: Dependency가 큰 submodule을 선별적 설치를 할 수 있도록 변경." />
<meta property="og:description" content="v0.5.0: api submodule의 PyTest를 위한 Jenkins의 credentials 추가, GitHub stage의 package 전체 설치 code 추가. Dependency가 큰 submodule을 선별적 설치를 할 수 있도록 변경." />
<meta property="og:image" content="https://zerohertz.github.io/zerohertzLib/_static/og.png" />
<meta property="og:image:alt" content="Zerohertz's Library v0.5.0 Documents" />
<meta name="description" content="v0.5.0: Dependency가 큰 submodule을 선별적 설치를 할 수 있도록 변경." />
<meta name="description" content="v0.5.0: api submodule의 PyTest를 위한 Jenkins의 credentials 추가, GitHub stage의 package 전체 설치 code 추가. Dependency가 큰 submodule을 선별적 설치를 할 수 있도록 변경." />
<link href="../_static/favicon.png" sizes="802x802" rel="icon" type="image/png">
<link href="../_static/favicon-16x16.png" sizes="16x16" rel="icon" type="image/png">
<link href="../_static/favicon-32x32.png" sizes="32x32" rel="icon" type="image/png">
Expand Down Expand Up @@ -257,6 +257,20 @@
<h1>v0.5<a class="headerlink" href="#v0-5" title="Permalink to this heading">#</a></h1>
<section id="v0-5-0">
<h2>v0.5.0<a class="headerlink" href="#v0-5-0" title="Permalink to this heading">#</a></h2>
<h3>[v0.5.0] Chore Update (<a href=https://github.com/Zerohertz/zerohertzLib/pull/129>#129</a>)</h3>
<div class="tip admonition">
<p class="admonition-title">Release Date</p>
<p>2023/11/29</p>
</div>
<p align="center">
<a href="https://github.com/Zerohertz/zerohertzLib/pulls?q=is:pr label:chore"><img src="https://img.shields.io/badge/chore-fef2c0?style=flat-square&logo=github" alt="chore"/></a>
<a href="https://github.com/Zerohertz/zerohertzLib/pulls?q=is:pr label:release/chore"><img src="https://img.shields.io/badge/release/chore-22FD7F?style=flat-square&logo=github" alt="release/chore"/></a>
</p>
<h4>Chore</h4>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">api</span></code> submodule의 PyTest를 위한 Jenkins의 credentials 추가</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">GitHub</span></code> stage의 package 전체 설치 code 추가</p></li>
</ul>
<h3>[v0.5.0] Release (<a href=https://github.com/Zerohertz/zerohertzLib/pull/127>#127</a>)</h3>
<div class="tip admonition">
<p class="admonition-title">Release Date</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions sphinx/source/release/v0.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

## v0.5.0

<h3>[v0.5.0] Chore Update (<a href=https://github.com/Zerohertz/zerohertzLib/pull/129>#129</a>)</h3>

```{admonition} Release Date
:class: tip
2023/11/29
```

<p align="center">
<a href="https://github.com/Zerohertz/zerohertzLib/pulls?q=is:pr label:chore"><img src="https://img.shields.io/badge/chore-fef2c0?style=flat-square&logo=github" alt="chore"/></a>
<a href="https://github.com/Zerohertz/zerohertzLib/pulls?q=is:pr label:release/chore"><img src="https://img.shields.io/badge/release/chore-22FD7F?style=flat-square&logo=github" alt="release/chore"/></a>
</p>


<h4>Chore</h4>

+ `api` submodule의 PyTest를 위한 Jenkins의 credentials 추가
+ `GitHub` stage의 package 전체 설치 code 추가

<h3>[v0.5.0] Release (<a href=https://github.com/Zerohertz/zerohertzLib/pull/127>#127</a>)</h3>

```{admonition} Release Date
Expand Down
46 changes: 42 additions & 4 deletions test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,62 @@

import zerohertzLib as zz

WEBHOOK = "https://discord.com/api/webhooks/1174193014923591791/vBPMpb0otKQH0lflp169u0a-8gJPZyDg17SPEsxKDDlmv3PMFl4eNrt3KWQgUmnWpYJ9"
OPENAI_TOKEN = os.environ.get("OPENAI_TOKEN")
DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL")
SLACK_WEBHOOK_URL = os.environ.get("SLACK_WEBHOOK_URL")
SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN")

tmp = os.path.dirname(__file__)
data = os.path.join(tmp, "data")


def test_discord_message():
discord = zz.api.Discord(WEBHOOK)
discord = zz.api.Discord(DISCORD_WEBHOOK_URL)
for response in discord.message("Testing..."):
assert response.status_code == 204


def test_discord_messages():
discord = zz.api.Discord(WEBHOOK)
discord = zz.api.Discord(DISCORD_WEBHOOK_URL)
for response in discord.message("Testing..." * 200):
assert response.status_code == 204


def test_discord_image():
discord = zz.api.Discord(WEBHOOK)
discord = zz.api.Discord(DISCORD_WEBHOOK_URL)
response = discord.image(f"{data}/test.jpg")
assert response.status_code == 200


def test_slack_webhook():
slack = zz.api.SlackWebhook(
SLACK_WEBHOOK_URL, "test", name="Test Webhook", icon_emoji="wrench"
)
response = slack.message("Testing...")
assert response.status_code == 200


def test_slack_bot_message():
slack = zz.api.SlackBot(
SLACK_BOT_TOKEN, "test", name="Test Bot", icon_emoji="hammer"
)
response = slack.message("Testing...")
assert response.status_code == 200


def test_slack_bot_file():
slack = zz.api.SlackBot(
SLACK_BOT_TOKEN, "test", name="Test Bot", icon_emoji="hammer"
)
response = slack.file(f"{data}/test.jpg")
assert response.status_code == 200


def test_openai():
client = zz.api.OpenAI(OPENAI_TOKEN)
response = client("오늘 기분이 어때? 1줄로 대답해줘.", model="gpt3")
assert isinstance(response, str)
slack = zz.api.SlackBot(
SLACK_BOT_TOKEN, "test", name="Test Bot", icon_emoji="hammer"
)
slack.message(response)
30 changes: 26 additions & 4 deletions test/test_logging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os

import zerohertzLib as zz

WEBHOOK = "https://discord.com/api/webhooks/1174193014923591791/vBPMpb0otKQH0lflp169u0a-8gJPZyDg17SPEsxKDDlmv3PMFl4eNrt3KWQgUmnWpYJ9"
DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL")
SLACK_WEBHOOK_URL = os.environ.get("SLACK_WEBHOOK_URL")
SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN")


def test_logging():
Expand All @@ -13,10 +17,28 @@ def test_logging():


def test_logging_discord():
log = zz.logging.Logger("TEST_2", logger_level=20, discord=DISCORD_WEBHOOK_URL)
log.debug("debug")
log.info("info")
log.warning("warning")
log.error("error")
log.critical("critical")


def test_logging_slack_webhook():
log = zz.logging.Logger(
"TEST_3", logger_level=20, slack=SLACK_WEBHOOK_URL, channel="test"
)
log.debug("debug")
log.info("info")
log.warning("warning")
log.error("error")
log.critical("critical")


def test_logging_slack_bot():
log = zz.logging.Logger(
"TEST_2",
logger_level=20,
discord=WEBHOOK,
"TEST_4", logger_level=20, slack=SLACK_BOT_TOKEN, channel="test"
)
log.debug("debug")
log.info("info")
Expand Down

0 comments on commit ee06a10

Please sign in to comment.