Skip to content

Commit

Permalink
修改测试脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
wes-lin committed Feb 26, 2025
1 parent 395d3a3 commit 55f4719
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ jobs:
with:
node-version: 18

- name: Restore cached Cookie
id: cache-cookie-restore
uses: actions/cache/restore@v4
with:
path: .cookie
key: ${{ runner.os }}-cookie

- name: Test Cookie
if: steps.cache-cookie-restore.outputs.cache-hit
run: echo "cookie cache hit!"

- name: init secrets
uses: shine1594/secrets-to-env-action@master
with:
Expand All @@ -48,14 +37,6 @@ jobs:
timeout_minutes: 10
max_attempts: 3
command: npm start

- name: Save cookie
id: cache-primes-save
uses: actions/cache/save@v4
with:
path: |
.cookie
key: ${{ steps.cache-cookie-restore.outputs.cache-primary-key }}

- name: Keep Running
if: github.event_name == 'schedule'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ tests/**/coverage/
*.sln

cheese.log

.cookie
21 changes: 13 additions & 8 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const wecomBot = require("./push/wecomBot");
const wxpush = require("./push/wxPusher");
const accounts = require("../accounts");
const families = require("../families");
const { env } = require("process");
const execThreshold = process.env.EXEC_THRESHOLD || 1;

const mask = (s, start, end) => s.split("").fill("*", start, end).join("");
Expand Down Expand Up @@ -93,7 +94,7 @@ const pushServerChan = (title, desp) => {
}
const json = JSON.parse(res.text);
if (json.code !== 0) {
logger.error(`ServerChan推送失败:${JSON.stringify(json)}`);
logger.error(`ServerChan推送失败:${json.info}`);
} else {
logger.info("ServerChan推送成功");
}
Expand Down Expand Up @@ -215,7 +216,6 @@ const loadCookies = (userName) => {
const cookies = JSON.parse(fs.readFileSync(`${cookieDir}/${userName}.json`, { encoding:'utf8' }))
const cookieJar = new CookieJar()
cookies.forEach(cookie => {
console.log(cookie)
cookieJar.setCookieSync(Cookie.parse(cookie), "https://cloud.189.cn")
});
return cookieJar
Expand All @@ -235,13 +235,18 @@ async function main() {
try {
logger.log(`账户 ${userNameInfo}开始执行`);
const cloudClient = new CloudClient(userName, password);
const cookies = loadCookies(userName)
if(cookies) {
cloudClient.cookieJar = cookies
} else {
console.log('未发现cookie, 手动进行登录')
// github action环境 ip不固定, 存cookie无效
if(process.env.GITHUB_ACTIONS) {
await cloudClient.login();
saveCookies(userName, cloudClient.cookieJar)
} else {
const cookies = loadCookies(userName)
if(cookies) {
cloudClient.cookieJar = cookies
} else {
console.log('未发现cookie, 手动进行登录')
await cloudClient.login();
saveCookies(userName, cloudClient.cookieJar)
}
}
const beforeUserSizeInfo = await cloudClient.getUserSizeInfo();
console.log(beforeUserSizeInfo)
Expand Down

0 comments on commit 55f4719

Please sign in to comment.