-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Automate excluded device section in README
- Loading branch information
Showing
6 changed files
with
184 additions
and
8 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,52 @@ | ||
import csv | ||
import os | ||
|
||
|
||
def get_file_line_count(): | ||
if os.name == "posix": | ||
return int(os.popen("wc -l < excluded-devices.csv").read()[:-1]) | ||
elif os.name == "nt": | ||
return int(os.popen("type excluded-devices.csv | find /v /c \"\"").read()[:-1]) - 1 | ||
else: | ||
raise Exception("Who are you?") | ||
|
||
|
||
output = "" | ||
print(f"Reading CSV file in {os.getcwd()}") | ||
with open("excluded-devices.csv", "r", encoding="utf-8") as file: | ||
reader = csv.reader(file, delimiter=',') | ||
row_count = get_file_line_count() | ||
print(f"Found {row_count} entries") | ||
if row_count < 1: | ||
raise Exception("Empty CSV file") | ||
next(reader) | ||
name = None | ||
models = [] | ||
for row in reader: | ||
print("Entry:", row) | ||
if name == row[0]: # multiple technical names | ||
if not models.__contains__(row[1]): | ||
models.append(row[1]) | ||
else: # new model entry | ||
if name is not None: | ||
output += "- " + name + " (" + ", ".join(models) + ")\n" | ||
name = row[0] | ||
models = [row[1]] | ||
output += "- " + name + " (" + ", ".join(models) + ")\n" | ||
|
||
print("Calculated output:") | ||
print(output) | ||
|
||
readme = open("../README.md", "r", encoding="utf-8").read() | ||
marker1 = "<!--- marker1 -->" | ||
marker2 = "<!--- marker2 -->" | ||
list_first_index = readme.find(marker1) + len(marker1) + 1 | ||
list_last_index = readme.find(marker2) | ||
print(f"Markers found at {list_first_index} and {list_last_index}") | ||
|
||
if list_first_index == -1 or list_last_index == -1: | ||
raise Exception("Position markers not found") | ||
|
||
print("Writing README file") | ||
with open("../README.md", "w", encoding="utf-8") as file: | ||
file.write(readme[:list_first_index] + output + readme[list_last_index:]) |
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,73 @@ | ||
gplay-name,gplay-technical-name,branding,device | ||
Asus ROG Phone 5,asus ASUS_I005_1,Asus,ASUS_I005_1 | ||
Asus ROG Phone 6,asus ASUS_AI2201,Asus,ASUS_AI2201 | ||
Blu G33,BLU G0890,Blu,G0890 | ||
Blu G33,BLU G0892,Blu,G0892 | ||
Blu G33,BLU G0892,Blu,G0892_SP | ||
Google Pixel 4,google flame,Google,flame | ||
Google Pixel 4 XL,google coral,Google,coral | ||
Google Pixel 4a,google sunfish,Google,sunfish | ||
Google Pixel 4a 5G,google bramble,Google,bramble | ||
Google Pixel 5,google redfin,Google,redfin | ||
Google Pixel 5a 5G,google barbet,Google,barbet | ||
Lava Blaze 5G,LAVA LXX503,Lava,LXX503 | ||
Motorola motorola edge 20,motorola berlin,Motorola,berlin | ||
Motorola motorola edge 30,motorola dubai,Motorola,dubai | ||
Motorola motorola edge 30 ultra,motorola eqs,Motorola,eqs | ||
Motorola motorola edge 40,motorola lyriq,Motorola,lyriq | ||
Nothing Phone 1,Nothing Spacewar,Nothing,Spacewar | ||
Nothing Phone 2,Nothing Pong,Nothing,Pong | ||
OnePlus 8T,OnePlus OnePlus8T,OnePlus,OnePlus8T | ||
OnePlus 9 5G,OnePlus OnePlus9,OnePlus,OnePlus9 | ||
OnePlus 9 5G,OnePlus OnePlus9TMO,OnePlus,OnePlus9TMO | ||
OnePlus 9 Pro 5G,OnePlus OnePlus9Pro,OnePlus,OnePlus9Pro | ||
OnePlus 9 Pro 5G,OnePlus OnePlus9ProTMO,OnePlus,OnePlus9ProTMO | ||
OnePlus 9RT 5G,OnePlus OP5154L1,OnePlus,OP5154L1 | ||
OnePlus 9RT 5G,OnePlus OP5155L1,OnePlus,OP5155L1 | ||
OnePlus 10T 5G,OnePlus OP5552L1,OnePlus,OP5552L1 | ||
OnePlus 11 5G,OnePlus OP594DL1,OnePlus,OP594DL1 | ||
OnePlus 11R 5G,OnePlus OP5961L1,OnePlus,OP5961L1 | ||
OnePlus Nord CE 2,OnePlus OP555BL1,OnePlus,OP555BL1 | ||
OnePlus Nord CE 2 Lite 5G,OnePlus OP535DL1,OnePlus,OP535DL1 | ||
OnePlus Nord CE 5G,OnePlus OnePlusNordCE,OnePlus,OnePlusNordCE | ||
Oppo CPH2145,OPPO OP4F1BL1,Oppo,OP4F1BL1 | ||
Oppo CPH2249,OPPO OP4F81L1,Oppo,OP4F81L1 | ||
Oppo CPH2251,OPPO OP4F83L1,Oppo,OP4F83L1 | ||
Oppo CPH2293,OPPO OP52E1L1,Oppo,OP52E1L1 | ||
Oppo OPPO Reno6 Z 5G,OPPO OP4FA7L1,Oppo,OP4FA7L1 | ||
Oppo OPPO Reno7,OPPO OP533FL1,Oppo,OP533FL1 | ||
POCO F4,POCO munch,POCO,munch | ||
POCO M5,POCO stone,POCO,stone | ||
POCO X2,POCO phoenixin,POCO,phoenixin | ||
Redmi 10C,Redmi rain,Redmi,rain | ||
Redmi 12 5G,Redmi XIG03,Redmi,XIG03 | ||
Redmi 12 5G,Redmi river,Redmi,river | ||
Redmi Note 10 Pro,POCO chopin,Redmi,chopin | ||
Redmi Note 10 Pro,Redmi sweet,Redmi,sweet | ||
Redmi Note 10 Pro,Redmi sweetin,Redmi,sweetin | ||
Redmi Note 10S,Redmi secret,Redmi,secret | ||
Redmi Note 12,Redmi tapas,Redmi,tapas | ||
Redmi Note 12,Redmi topaz,Redmi,topaz | ||
Redmi Note 12 Pro 5G,Redmi ruby,Redmi,ruby | ||
Redmi Note 12 Pro+ 5G,Redmi rubypro,Redmi,rubypro | ||
Redmi POCO F5,POCO marblein,Redmi,marblein | ||
realme 9,realme RE54E2L1,realme,RE54E2L1 | ||
realme 10 Pro 5G,realme RE588BL1,realme,RE588BL1 | ||
realme 10 Pro 5G,realme RE58B8L1,realme,RE58B8L1 | ||
realme 10 Pro+ 5G,realme RE58A5L1,realme,RE58A5L1 | ||
realme 11 Pro+ 5G,realme RE58B6L1,realme,RE58B6L1 | ||
realme narzo 30 5G,realme RE513CL1,realme,RE513CL1 | ||
Realme realme GT Master Edition,realme RE54ABL1,Realme,RE54ABL1 | ||
Realme realme GT Neo2 5G,realme RE879AL1,Realme,RE879AL1 | ||
realme 真我GT 2,realme RE58B2L1,realme,RE58B2L1 | ||
Vivo I2011,iQOO 2011,Vivo,2011 | ||
Vivo I2012,iQOO 2012,Vivo,2012 | ||
Vivo I2017,iQOO 2017,Vivo,2017 | ||
Vivo T2x 5G,vivo V2225,Vivo,V2225 | ||
Vivo V2053,vivo 2041,Vivo,2041 | ||
Vivo V2130,vivo 2130,Vivo,2130 | ||
Vivo V2141,vivo 2141,Vivo,2141 | ||
Vivo V27,vivo V2231,Vivo,V2231 | ||
Vivo vivo 2018,vivo 2018,Vivo,2018 | ||
Xiaomi 12T Pro,Xiaomi diting,Xiaomi,diting | ||
Xiaomi 13T,Xiaomi aristotle,Xiaomi,aristotle |
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
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
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,46 @@ | ||
name: Device Catalog Updater | ||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- '.github/excluded-devices.csv' | ||
|
||
jobs: | ||
update: | ||
name: Device Catalog Updater | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
sparse-checkout: | | ||
README.md | ||
.github/excluded-devices.csv | ||
.github/device-catalog-manager.py | ||
- name: List root folder | ||
run: | | ||
pwd | ||
ls -la | ||
- name: List .github folder | ||
run: | | ||
cd .github | ||
pwd | ||
ls -la | ||
- name: Update excluded devices in README via Python | ||
shell: sh | ||
run: | | ||
cd .github | ||
python device-catalog-manager.py | ||
- name: Commit updated README.md | ||
run: | | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
git checkout main | ||
git add README.md | ||
git commit -m "repo: Fill README with excluded devices" | ||
git push |
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