-
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 #4 from web333wiki/bear-add-ci
Add CI to check cards
- Loading branch information
Showing
4 changed files
with
50 additions
and
2 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,26 @@ | ||
import os | ||
import sys | ||
|
||
def check_cards(): | ||
valid_tags = ['#show-card', '#awesome-card', '#explain-card', '#grant-card'] | ||
cards_dir = 'cards' | ||
|
||
for root, _, files in os.walk(cards_dir): | ||
for file in files: | ||
if file.endswith('.md'): | ||
with open(os.path.join(root, file), 'r') as f: | ||
lines = f.readlines() | ||
first_line = lines[0].strip() | ||
if file == 'Web3 Wiki.md': | ||
if not all(tag in first_line for tag in valid_tags): | ||
print(f"Error: {file} does not contain all valid tags in the first line.") | ||
sys.exit(1) | ||
else: | ||
tags_in_file = [line.strip() for line in lines if line.strip() in valid_tags] | ||
if len(tags_in_file) != 1: | ||
print(f"Error: {file} should contain exactly one valid tag.") | ||
sys.exit(1) | ||
print("All cards are valid.") | ||
|
||
if __name__ == "__main__": | ||
check_cards() |
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,23 @@ | ||
name: Check Cards | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
check-cards: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
- name: Run card check script | ||
run: python .github/scripts/check-cards.py |
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,4 +1,3 @@ | ||
|
||
#show-card | ||
|
||
>[!todo] | ||
|
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,4 +1,4 @@ | ||
#show-card | ||
#show-card | ||
|
||
## Introduction | ||
|
||
|