瀏覽代碼

Add possibility to run duplicate link check only

Changes:

- It is now possible to only check for duplicate
  links (without checking if the links are working)

- Check for duplicate links when a push occurs

- Update the scripts documentation accordingly
pull/3011/head
Matheus Felipe 2 年之前
父節點
當前提交
4bc90a81cc
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: AA785C523274872F
共有 3 個檔案被更改,包括 26 行新增3 行删除
  1. +4
    -0
      .github/workflows/test_of_push_and_pull.yml
  2. +8
    -0
      scripts/README.md
  3. +14
    -3
      scripts/validate/links.py

+ 4
- 0
.github/workflows/test_of_push_and_pull.yml 查看文件

@@ -31,3 +31,7 @@ jobs:
- name: Validate pull request changes
run: scripts/github_pull_request.sh ${{ github.repository }} ${{ github.event.pull_request.number }} ${FILENAME}
if: github.event_name == 'pull_request'

- name: Checking if push changes are duplicated
run: python scripts/validate/links.py ${FILENAME} --only_duplicate_links_checker
if: github.event_name == 'push'

+ 8
- 0
scripts/README.md 查看文件

@@ -40,6 +40,14 @@ To run link validation on the `README.md` file, being in the root directory of p
$ python scripts/validate/links.py README.md
```

As there are many links to check, this process can take some time. If your goal is not to check if the links are working, you can only check for duplicate links. Run:

```bash
$ python scripts/validate/links.py README.md -odlc
```

*`-odlc` is an abbreviation of `--only_duplicate_links_checker`*

## Running Tests

To run all tests it is necessary to change to the scripts directory:


+ 14
- 3
scripts/validate/links.py 查看文件

@@ -241,21 +241,32 @@ def start_links_working_checker(links: List[str]) -> None:
sys.exit(1)


def main(filename: str) -> None:
def main(filename: str, only_duplicate_links_checker: bool) -> None:

links = find_links_in_file(filename)

start_duplicate_links_checker(links)
start_links_working_checker(links)

if not only_duplicate_links_checker:
start_links_working_checker(links)


if __name__ == '__main__':
num_args = len(sys.argv)
only_duplicate_links_checker = False

if num_args < 2:
print('No .md file passed')
sys.exit(1)
elif num_args == 3:
third_arg = sys.argv[2].lower()

if third_arg == '-odlc' or third_arg == '--only_duplicate_links_checker':
only_duplicate_links_checker = True
else:
print(f'Third invalid argument. Usage: python {__file__} [-odlc | --only_duplicate_links_checker]')
sys.exit(1)

filename = sys.argv[1]

main(filename)
main(filename, only_duplicate_links_checker)

Loading…
取消
儲存