Skip to content

Commit

Permalink
CI(UNIX) Cache Test (#192)
Browse files Browse the repository at this point in the history
* cache test

* 更新 unix.yml

* 更新 get_qqnt.py
  • Loading branch information
LY-Xiang authored Jan 10, 2025
1 parent 03a4054 commit f7c203f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 15 deletions.
49 changes: 38 additions & 11 deletions .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
- '.github/workflows/unix.yml'
workflow_dispatch:

concurrency:
group: unix
cancel-in-progress: false

jobs:
install_and_test:
runs-on: ${{ matrix.os }}
Expand All @@ -27,16 +31,30 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.9 # 指定 Python 3 版本
cache: 'pip'

- name: Install dependencies
- name: Install dependencies (Python)
run: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get install -f
sudo apt-get install -y xvfb libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 xdg-utils libatspi2.0-0 libuuid1 libsecret-1-0
fi
- name: Cache (apt)
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: xvfb libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 xdg-utils libatspi2.0-0 libuuid1 libsecret-1-0
version: ${{ runner.os }}

- name: Install dependencies (apt)
if: runner.os == 'Linux'
run: sudo apt-get install xvfb libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 xdg-utils libatspi2.0-0 libuuid1 libsecret-1-0 -y

- name: Restore Cache (QQ)
uses: actions/cache/restore@v4
with:
path: QQ
key: QQ-${{ runner.os }}-${{ runner.arch }}

- name: Download and Install QQ Software
run: |
echo "当前 RUNNER_OS: $RUNNER_OS"
Expand All @@ -51,6 +69,12 @@ jobs:
open /Applications/QQ.app/ & # 运行 QQ 以创建沙盒内文件夹
fi
- name: Save Cache (QQ)
uses: actions/cache/save@v4
with:
path: QQ
key: QQ-${{ runner.os }}-${{ runner.arch }}

- name: Run install.sh
run: |
chmod +x install.sh
Expand Down Expand Up @@ -102,15 +126,18 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Flatpak
run: |
sudo apt-get install -y xvfb # 虚拟显示
sudo apt-get update
sudo apt-get install -y flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Cache (apt)
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: xvfb flatpak
version: flatpak

- name: Install dependencies (apt)
run: sudo apt-get install xvfb flatpak -y

- name: Install Flatpak QQ
run: |
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo flatpak install -y flathub com.qq.QQ
- name: Run install.sh
Expand Down
15 changes: 11 additions & 4 deletions get_qqnt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from requests import get
from sys import exit, argv

from os import mkdir
from os.path import join as pjoin,isfile,isdir
from shutil import copyfile

# index2cdnjs
def get1(r):
Expand Down Expand Up @@ -52,6 +54,11 @@ def get2(r, key):
print("url:%s" % r)

# download
with open(name, "wb") as QQ:
for chunk in get(r, stream=True).iter_content(chunk_size=4096):
QQ.write(chunk)
p=pjoin("QQ",name)
if not isfile(p):
if not isdir("QQ"):
mkdir("QQ")
with open(p, "wb") as QQ:
for chunk in get(r, stream=True).iter_content(chunk_size=4096):
QQ.write(chunk)
copyfile(p,name)

0 comments on commit f7c203f

Please sign in to comment.