-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Move ICFY stat generation to Github Actions #39646
Conversation
4284e1d
to
2535df2
Compare
2535df2
to
63a06d8
Compare
.github/workflows/icfy-stats.yml
Outdated
with: | ||
node-version: '>=12.15.0' | ||
- name: Checkout code | ||
uses: actions/checkout@master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this? We need to fetch the refs, not just the commits:
uses: actions/checkout@master | |
uses: actions/checkout@v2 | |
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master |
Maybe we can drop the with/fetch-depth as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems ready to me, ICFY will need some change to handle this. |
.github/workflows/icfy-stats.yml
Outdated
ANCESTOR_SHA1=$(git merge-base HEAD origin/master) | ||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
curl -X POST --globoff \ | ||
"http://api.iscalypsofastyet.com:5000/submit-stats?secret=$ICFY_SECRET" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it hated the ${{}}
syntax huh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, maybe the secret has/had bad URL characters in it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could inline the secret again without the env, the important bit is the --globoff
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the secret contains characters like %
, |
, }
or *
. Definitely not URL and shell friendly 🙂
.github/workflows/icfy-stats.yml
Outdated
-d '{ | ||
"payload": { | ||
"branch": "'"$CURRENT_BRANCH"'", | ||
"build_num": '"$GITHUB_RUN_NUMBER"', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by the build numbering. For the feb1484 commit, the build_num
received by ICFY was 16
:
Received CircleCI success webhook notification: { payload:
{ branch: 'update/move-icfy-stats-to-github-action',
build_num: 16,
sha: 'feb1484add484d02d57e6728bd5ad0adf7529698',
ancestor: '0c9f34fbee2020e8d771dce3c98a1439c30324e6',
from: 'gh-action' } }
But the run numbers in GH web UI are 9 figures starting with 4 and the artifact download URL is:
https://github.com/Automattic/wp-calypso/suites/480255681/artifacts/2208657
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be GITHUB_RUN_ID
?
https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. actions/upload-artifact#50
Yeah, the run_id would let you query for artifacts: https://developer.github.com/v3/actions/artifacts/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now after the latest commit the build number is 17
, the build id is 44892545
and the artifact URL is https://github.com/Automattic/wp-calypso/suites/480418004/artifacts/2211405
. Not quite there yet, but much closer 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curl https://api.github.com/repos/automattic/wp-calypso/actions/runs/44892545/artifacts
returns:
{
"total_count": 1,
"artifacts": [
{
"id": 2211405,
"node_id": "MDg6QXJ0aWZhY3QyMjExNDA1",
"name": "icfy",
"size_in_bytes": 192025220,
"url": "https://api.github.com/repos/Automattic/wp-calypso/actions/artifacts/2211405",
"archive_download_url": "https://api.github.com/repos/Automattic/wp-calypso/actions/artifacts/2211405/zip",
"expired": false,
"created_at": "2020-02-25T13:04:29Z",
"updated_at": "2020-02-25T13:04:30Z"
}
]
}
I guess that with the build ID, getting to the artifact download URL became possible 🎉
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: icfy | ||
path: icfy-stats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we publish the artifacts as two plain files, stats.json
and chart.json
? That would be much more convenient for the ICFY client. It now downloads the files directly into memory. Now, it would need to unpack the ZIP to some tmp directory, read the JSON files from there, cleanup at the end...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses https://github.com/actions/upload-artifact. Docs make it sound like it will always be a zip:
You must upload artifacts during a workflow run. GitHub provides two actions that you can use to upload and download build artifacts. Files uploaded to a workflow run are archived using the
.zip
format. For more information, see the actions/upload-artifact and download-artifact actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem like it. https://github.com/actions/upload-artifact
It wants a path to a directory and a name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it helps, but zips can be used as streams with https://www.npmjs.com/package/node-stream-zip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node-stream-zip
can only read from files 🙁 I need something that can read from a generic stream. Will continue looking for another package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found https://www.npmjs.com/package/unzipper which works great so far 👍
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~14305 bytes removed 📉 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~296 bytes removed 📉 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Moment.js Locales (~3979 bytes removed 📉 [gzipped])
Locale data for moment.js. Unless you are upgrading the moment.js library, changes in these chunks are suspicious. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
4642bb4
to
d1abef8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-Authored-By: Jon Surrell <jon.surrell@automattic.com>
Machines have 2 vCPUs: https://docs.microsoft.com/en-us/azure/virtual-machines/dv2-dsv2-series#dsv2-series `Standard_DS2_v2`
This reverts commit 07bcafa.
d1abef8
to
e5c331b
Compare
Changes proposed in this Pull Request
Requires: