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 <kolya182@users.noreply.github.com>
This commit is contained in:
mykola.eth 2020-04-16 19:27:40 -07:00 committed by GitHub
parent 27d26786bb
commit 440bc104de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 77 additions and 42 deletions

View File

@ -1,5 +1,8 @@
name: Compress images
on: pull_request
on:
push:
branches:
- master
jobs:
build:
name: calibreapp/image-actions

26
.github/workflows/daily_update.yml vendored Normal file
View File

@ -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

37
.github/workflows/formatter.yml vendored Normal file
View File

@ -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

View File

@ -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##*/}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -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)
})
})

View File

@ -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))
}

View File

@ -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 => {