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

* Smoother practice experience

* update ci to check all md files

* fix some syntax

* fix README-zh_CN.md

* update syntax_lint accorging to PEP8

* Temporarily delete this question 'Explain the sidecar container pattern' to pass the workflow

---------

Co-authored-by: zhangzhen <zhangzhen@nao.cas.cn>
Co-authored-by: Arie Bregman <bregman.arie@gmail.com>
This commit is contained in:
MengDanzz 2023-02-06 02:50:51 +08:00 committed by GitHub
parent 50c9714fe4
commit 01e1dddd2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 47 deletions

View File

@ -289,7 +289,7 @@
</b></details>
<details>
<summary>你是如何实施从某个阶段而不是从最开始构建的选项?<summary><br><b>
<summary>你是如何实施从某个阶段而不是从最开始构建的选项?</summary><br><b>
</b></details>
<details>
@ -924,7 +924,7 @@ Zombie假死态
</b></details>
<details>
<summary>你能解释一下网络进程/连接如何建立以及如何终止?><br></b>
<summary>你能解释一下网络进程/连接如何建立以及如何终止?</summary><br></b>
</b></details>
<details>
@ -1385,6 +1385,7 @@ Terraform与其他工具相比的优势
* Provider
* Resource
* Provisioner
</summary>
</b></details>
<details>
@ -1656,7 +1657,7 @@ Docker Cloud构建在Docker Hub之上因此Docker Cloud提供了
</b></details>
<details>
<summary>解释一下递归</summary<br><b>
<summary>解释一下递归</summary><br><b>
</b></details>
<details>
@ -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>
@ -2072,6 +2073,7 @@ def reverse_string(string):
* Mergesort
* Bucket Sort
* Radix Sort
</summary>
</b></details>
<a name="python-advanced"></a>
@ -2110,7 +2112,7 @@ def reverse_string(string):
</b></details>
<details>
<summary>你可以在Python中实现链接链表吗?<br><b>
<summary>你可以在Python中实现链接链表吗?</summary><br><b>
</b></details>
<details>
@ -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>

View File

@ -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

View File

@ -11,12 +11,10 @@ $ python tests/syntax_lint.py
"""
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 = []
@ -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
@ -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
@ -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:
@ -107,22 +105,26 @@ 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
else:
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}'
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
if b'<summary>' in line:
else:
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}"
error = True
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:
@ -131,12 +133,20 @@ def check_summary_tag(file_list):
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.")

View File

@ -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

View File

@ -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.