Skip to content

build: get previous payload by querying git #5122

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

Merged
merged 4 commits into from
Jun 14, 2017

Conversation

devversion
Copy link
Member

Currently the previous payload is just the latest uploaded payload result on Firebase. This is problematic because it can happen that the current payload is uploaded "too fast" and the payload task is comparing against itself.

Just calculating before uploading could work most of the time, but there it would still fail if another Travis Job uploades payload results at the same time.

The safest solution would be resolving the parent commit of the current Travis job. This way the payload diff would be always correct (even if multiple Jobs are running).

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 13, 2017
@devversion devversion force-pushed the build/payload-previous-sha branch 2 times, most recently from c25888f to 26bfc91 Compare June 13, 2017 23:54
@devversion devversion requested a review from jelbourn June 13, 2017 23:59
@devversion devversion assigned devversion and jelbourn and unassigned devversion Jun 13, 2017
function getCommitFromPreviousPayloadUpload(): string {
if (isTravisMasterBuild()) {
const commitRange = process.env['TRAVIS_COMMIT_RANGE'];
const commitCount = spawnSync('git', ['rev-list', '--count', commitRange]).stdout
Copy link
Member

Choose a reason for hiding this comment

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

Can you add comments that write out the commit commands and describe what you're getting from them?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added comments. It was pretty hard to explain what those Git calls do. Please me know if you think something needs to be better explained.

@devversion devversion force-pushed the build/payload-previous-sha branch from 72925dc to 8a06781 Compare June 14, 2017 20:55
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jun 14, 2017
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

Grammar nits

function getCommitFromPreviousPayloadUpload(): string {
if (isTravisMasterBuild()) {
const commitRange = process.env['TRAVIS_COMMIT_RANGE'];
// In some situations Travis will include multiple commits in a single Travis Job. This means
Copy link
Contributor

Choose a reason for hiding this comment

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

In some situations Travis -> In some situations, Travis

const commitRange = process.env['TRAVIS_COMMIT_RANGE'];
// In some situations Travis will include multiple commits in a single Travis Job. This means
// that we can't just resolve the previous commit by using the parent commit of HEAD.
// By resolving the amount of commits inside of the current Travis Job we can figure out
Copy link
Contributor

Choose a reason for hiding this comment

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

By resolving the amount of commits inside of the current Travis Job we can -> By resolving the amount of commits inside of the current Travis job, we can

// how many commits before HEAD the last Travis Job ran.
const commitCount = spawnSync('git', ['rev-list', '--count', commitRange]).stdout
.toString().trim();
// With the amount of commits inside of the current Travis Job we can query Git to print
Copy link
Contributor

Choose a reason for hiding this comment

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

With the amount of commits inside of the current Travis job we can -> With the amount of commits inside of the current Travis job, we can

return spawnSync('git', ['rev-parse', `HEAD~${commitCount}`]).stdout.toString().trim();
} else {
// Travis applies the changes of Pull Requests in new branches. This means that resolving
// the commit, that previously ran on the target branch (mostly "master"), can be done
Copy link
Contributor

Choose a reason for hiding this comment

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

This means that resolving the commit, that previously -> This means that resolving the commit that previously

@kara kara removed the action: merge The PR is ready for merge by the caretaker label Jun 14, 2017
Currently the previous payload is just the latest uploaded payload result on Firebase. This is problematic because it can happen that the current payload is uploaded "too fast" and the payload task is comparing against itself.

Just calculating before uploading could work most of the time, but there it would still fail if another Travis Job uploades payload results at the same time.

The safest solution would be resolving the parent commit of the current Travis job. This way the payload diff would be always correct (even if multiple Jobs are running).
@devversion devversion force-pushed the build/payload-previous-sha branch from 8a06781 to cc56402 Compare June 14, 2017 21:43
@devversion
Copy link
Member Author

@kara Fixed all grammar comments. Thanks for those!

@devversion devversion added the action: merge The PR is ready for merge by the caretaker label Jun 14, 2017
@kara kara merged commit 7b5b18d into angular:master Jun 14, 2017
@devversion devversion deleted the build/payload-previous-sha branch June 14, 2017 21:51
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants