From 6f3416ac7bd7ed3adceb3249ef5a33765974a396 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Fri, 21 Apr 2023 08:19:00 +0800 Subject: [PATCH] fix: :green_heart: fix CI --- .github/workflows/upload_COS.yml | 15 ++----- dependency/py/nowHash.py | 14 +++++++ dependency/py/upload.py | 68 -------------------------------- 3 files changed, 18 insertions(+), 79 deletions(-) create mode 100644 dependency/py/nowHash.py delete mode 100644 dependency/py/upload.py diff --git a/.github/workflows/upload_COS.yml b/.github/workflows/upload_COS.yml index dedef02..8b15744 100644 --- a/.github/workflows/upload_COS.yml +++ b/.github/workflows/upload_COS.yml @@ -15,12 +15,9 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Unix to dos - run: bash ./dependency/shell/Unix2dos.sh - - name: Hash THUAI6 run: | - python ./dependency/py/HashFiles.py -t ../THUAI6 + python ./dependency/py/nowHash.py - name: Setup dotnet Core uses: actions/setup-dotnet@v3 @@ -48,21 +45,17 @@ jobs: with: path: | ./THUAI6 - key: ${{ hashFiles('./hash.json') }} + key: ${{ hashFiles('./hash.txt') }} build_upload: needs: client_build runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - name: Unix to dos - run: bash ./dependency/shell/Unix2dos.sh - name: Hash THUAI6 run: | - python ./dependency/py/HashFiles.py -t ../THUAI6 - + python ./dependency/py/nowHash.py - name: Setup dotnet Core uses: actions/setup-dotnet@v3 @@ -83,7 +76,7 @@ jobs: with: path: | ./THUAI6 - key: ${{ hashFiles('./hash.json') }} + key: ${{ hashFiles('./hash.txt') }} - name: Publish run: | diff --git a/dependency/py/nowHash.py b/dependency/py/nowHash.py new file mode 100644 index 0000000..3214fe1 --- /dev/null +++ b/dependency/py/nowHash.py @@ -0,0 +1,14 @@ +# -*- coding=utf-8 +import sys +import os +import argparse +import getopt +import hashlib +import json +import mimetypes + + +with open('..\..\.git\FETCH_HEAD', 'r') as f: + data = f.read() +with open('..\..\hash.txt', 'w') as fw: + fw.write(data[:data.find(' ')]) diff --git a/dependency/py/upload.py b/dependency/py/upload.py deleted file mode 100644 index 8173378..0000000 --- a/dependency/py/upload.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding=utf-8 -from qcloud_cos import CosConfig -from qcloud_cos import CosS3Client -import sys -import os -import logging -import getopt -import hashlib -import json - -def upload(path): - response = client.upload_file( - Bucket='thuai6-1314234950', - LocalFilePath= path, - Key = "TEST", - PartSize=1, - MAXThread=10, - EnableMD5=False - ) - return response - -def generateHashFile(): - file = targetfolder - hashlist={} - for root, dirs, files in os.walk(file): - for file in files: - path = os.path.join(root, file) - with open(path, 'rb') as f: - data = f.read() - hashlist[path.replace(file)]=hashlib.md5(data) - res = json.dumps(hashlist) - - -try: - opts,args = getopt.getopt(sys.argv[1:],"t:i:k:") -except getopt.GetoptError: - print("upload.py -d -i -k") - -sKey="" -sId="" -targetfolder="" -for opt,arg in opts: - if opt == "-t": - targetfolder = arg - elif opt == "-i": - sId = arg - elif opt == "-k": - sKey = arg - -print("skey:"+sKey+" sid:"+sId+" tar:"+targetfolder) -# 正常情况日志级别使用 INFO,需要定位时可以修改为 DEBUG,此时 SDK 会打印和服务端的通信信息 -logging.basicConfig(level=logging.INFO, stream=sys.stdout) - -# 1. 设置用户属性, 包括 secret_id, secret_key, region等。Appid 已在 CosConfig 中移除,请在参数 Bucket 中带上 Appid。Bucket 由 BucketName-Appid 组成 -secret_id = sId # 用户的 SecretId,建议使用子账号密钥,授权遵循最小权限指引,降低使用风险。子账号密钥获取可参见 https://cloud.tencent.com/document/product/598/37140 -secret_key = sKey # 用户的 SecretKey,建议使用子账号密钥,授权遵循最小权限指引,降低使用风险。子账号密钥获取可参见 https://cloud.tencent.com/document/product/598/37140 -region = 'ap-beijing' # 替换为用户的 region,已创建桶归属的 region 可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket - # COS 支持的所有 region 列表参见 https://cloud.tencent.com/document/product/436/6224 -token = None # 如果使用永久密钥不需要填入 token,如果使用临时密钥需要填入,临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048 -scheme = 'https' # 指定使用 http/https 协议来访问 COS,默认为 https,可不填 - -config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token, Scheme=scheme) -client = CosS3Client(config) - -generateHashFile() - -#### 高级上传接口(推荐) -# 根据文件大小自动选择简单上传或分块上传,分块上传具备断点续传功能。