Add Danger (#1857)
* Add Danger * Create Dangerfile * Add Gemfile * Rename danger to danger.ci * Rename danger.ci to danger.yml * Update Dangerfile * Add validate JSON * Add find * Add image and json validation * Add Payment: Paid for stale * Add validation for info.json, list.json files and check file names * Add Payment: Unpaid * Optimised images with calibre/image-actions * Add validation for whitelist and blacklist * Update helpers.ts * Update Dangerfile * Optimised images with calibre/image-actions * Update danger.yml * Remove uppercase logo Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Mykola <kolya182@gmail.com>
4
.github/stale.yml
vendored
|
@ -4,11 +4,9 @@ daysUntilStale: 1
|
|||
daysUntilClose: 2
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- 'Payment: Paid'
|
||||
- pinned
|
||||
- security
|
||||
- paid
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: wontfix
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
|
|
21
.github/workflows/danger.yml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
name: Danger
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
danger:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install gems
|
||||
run: sudo gem install bundler --no-document
|
||||
- name: Bundle update
|
||||
run: bundle update --bundler
|
||||
- name: Run Danger
|
||||
run: danger --verbose
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.DANGER_TOKEN }}
|
109
Dangerfile
Normal file
|
@ -0,0 +1,109 @@
|
|||
require 'find'
|
||||
require 'image_size'
|
||||
require 'json-schema'
|
||||
|
||||
assets_folder = './blockchains'
|
||||
allowed_extensions = ['png', 'json']
|
||||
allowed_file_names = ['info', 'list', 'logo', 'whitelist', 'blacklist']
|
||||
|
||||
# Failures
|
||||
# Do not allow files in this directory
|
||||
Dir.foreach(assets_folder) \
|
||||
.map { |x| File.expand_path("#{assets_folder}/#{x}") } \
|
||||
.select { |x| File.file?(x) }
|
||||
.map { |x|
|
||||
fail("Not allowed to have files inside blockchains folder itself. You have to add them inside specific blockchain folder as blockchain/ethereum or blockchain/binance for file: " + x)
|
||||
}
|
||||
|
||||
Find.find(assets_folder) do |file|
|
||||
file_extension = File.extname(file).delete('.')
|
||||
file_name = File.basename(file, File.extname(file))
|
||||
|
||||
# Skip if directory
|
||||
if File.directory?(file)
|
||||
next
|
||||
end
|
||||
|
||||
if !allowed_extensions.include? file_extension
|
||||
fail("Extension not allowed for file: " + file)
|
||||
end
|
||||
|
||||
if !allowed_file_names.include? file_name
|
||||
fail("Filename not allowed for file: " + file)
|
||||
end
|
||||
|
||||
# Validate JSON content
|
||||
if file_extension == 'json'
|
||||
value = nil
|
||||
begin
|
||||
value = JSON.parse(File.open(file).read)
|
||||
rescue JSON::ParserError, TypeError => e
|
||||
fail("Wrong JSON content in file: " + file)
|
||||
end
|
||||
|
||||
# Validate info.json
|
||||
if file_name == 'info'
|
||||
schema = {
|
||||
"type": "object",
|
||||
"required": ["name", "website", "short_description", "explorer"],
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"website": {"type": "string"},
|
||||
"short_description": {"type": "string"},
|
||||
"explorer": {"type": "string"}
|
||||
}
|
||||
}
|
||||
errors = JSON::Validator.fully_validate(schema, value)
|
||||
errors.each { |error| message("#{error} in file #{file}") }
|
||||
end
|
||||
|
||||
# Validate list.json for validators
|
||||
if file_name == 'list'
|
||||
schema = {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"properties": {
|
||||
"id": { "type": "string" },
|
||||
"name": { "type": "string" },
|
||||
"description": { "type": "string" },
|
||||
"website": { "type": "string" }
|
||||
},
|
||||
"required": ["id", "name", "description", "website"]
|
||||
}
|
||||
}
|
||||
errors = JSON::Validator.fully_validate(schema, value)
|
||||
errors.each { |error| message("#{error} in file #{file}") }
|
||||
end
|
||||
|
||||
# Validate whitelist, blacklist files
|
||||
if file_name == 'whitelist' || file_name == 'blacklist'
|
||||
schema = {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
errors = JSON::Validator.fully_validate(schema, value)
|
||||
errors.each { |error| message("#{error} in file #{file}") }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Validate images
|
||||
if file_extension == 'png'
|
||||
image_size = ImageSize.path(file)
|
||||
|
||||
if image_size.width > 512 || image_size.height > 512
|
||||
fail("Image width or height is higher than 512px for file: " + file)
|
||||
end
|
||||
|
||||
if image_size.format == 'png'
|
||||
fail("Image should be PNG for file: " + file)
|
||||
end
|
||||
|
||||
# Make sure file size only 100kb
|
||||
if File.size(file).to_f / 1024 > 100
|
||||
fail("Image should less than 100kb for file: " + file)
|
||||
end
|
||||
end
|
||||
end
|
5
Gemfile
Normal file
|
@ -0,0 +1,5 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gem 'danger'
|
||||
gem 'image_size', '~> 2.0'
|
||||
gem 'json-schema'
|
64
Gemfile.lock
Normal file
|
@ -0,0 +1,64 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
claide (1.0.3)
|
||||
claide-plugins (0.9.2)
|
||||
cork
|
||||
nap
|
||||
open4 (~> 1.3)
|
||||
colored2 (3.1.2)
|
||||
cork (0.3.0)
|
||||
colored2 (~> 3.1)
|
||||
danger (6.3.2)
|
||||
claide (~> 1.0)
|
||||
claide-plugins (>= 0.9.2)
|
||||
colored2 (~> 3.1)
|
||||
cork (~> 0.1)
|
||||
faraday (~> 0.9)
|
||||
faraday-http-cache (~> 2.0)
|
||||
git (~> 1.6)
|
||||
kramdown (~> 2.0)
|
||||
kramdown-parser-gfm (~> 1.0)
|
||||
no_proxy_fix
|
||||
octokit (~> 4.7)
|
||||
terminal-table (~> 1)
|
||||
faraday (0.17.3)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-http-cache (2.1.0)
|
||||
faraday (~> 0.8)
|
||||
git (1.6.0)
|
||||
rchardet (~> 1.8)
|
||||
image_size (2.0.2)
|
||||
json-schema (2.8.1)
|
||||
addressable (>= 2.4)
|
||||
kramdown (2.1.0)
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
multipart-post (2.1.1)
|
||||
nap (1.1.0)
|
||||
no_proxy_fix (0.1.2)
|
||||
octokit (4.18.0)
|
||||
faraday (>= 0.9)
|
||||
sawyer (~> 0.8.0, >= 0.5.3)
|
||||
open4 (1.3.4)
|
||||
public_suffix (4.0.4)
|
||||
rchardet (1.8.0)
|
||||
sawyer (0.8.2)
|
||||
addressable (>= 2.3.5)
|
||||
faraday (> 0.8, < 2.0)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
unicode-display_width (1.7.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
danger
|
||||
image_size (~> 2.0)
|
||||
json-schema
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.2
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 52 KiB |
|
@ -10,5 +10,6 @@
|
|||
"url":"https://twitter.com/streamixio",
|
||||
"handle":"Streamixio"
|
||||
}
|
||||
]
|
||||
],
|
||||
"explorer": "https://tronscan.org/#/token20/TFPAuuQym78giRve6iHTf4y7dZJxAkkrUa"
|
||||
}
|
||||
|
|
|
@ -260,7 +260,10 @@ export const rootDirAllowedFiles = [
|
|||
"package.json",
|
||||
"README.md",
|
||||
".git",
|
||||
"pricing"
|
||||
"pricing",
|
||||
"Dangerfile",
|
||||
"Gemfile",
|
||||
"Gemfile.lock"
|
||||
]
|
||||
|
||||
export const assetFolderAllowedFiles = [
|
||||
|
|