Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create cron nft-ttr to measure nft time to retrievability #1945

Merged
merged 99 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
45e8abf
add .github/workflows/cron-nft-ttr
gobengo May 25, 2022
e4d0d22
nft-ttr uses yargs to accept --url flag defaulting to nft.storage
gobengo May 25, 2022
9c968d9
nft-ttr downloads file to use as example image when measuring
gobengo May 25, 2022
82f97a5
nft-ttr downloads a source file to use for rest of test
gobengo May 25, 2022
e6cfff9
measureNftTimeToRetrievability.js logs duration
gobengo May 26, 2022
8bff205
measureNftTimeToRetrievability.js pushes metrics to metricsGateway
gobengo May 26, 2022
5d484b1
measureNftTimeToRetrievability.spec.js test doesnt hit network, asser…
gobengo May 26, 2022
a24f5aa
Add github workflow to typecheck/test cron
gobengo May 26, 2022
d84e70b
lint cron
gobengo May 27, 2022
35a4913
cron typechecks
gobengo May 27, 2022
b986dab
github workflow for cron check does npm-install in cron dir
gobengo May 27, 2022
4f3051a
try new workflow cron check install-command
gobengo May 27, 2022
3d319c8
dont use gozala typecheck action
gobengo May 27, 2022
b425e50
gh cron log
gobengo May 27, 2022
f2fc920
cron debug
gobengo May 27, 2022
a1d3ede
client has prepack script
gobengo May 27, 2022
1b340e3
cron debug
gobengo May 27, 2022
2a575f3
cron debug
gobengo May 27, 2022
08f1f62
cron rm mime-types
gobengo May 27, 2022
854a282
cron debug
gobengo May 27, 2022
03fbab9
cron debug
gobengo May 27, 2022
6f1cd2c
measureNftTimeToRetrievability can be tested with >10Mb files
gobengo May 31, 2022
a40a696
move online test to nft-ttr.spec.js
gobengo May 31, 2022
d4d4cd0
update cron-nft-ttr.yml
gobengo May 31, 2022
176ebea
nft-ttr support retrieving from multiple gateways
gobengo May 31, 2022
8a343f5
fix cron typecheck
gobengo May 31, 2022
6515072
.github cron-nft-ttr invokes using multiple gateways
gobengo May 31, 2022
9e686d7
github cron-nft-ttr passes secrets.PUSHGATEWAY_BASIC_AUTH
gobengo May 31, 2022
53b43b7
measureNftTimeToRetrievability.js metrics pushgateway works locally w…
gobengo Jun 1, 2022
efa794b
rm default metricsPushGateway and provide it in gh action
gobengo Jun 1, 2022
ff1d696
yarn.lock
gobengo Jun 1, 2022
b7d958b
ghwf cron-nft-ttr invokes with camelCase flag not kebab-case
gobengo Jun 1, 2022
f7f9755
ci(cron): action doesnt explicitly check for NFT_STORAGE_API_KEY env
gobengo Jun 1, 2022
c27d229
rename BYTES_10_MB -> defaultTestMinImageSizeBytes
gobengo Jun 1, 2022
74b91ce
add descriptive variable name isProcessEntrypoint in bin/nft-ttr.js
gobengo Jun 1, 2022
1a5d930
rm unused UrlIamages
gobengo Jun 1, 2022
b4e2528
rename fn TestImages -> createTestImages
gobengo Jun 1, 2022
9ddccc6
createTestImages uses RandomImageBlob
gobengo Jun 1, 2022
501b79d
packages/cron uses @typescript-eslint/recommended and naming-convention
gobengo Jun 1, 2022
398090a
measureNftTimeToRetrievability.js merges config & { secrets } into op…
gobengo Jun 1, 2022
6ee4020
add Milliseconds.subtract static
gobengo Jun 1, 2022
ff5d3c4
measureNftTimeToRetrievability checks success via response.ok and not…
gobengo Jun 1, 2022
4267950
cron eslintConfig rm unneeded .excludedFiles
gobengo Jun 1, 2022
4a27271
dont eslint-disable cron jobs/dagcargo , disable via eslintConfig ove…
gobengo Jun 1, 2022
a1fd2a3
start integrating prom-client
gobengo Jun 2, 2022
f9ef640
refactor metrics
gobengo Jun 2, 2022
88cf750
progress on metrics
gobengo Jun 2, 2022
0ee9e6c
measureNftTimeToRetrievability test works on airplane with no wifi
gobengo Jun 3, 2022
ee2c3ba
nft-ttr uses httpImageFetcher
gobengo Jun 4, 2022
7d543fa
measureNftTimeToRetrievability.spec asserts that pushRetrievalMetrics…
gobengo Jun 4, 2022
18c9fd6
cleanup cron nftttr
gobengo Jun 4, 2022
4a643a0
cron uses sade instead of yargs
gobengo Jun 5, 2022
280045a
cron tests work offline by stubbing network calls
gobengo Jun 5, 2022
f2450cc
cron package uses ava instead of jest for testing
gobengo Jun 6, 2022
4f584aa
measureNftTimeToRetrievability and nft-ttr return AsyncIterable and t…
gobengo Jun 6, 2022
40a19e6
cron eslint uses plugin:prettier/recommended
gobengo Jun 6, 2022
7484929
cron eslint add plugin:@typescript-eslint/recommended-requiring-type-…
gobengo Jun 6, 2022
6642e35
ci: cron.yml prepares client before linting cron
gobengo Jun 6, 2022
82b07a4
remove unused code pushing to prom pushgateway via fetch (and using w…
gobengo Jun 6, 2022
d393637
remove unused byteLength field from createRetrievalDurationSecondsMetric
gobengo Jun 6, 2022
9463cc8
cron test uses c8 to report code coverage
gobengo Jun 6, 2022
4b37443
cron remove unused safe-env-vars dep
gobengo Jun 6, 2022
bb6bc88
cron remove unused dep debug
gobengo Jun 6, 2022
49d89e8
cron eslint remove unused not-from-recommended rules
gobengo Jun 6, 2022
0e46d96
cron eslint remove unused eslintIgnore values
gobengo Jun 6, 2022
c25529b
cron remove unused eslint-disable file comments
gobengo Jun 6, 2022
a8528ae
clean createMeasureSecretsFromEnv based on review
gobengo Jun 9, 2022
726a7a4
nft-ttr error throws with cause instead of console.warn
gobengo Jun 14, 2022
1f5e764
fix: preserve all backup_urls for chunked uploads (#1940)
yusefnapora May 26, 2022
4822448
chore: refactor service configuration loading (#1914)
yusefnapora Jun 1, 2022
86986c6
feat: Adding HasDeleteRestriction user_tag (#1952)
jsdevel Jun 1, 2022
f5072e2
chore(main): release api 2.24.2 (#1930)
github-actions[bot] Jun 2, 2022
14d8ad2
feat: DB schema and API for user_tag_proposal. (#1410) (#1402)
jsdevel Jun 2, 2022
486fdcd
fix: config loading required vars (#1955)
hugomrdias Jun 2, 2022
5b5f341
feat: Adding admin ability to search by github_id (#1960)
jsdevel Jun 7, 2022
2a03744
chore(main): release api 2.25.0 (#1956)
github-actions[bot] Jun 7, 2022
5c2c7f5
feat: optimize metrics query (#1906)
johnathonroach Jun 7, 2022
fec755c
chore(main): release api 2.26.0 (#1966)
github-actions[bot] Jun 7, 2022
7035dae
feat: cron release workflow (#1932)
flea89 Jun 8, 2022
2a5592a
chore(main): release cron 3.1.0 (#1968)
github-actions[bot] Jun 8, 2022
94e43e3
feat: add NFTUp CTA to stats page (#1971)
johnathonroach Jun 9, 2022
48c4330
chore(main): release website 1.52.0 (#1975)
github-actions[bot] Jun 9, 2022
e7e5db5
fix: Adding user_tag_proposal schema to reset.sql for local dev (#1977)
jsdevel Jun 10, 2022
c2256b1
docs: add store from URL example (#1979)
Jun 13, 2022
de7ed04
Revert "nft-ttr error throws with cause instead of console.warn"
gobengo Jun 14, 2022
5e5ee27
nft-ttr rename main -> cli
gobengo Jun 14, 2022
d42d952
nft-ttr tests pass without process.env needing NFT_STORAGE_API_KEY
gobengo Jun 14, 2022
440e07e
cron: better typechecking around RetrievalDurationMetric value
gobengo Jun 14, 2022
ab441c9
test createMeasureOptionsFromSade
gobengo Jun 14, 2022
4007e42
test createMeasureSecretsFromEnv
gobengo Jun 14, 2022
2c852e2
rm sadeParseWithoutExit
gobengo Jun 14, 2022
835d77a
get rid of LogFunction
gobengo Jun 14, 2022
14449d8
Merge branch 'main' into issues/1943-measure-ttr
gobengo Jun 14, 2022
511e16c
test cron utils so coverage is green in c8
gobengo Jun 14, 2022
d3fff4b
rm --silent from cron-nft-ttr gh wf
gobengo Jun 14, 2022
fbfe265
remove unneeded eslint-disable-next-line
gobengo Jun 14, 2022
17f840a
remove commented console.log
gobengo Jun 14, 2022
6836369
Add explanation comment to hasOwnProperty
gobengo Jun 14, 2022
1aea9c1
rm unnecessary nohoists
gobengo Jun 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/cron-nft-ttr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Measure NFT Time to Retrievability (nft-ttr)

on:
schedule:
- cron: '30 * * * *'
workflow_dispatch:

jobs:
measure:
name: measure nft time to retrievability
runs-on: ubuntu-latest
strategy:
matrix:
env: ['staging', 'production']
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- uses: bahmutov/npm-install@v1
- name: Run job
env:
DEBUG: '*'
ENV: ${{ matrix.env }}
NFT_STORAGE_API_KEY: ${{ secrets.NFT_STORAGE_API_KEY }}
PUSHGATEWAY_JOBNAME: nftstorage_ci/instance/github_action
PUSHGATEWAY_URL: https://pushgateway.k8s.locotorp.info/metrics/job/nftstorage_ci/instance/github_action
PUSHGATEWAY_BASIC_AUTH: ${{ secrets.PUSHGATEWAY_BASIC_AUTH }}
gobengo marked this conversation as resolved.
Show resolved Hide resolved
run: |
yarn workspace cron run start:nft-ttr measure --logConfigAndExit
yarn workspace cron run start:nft-ttr measure \
--minImageSizeBytes=10000000 \
--gateways https://nftstorage.link https://dweb.link \
--metricsPushGateway $PUSHGATEWAY_URL \
gobengo marked this conversation as resolved.
Show resolved Hide resolved
--metricsPushGatewayJobName $PUSHGATEWAY_JOBNAME \

- name: Heartbeat
if: ${{ success() }}
run: ./packages/tools/cli.js heartbeat --token ${{ secrets.OPSGENIE_KEY }} --name cron-nft-ttr
47 changes: 47 additions & 0 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,54 @@ on:
paths:
- 'packages/cron/**'
- '.github/workflows/cron.yml'
- 'yarn.lock'
pull_request:
branches:
- main
paths:
- 'packages/cron/**'
- '.github/workflows/cron.yml'
- 'yarn.lock'

jobs:
lint:
name: lint cron
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- uses: bahmutov/npm-install@v1
- run: yarn workspace nft.storage prepare
- run: yarn workspace cron lint

check:
name: Typecheck cron
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- uses: bahmutov/npm-install@v1
- run: yarn workspace nft.storage prepare
- run: yarn workspace cron typecheck

test:
name: Test cron
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- uses: bahmutov/npm-install@v1
- name: Test (ES)
run: yarn --cwd packages/cron test
env:
NFT_STORAGE_API_KEY: ${{ secrets.NFT_STORAGE_API_KEY }}

release:
name: Release
runs-on: ubuntu-latest
Expand Down
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{
"private": true,
"workspaces": [
"packages/*"
],
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"@cloudflare/workers-types",
"@types/jest",
"@types/mocha",
"@types/node",
"@types/webpack-env"
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this nohoist change? Unless it causing an issue, can we move to a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was causing an issue I believe. I will verify it's really required now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wasn't required. :/ ty

},
"scripts": {
"dev:api": "cd packages/api && yarn dev",
"dev:website": "cd packages/website && yarn dev",
Expand Down
147 changes: 144 additions & 3 deletions packages/cron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,170 @@
"nftstorage-pinata": "src/bin/pinata.js"
},
"scripts": {
"lint": "eslint 'src/**/*.js'",
"lint:fix": "npm run lint -- --fix",
"start": "run-s start:*",
"start:nft-ttr": "node src/bin/nft-ttr.js",
"start:pins": "NODE_TLS_REJECT_UNAUTHORIZED=0 node src/bin/pins.js",
"start:pins-failed": "NODE_TLS_REJECT_UNAUTHORIZED=0 node src/bin/pins-failed.js",
"start:pinata": "node src/bin/pinata.js",
"start:dagcargo:sizes": "NODE_TLS_REJECT_UNAUTHORIZED=0 node src/bin/dagcargo-sizes.js",
"start:metrics": "NODE_TLS_REJECT_UNAUTHORIZED=0 node src/bin/metrics.js"
"start:metrics": "NODE_TLS_REJECT_UNAUTHORIZED=0 node src/bin/metrics.js",
"test": "c8 ava",
"typecheck": "npx tsc --build tsconfig.json"
},
"author": "Alan Shaw",
"license": "(Apache-2.0 OR MIT)",
"dependencies": {
"@nftstorage/ipfs-cluster": "^5.0.1",
"@web-std/fetch": "^4.0.0",
"debug": "^4.3.2",
"ava": "^4.3.0",
"dotenv": "^10.0.0",
"form-data": "^4.0.0",
"it-to-buffer": "^2.0.2",
"limiter": "2.0.1",
"nft.storage": "^6.0.0",
"p-retry": "^4.6.1",
"p-settle": "^5.0.0",
"pg": "^8.7.1",
"prom-client": "^14.0.1",
"sade": "^1.8.1",
"sharp": "^0.30.6",
"stream-mime-type": "^1.0.2",
"streaming-iterables": "^6.0.0"
},
"devDependencies": {
"@types/mime-types": "^2.1.1",
"@types/node": "^17.0.35",
"@types/sharp": "^0.30.2",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"c8": "^7.11.3",
"eslint-plugin-prettier": "^4.0.0",
"npm-run-all": "^4.1.5"
}
},
"eslintConfig": {
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"standard",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 13,
"project": [
"./tsconfig.json"
]
},
"env": {
"es2022": true,
"browser": true,
"node": true
},
"rules": {},
"overrides": [
{
"files": [
"./src/bin/pins-failed.js",
"./src/jobs/dagcargo.js"
],
"rules": {
"@typescript-eslint/no-unsafe-assignment": "off"
}
},
{
"files": [
"./src/jobs/dagcargo.js"
],
"rules": {
"camelcase": "off"
}
},
{
"files": [
"./src/jobs/dagcargo.js",
"./src/jobs/metrics.js",
"./src/jobs/pins.js",
"./src/lib/ipfs.js"
],
"rules": {
"@typescript-eslint/no-unsafe-member-access": "off"
}
},
{
"files": [
"./src/lib/ipfs.js"
],
"rules": {
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off"
}
},
{
"files": [
"./src/lib/fetch.js"
],
"rules": {
"@typescript-eslint/no-unsafe-assignment": "off"
}
},
{
"files": [
"./src/jobs/dagcargo.js",
"./src/jobs/pinata.js",
"./src/jobs/pins.js",
"./src/lib/ipfs.js"
],
"rules": {
"@typescript-eslint/restrict-template-expressions": "off"
}
},
{
"files": [
"./src/jobs/dagcargo.js",
"./src/jobs/pins.js",
"./src/lib/fetch.js",
"./src/lib/pinata.js"
],
"rules": {
"@typescript-eslint/no-unsafe-return": "off"
}
},
{
"files": [
"./src/bin/dagcargo-sizes.js",
"./src/bin/metrics.js",
"./src/bin/pinata.js",
"./src/bin/pins-failed.js",
"./src/bin/pins.js"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
},
{
"files": [
"./src/bin/dagcargo-sizes.js",
"./src/bin/metrics.js",
"./src/bin/pinata.js",
"./src/bin/pins-failed.js",
"./src/bin/pins.js",
"./src/jobs/dagcargo.js",
"./src/jobs/pinata.js",
"./src/jobs/pins.js",
"./src/lib/pinata.js"
],
"rules": {
"@typescript-eslint/naming-convention": "off"
}
}
]
},
"eslintIgnore": [
"node_modules"
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can you follow up with a PR to fix the linter issues and remove all this configuration? 🙏🙏🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing. didn't want to lint those old files prematurely until you weighed in on the lint rules at hand

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanshaw this would do it. Not sure if you want to review in here or out. gobengo#1

}
Loading