From 440bc104dee2812cdbda46ebd17b6102c12a78c8 Mon Sep 17 00:00:00 2001 From: "mykola.eth" <3277207+kolya182@users.noreply.github.com> Date: Thu, 16 Apr 2020 19:27:40 -0700 Subject: [PATCH] Add daily update action and formatter (#1882) * Run image compression on very push to master * Add contract in lowercase for test * Add daily updater * Add formatter on every pull,push to branches * Remove dublicates * Fix run syntax * Fix syntax * Run image compression only when push to master * Run formater on all PR, exept master * Add npm cache * Add branches * Try fix rename issue on ci * Add trailing slash * remove trailing * Move uses in step * remove dash from uses * Run each npm run individually * remove name * remove checksum * rename to jpg * Add AMATEN (AMA) lowercase * debug * Run checksum after formating * USet lates checkout and commit to branch innsted deatached head * Checkout to branch in checkout * Fix version * Add formating * Add formating Co-authored-by: kolya182 --- .github/workflows/compress_images.yml | 5 ++- .github/workflows/daily_update.yml | 26 ++++++++++++ .github/workflows/formatter.yml | 37 ++++++++++++++++++ .github/workflows/generator.yml | 27 ------------- .../logo.png | Bin 0 -> 2172 bytes .../logo.png | Bin 0 -> 1922 bytes script/erc20_to_checksum.ts | 6 +-- script/format_files_name.ts | 14 +++---- src/test/helpers.ts | 4 +- 9 files changed, 77 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/daily_update.yml create mode 100644 .github/workflows/formatter.yml delete mode 100644 .github/workflows/generator.yml create mode 100644 blockchains/ethereum/assets/0x42726d074BBa68Ccc15200442B72Afa2D495A783/logo.png create mode 100644 blockchains/ethereum/assets/0xd7E1e4530D95717506633E58437f056A49c1FABB/logo.png diff --git a/.github/workflows/compress_images.yml b/.github/workflows/compress_images.yml index 3d95fd0c8..e957ca29c 100644 --- a/.github/workflows/compress_images.yml +++ b/.github/workflows/compress_images.yml @@ -1,5 +1,8 @@ name: Compress images -on: pull_request +on: + push: + branches: + - master jobs: build: name: calibreapp/image-actions diff --git a/.github/workflows/daily_update.yml b/.github/workflows/daily_update.yml new file mode 100644 index 000000000..e8da9d400 --- /dev/null +++ b/.github/workflows/daily_update.yml @@ -0,0 +1,26 @@ +name: Daily Update +on: + push: + branches: [ master ] +jobs: + daily_update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + token: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + - uses: actions/setup-node@v1.4.1 + with: + node-version: 12 + - name: Install dependencies + run: npm i + - name: Generate list + run: | + npm run update:bep2 + npm run gen:list + - name: Commit daily changes if new updates + uses: stefanzweifel/git-auto-commit-action@v4.1.2 + with: + commit_user_name: trust-wallet-merge-bot + commit_user_email: mergebot@trustwallet.com + commit_message: Daily update + diff --git a/.github/workflows/formatter.yml b/.github/workflows/formatter.yml new file mode 100644 index 000000000..0414cc1aa --- /dev/null +++ b/.github/workflows/formatter.yml @@ -0,0 +1,37 @@ +name: Formatter +on: + push: + branches: + - '*' + - '!master' + pull_request: + branches: + - 'master' +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + - uses: actions/setup-node@v1.4.1 + with: + node-version: '12.x' + - name: Restore npm cache + uses: actions/cache@v1 + with: + id: cache-npm + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + - name: Install Dependencies + if: steps.cache-npm.outputs.cache-hit != 'true' + run: npm ci + - run: npm run format:all + - run: npm run resize + - name: Commit daily changes if new updates + uses: stefanzweifel/git-auto-commit-action@v4.1.2 + with: + commit_user_name: trust-wallet-merge-bot + commit_user_email: mergebot@trustwallet.com + commit_message: Add formating \ No newline at end of file diff --git a/.github/workflows/generator.yml b/.github/workflows/generator.yml deleted file mode 100644 index e65ef8bbb..000000000 --- a/.github/workflows/generator.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Generator -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] -jobs: - format: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1.4.1 - with: - node-version: 12 - - name: Generate list - run: | - npm install - npm run gen:list - git config --local user.email "trustbot@trustwallet.com" - git config --local user.name "Trust Wallet Actions Bot" - git diff - git commit -m "Generate whitelist and blacklist" -a - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.DANGER_GITHUB_API_TOKEN }} - branch: ${GITHUB_REF##*/} \ No newline at end of file diff --git a/blockchains/ethereum/assets/0x42726d074BBa68Ccc15200442B72Afa2D495A783/logo.png b/blockchains/ethereum/assets/0x42726d074BBa68Ccc15200442B72Afa2D495A783/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..a02a05e898c890983cbaa1f06ff186f80f0e3500 GIT binary patch literal 2172 zcmXw33p|urAAZL)lT34YXQqv$C@o*I$!w&ujJrPhuv+@m62>LID4VV1I=NLST3zM3 zyRv15aY>nsYY1HsMKsY`C5wp0jI-x`r|^)k>EQa!p+_aDeYQ2jvz$D#mU{)DflR; zU|^$?0b&ts1_&rYu(=L@g%Jb+6?9NZ$6z8H3D?+QfI1XZq1Xb(@8er(2&iU&J200H zs^~yO2W1qz1fC9&%3L7}r=o*u7^h?9AQiiRQkSAlXGE(XQs zM@(!NmZ-roPyp5l?TaK>r~#J;k&qm+l|rd>(9Ocu*uY6(LVltF1E8P>~*43c6DqNfLEFcCJlAsuQ zjj}r&a~GCl0LTepu?P^Z05Adv6aZ5o9$E?wff}G5m@A-Toxaro@DyMRhJjgd7cS~?=W`KI&cMzHmWB>MFtibN1m|X` zP}w7l!&5zJRYVON?SXEhrYm?jZv_WP&y(b}OED$pwR_R8^7gRPjZ)BR~B$Az#&@j*l?dBr?aZA)64IkzT#11 ztGMRpCy$n9|0tW9_)*cT$b0(hwwTEIwhy&^wYL|RGOsswwvKm|sID2xefU`s8RQWz z(!QzYRnJCi`lnL(*|!yn=fRRs$)WO7$A6PPDN=nPt-3pDUN2}3e>XHb^;kn**V?fW zei`%~ZMg29jeb7rq{29cPoay&E}q>~xbd0m5t)MAL_U`%-A$&=mkxQ(yZS z9gx|bMps`Y3mqa<1t$z7vzbmrORivP=eR}>>}X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l3^Obtn=0Y}SrIlB3b($N5=H?$x z@Q-)LpWm5ey{WQ&lb6QkA6m3m^-z;H<=r~J{N_|yd`>@Wqmkjn6zOZTb>wyH!oNc{ y_{@w-xm{}7+i2uB28Wq5DorY1CAk_MBOoKgKZg)9(JAz6MZAz_t68-@lXJKam literal 0 HcmV?d00001 diff --git a/blockchains/ethereum/assets/0xd7E1e4530D95717506633E58437f056A49c1FABB/logo.png b/blockchains/ethereum/assets/0xd7E1e4530D95717506633E58437f056A49c1FABB/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..dd0167f37320d2ed4f9fe28453628767dbb69ddb GIT binary patch literal 1922 zcmV-|2YvX7P)Px&08mU+MNDaN|3^pb|Nrd&|FtkC|5ri5d`$cQ@BaV* ze@92|Wka*m%=iEQ?f?Ji`uhKQZM)0E|NsBU|K#KH^#A|=)qic_NGY(~)93H<0002l z|NZU%|Js3W=Swc>MJw8th}wc|v%kOJ!nfYBq25d~*=SDTwyfUm+vaLh;c{N)IUd@7 zW#U*o_5c6jWJ~2wG2%@%&Sv}iaM9|R1_;l+NH63( zAKry;;Z;81WJ}>U+gOfuPpb>3u0;B;K!hkM;qInd0z>0ChQMk?5RZrH@J z*_DClUP$43VdZaQ*?(!{Pc!ADnC&tX=}R!>LL}rzD9wv?{x=ZiNiEx#k?T-7>1a>h zbzkaTKjTL&;e&MNTSDbeHS1qM+oO`;=l9=eRqAzT%Wh=gU`gj!MdxN#=c}CNcUkL8 zE#+`kyJ%h3Wk}y#Q0`Vc>|I6GT|mrRPUcQG*j_{1d1K*KJlTtO<#1NvT|?bnM!$4l z+kIv2N-yn7C*5LK?nNHnWme{4N9UJ_+CL}aiEaNW0N-?8-f36oUPshsOV+`z-cvi_ zVLs)Gcj7)F$XZb8s*>SAAmnOK+k$e(Zeij^Bim$B?n*b`OgY-XvfYDs*i}L3Hx}Yp zK=>^N<~0}XKO^8;JmF9?-ldk^*38~yNxi+p>NpzXk#p2=Ti$kD=)<$>sgvSnQr>=T z=0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.ts index 1e9181be2..e1b9f7319 100644 --- a/script/erc20_to_checksum.ts +++ b/script/erc20_to_checksum.ts @@ -2,9 +2,9 @@ import { ethSidechains, readDirSync, getChainAssetsPath } from "../src/test/help import { checksumAssetsFolder } from './format_files_name' ethSidechains.forEach(chain => { - const assetsPath = getChainAssetsPath(chain) + const chainAssetsPath = getChainAssetsPath(chain) - readDirSync(assetsPath).forEach(addr => { - checksumAssetsFolder(assetsPath, addr) + readDirSync(chainAssetsPath).forEach(addr => { + checksumAssetsFolder(chainAssetsPath, addr) }) }) \ No newline at end of file diff --git a/script/format_files_name.ts b/script/format_files_name.ts index de8c6ba6a..f8ddc339a 100644 --- a/script/format_files_name.ts +++ b/script/format_files_name.ts @@ -17,30 +17,26 @@ import { ethSidechains.forEach(chain => { const assetsPath = getChainAssetsPath(chain) - const chainAddresses = readDirSync(assetsPath) - - chainAddresses.forEach(address => { - checksumAssetsFolder(assetsPath, address) + readDirSync(assetsPath).forEach(address => { getChainAssetFilesList(chain, address).forEach(file => { if (getFileName(file) == logoName && getFileExt(file) !== logoExtension) { console.log(`Renaming incorrect asset logo extension ${file} ...`) renameAndMove(getChainAssetPath(chain, address), file, logo) } }) + checksumAssetsFolder(assetsPath, address) }) }) export function checksumAssetsFolder(assetsFolderPath: string, addr: string) { if (!isChecksum(addr)) { - const checksumAddr = toChecksum(addr) - renameAndMove(assetsFolderPath, addr, checksumAddr) + renameAndMove(assetsFolderPath, addr, toChecksum(addr)) } } export function renameAndMove(path: string, oldName: string, newName: string) { - console.log(` Renaming file or folder at path ${path}: ${oldName} => ${newName} ...`) - const renamed = execRename(path, getMoveCommandFromTo(oldName, newName)) - console.log(` Result renaming: ${renamed}`) + console.log(` Renaming file or folder at path ${path}: ${oldName} => ${newName}`) + execRename(path, getMoveCommandFromTo(oldName, newName)) } diff --git a/src/test/helpers.ts b/src/test/helpers.ts index 370fe950c..813a805dd 100644 --- a/src/test/helpers.ts +++ b/src/test/helpers.ts @@ -7,7 +7,6 @@ const web3 = new Web3('ws://localhost:8546'); import { CoinTypeUtils, CoinType } from "@trustwallet/types"; const sizeOf = require("image-size"); const { execSync } = require('child_process'); -import { AssetInfo } from "../../src/test/models"; export const getChainName = (id: CoinType): string => CoinTypeUtils.id(id) // 60 => ethereum export const Binance = getChainName(CoinType.binance) @@ -208,7 +207,8 @@ export function getMoveCommandFromTo(oldName: string, newName: string): string { } export function execRename(path: string, command: string) { - execSync(`cd ${path} && ${command}`, {encoding: "utf-8"}) + console.log(`Running command ${command}`) + execSync(command, {encoding: "utf-8", cwd: path}) } export const isValidatorHasAllKeys = (val: ValidatorModel): boolean => {