Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts/run_ci.sh to cover directories in the exercises and topics dir #315

Merged
merged 8 commits into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
</b></details>

<details>
<summary>你是如何实施从某个阶段而不是从最开始构建的选项?<summary><br><b>
<summary>你是如何实施从某个阶段而不是从最开始构建的选项?</summary><br><b>
</b></details>

<details>
Expand Down Expand Up @@ -924,7 +924,7 @@ Zombie(假死态)
</b></details>

<details>
<summary>你能解释一下网络进程/连接如何建立以及如何终止?><br></b>
<summary>你能解释一下网络进程/连接如何建立以及如何终止?</summary><br></b>
</b></details>

<details>
Expand Down Expand Up @@ -1385,6 +1385,7 @@ Terraform与其他工具相比的优势:
* Provider
* Resource
* Provisioner
</summary>
</b></details>

<details>
Expand Down Expand Up @@ -1656,7 +1657,7 @@ Docker Cloud构建在Docker Hub之上,因此Docker Cloud提供了
</b></details>

<details>
<summary>解释一下递归</summary<br><b>
<summary>解释一下递归</summary><br><b>
</b></details>

<details>
Expand Down Expand Up @@ -1951,11 +1952,11 @@ with open('file.txt', 'w') as file:
</b></details>

<details>
<summay>如何用 "blue" 替换字符串 "green"?</summary><br><b>
<summary>如何用 "blue" 替换字符串 "green"?</summary><br><b>
</b></details>

<details>
<summay>如何找到一个变量中的所有IP地址? 如何在文件中找到它们?</summary><br><b>
<summary>如何找到一个变量中的所有IP地址? 如何在文件中找到它们?</summary><br><b>
</b></details>

<details>
Expand Down Expand Up @@ -2072,6 +2073,7 @@ def reverse_string(string):
* Mergesort
* Bucket Sort
* Radix Sort
</summary>
</b></details>

<a name="python-advanced"></a>
Expand Down Expand Up @@ -2110,7 +2112,7 @@ def reverse_string(string):
</b></details>

<details>
<summary>你可以在Python中实现链接链表吗?<br><b>
<summary>你可以在Python中实现链接链表吗?</summary><br><b>
</b></details>

<details>
Expand Down Expand Up @@ -2832,7 +2834,7 @@ where c.Customer_ID in (Select Customer_ID from cat_food);
</b></details>

<details>
<summmary>详细描述如何使用可以从云外部访问的IP来启动实例</summary><br><b>
<summary>详细描述如何使用可以从云外部访问的IP来启动实例</summary><br><b>
</b></details>

<details>
Expand Down
12 changes: 11 additions & 1 deletion scripts/run_ci.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/bash
# These are the same steps we are running in Travis CI

python $(dirname "$0")/../tests/syntax_lint.py

find . -name "*.md" -not -path "./tests/*" | \
xargs -I {} \
python $(dirname "$0")/../tests/syntax_lint.py {} > /dev/null
mdPassed=$?
flake8 --max-line-length=100 . && echo "PEP8 Passed"
pyPassed=$?
if [ $pyPassed -eq 0 ] && [ $mdPassed -eq 0 ];then
exit 0
else
exit 1
fi
70 changes: 40 additions & 30 deletions tests/syntax_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@

"""

import pathlib
import sys

p = pathlib.Path(__file__).parent.parent.joinpath('README.md')
p = sys.argv[1]

with open(p, 'rb') as f:
file_list = [line.rstrip() for line in f.readlines()]

errors = []

Expand All @@ -31,9 +29,9 @@ def count_details(file_list):
details_count = 0

for line_number, line in enumerate(file_list):
if b'<details>' in line:
if b"<details>" in line:
details_count += 1
if b'</details>' in line:
if b"</details>" in line:
details_final_count += 1

return details_count == details_final_count
Expand All @@ -49,9 +47,9 @@ def count_summary(file_list):
details_count = 0

for line_number, line in enumerate(file_list):
if b'<summary>' in line:
if b"<summary>" in line:
details_count += 1
if b'</summary>' in line:
if b"</summary>" in line:
details_final_count += 1

return details_count == details_final_count
Expand All @@ -70,22 +68,22 @@ def check_details_tag(file_list):

after_detail = False
error = False
err_message = ''
err_message = ""
for line_number, line in enumerate(file_list):
if b'<details>' in line and b'</details>' in line:
if b"<details>" in line and b"</details>" in line:
pass
else:
if b'<details>' in line and after_detail:
err_message = f'Missing closing detail tag round line {line_number - 1}'
if b"<details>" in line and after_detail:
err_message = f"Missing closing detail tag round line {line_number - 1}"
error = True
if b'</details>' in line and not after_detail:
err_message = f'Missing opening detail tag round line {line_number - 1}'
if b"</details>" in line and not after_detail:
err_message = f"Missing opening detail tag round line {line_number - 1}"
error = True

if b'<details>' in line:
if b"<details>" in line:
after_detail = True

if b'</details>' in line and after_detail:
if b"</details>" in line and after_detail:
after_detail = False

if error:
Expand All @@ -107,36 +105,48 @@ def check_summary_tag(file_list):

after_summary = False
error = False
err_message = ''
for line_number, line in enumerate(file_list):
if b'<summary>' in line and b'</summary>' in line:
pass
err_message = ""
for idx, line in enumerate(file_list):
line_number = idx + 1
if b"<summary>" in line and b"</summary>" in line:
if after_summary:
err_message = f"Missing closing summary tag around line {line_number}"
error = True

else:
if b'<summary>' in line and after_summary:
err_message = f'Missing closing summary tag around line {line_number}'
if b"<summary>" in line and after_summary:
err_message = f"Missing closing summary tag around line {line_number}"
error = True
if b'</summary>' in line and not after_summary:
err_message = f'Missing opening summary tag around line {line_number}'
if b"</summary>" in line and not after_summary:
err_message = f"Missing opening summary tag around line {line_number}"
error = True

if b'<summary>' in line:
if b"<summary>" in line:
after_summary = True

if b'</summary>' in line and after_summary:
if b"</summary>" in line and after_summary:
after_summary = False

if error:
errors.append(err_message)
if error:
errors.append(err_message)

error = False


if __name__ == '__main__':
def check_md_file(file_name):
with open(p, "rb") as f:
file_list = [line.rstrip() for line in f.readlines()]
check_details_tag(file_list)
check_summary_tag(file_list)


if __name__ == "__main__":
print(f"..........Checking {p}..........")
check_md_file(p)
if errors:
print(f"{p} failed", file=sys.stderr)
for error in errors:
print(error)
print(error, file=sys.stderr)
exit(1)

print("Tests passed successfully.")
7 changes: 0 additions & 7 deletions topics/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2349,14 +2349,7 @@ The pod is automatically assigned with the default service account (in the names

### Patterns

<details>
<summary>Explain the sidecar container pattern</summary><br><b>
ion container, there is a sidecar container.
</b></details>
r, the application would not exist. In addition to the application container, there is a sidecar container.

In simpler words, when you have a Pod and there is more than one container running in that Pod that supports or complements the application container, it means you use the sidecar pattern.
</b></details>

### CronJob

Expand Down
1 change: 1 addition & 0 deletions topics/security/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ True. It is only used during the key exchange algorithm of symmetric encryption.
Hashing is a mathematical function for mapping data of arbitrary sizes to fixed-size values. This function produces a "digest" of the data that can be used for verifying that the data has not been modified (amongst other uses)
</b></details>

<details>
<summary>How is hashing different from encryption?</summary><br><b>

Encrypted data can be decrypted to its original value. Hashed data cannot be reversed to view the original data - hashing is a one-way function.
Expand Down