Merge branch 'develop' into feat/protocol

This commit is contained in:
Ryan Manuel
2023-03-31 16:19:05 +00:00
committed by GitHub
38 changed files with 4080 additions and 4882 deletions

View File

@@ -1,5 +1,5 @@
const createPullRequest = async ({ context, github, baseBranch, branchName, description, body, reviewers }) => {
const { data: { number } } = await github.pulls.create({
const { data: { number } } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
base: baseBranch,
@@ -10,7 +10,7 @@ const createPullRequest = async ({ context, github, baseBranch, branchName, desc
})
if (reviewers) {
await github.pulls.requestReviewers({
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: number,

View File

@@ -31,7 +31,7 @@ async function run ({ context, core, github }) {
pull_number: contextPullRequest.number,
}
const { data: pullRequest } = await github.pulls.get(restParameters)
const { data: pullRequest } = await github.rest.pulls.get(restParameters)
const { type: semanticType, header } = await validatePrTitle({
github,
@@ -41,7 +41,7 @@ async function run ({ context, core, github }) {
const associatedIssues = getLinkedIssues(pullRequest.body)
const { data } = await github.pulls.listFiles(restParameters)
const { data } = await github.rest.pulls.listFiles(restParameters)
const changedFiles = data.map((fileDetails) => fileDetails.filename)

View File

@@ -39,7 +39,7 @@ async function validatePrTitle ({ github, prTitle, restParameters }) {
let nonMergeCommits = []
for await (const response of github.paginate.iterator(
github.pulls.listCommits,
github.rest.pulls.listCommits,
restParameters,
)) {
commits.push(...response.data)

View File

@@ -87,7 +87,7 @@ const updateBrowserVersionsFile = ({ latestBetaVersion, latestStableVersion }) =
}
const updatePRTitle = async ({ context, github, baseBranch, branchName, description }) => {
const { data } = await github.pulls.list({
const { data } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
base: baseBranch,
@@ -100,7 +100,7 @@ const updatePRTitle = async ({ context, github, baseBranch, branchName, descript
return
}
await github.pulls.update({
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: data[0].number,

View File

@@ -8,8 +8,10 @@ describe('pull requests', () => {
context('.createPullRequest', () => {
it('creates pull request with correct properties', async () => {
const github = {
pulls: {
create: sinon.stub().returns(Promise.resolve({ data: { number: 123 } })),
rest: {
pulls: {
create: sinon.stub().returns(Promise.resolve({ data: { number: 123 } })),
},
},
}
@@ -29,7 +31,7 @@ describe('pull requests', () => {
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
})
expect(github.pulls.create).to.be.calledWith({
expect(github.rest.pulls.create).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
base: 'develop',
@@ -42,9 +44,11 @@ describe('pull requests', () => {
it('creates pull request with correct properties including reviewers', async () => {
const github = {
pulls: {
create: sinon.stub().returns(Promise.resolve({ data: { number: 123 } })),
requestReviewers: sinon.stub().returns(Promise.resolve()),
rest: {
pulls: {
create: sinon.stub().returns(Promise.resolve({ data: { number: 123 } })),
requestReviewers: sinon.stub().returns(Promise.resolve()),
},
},
}
@@ -65,7 +69,7 @@ describe('pull requests', () => {
reviewers: ['ryanthemanuel'],
})
expect(github.pulls.create).to.be.calledWith({
expect(github.rest.pulls.create).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
base: 'develop',
@@ -75,7 +79,7 @@ describe('pull requests', () => {
maintainer_can_modify: true,
})
expect(github.pulls.requestReviewers).to.be.calledWith({
expect(github.rest.pulls.requestReviewers).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
pull_number: 123,

View File

@@ -27,7 +27,9 @@ describe('semantic-pull-request/validate-pr-title', () => {
paginate: {
iterator: sinon.stub().returns(myAsyncIterable),
},
pulls: {},
rest: {
pulls: {},
},
}
const prTitle = 'fix: issue with server'
@@ -57,7 +59,9 @@ describe('semantic-pull-request/validate-pr-title', () => {
paginate: {
iterator: sinon.stub().returns(myAsyncIterable),
},
pulls: {},
rest: {
pulls: {},
},
}
const prTitle = 'fix: issue with server'
@@ -85,7 +89,9 @@ describe('semantic-pull-request/validate-pr-title', () => {
paginate: {
iterator: sinon.stub().returns(myAsyncIterable),
},
pulls: {},
rest: {
pulls: {},
},
}
const prTitle = 'fix: issue with server'

View File

@@ -271,15 +271,17 @@ describe('update browser version github action', () => {
context('.updatePRTitle', () => {
it('updates pull request title', async () => {
const github = {
pulls: {
list: sinon.stub().returns(Promise.resolve(
{
data: [
{ number: '123' },
],
},
)),
update: sinon.stub(),
rest: {
pulls: {
list: sinon.stub().returns(Promise.resolve(
{
data: [
{ number: '123' },
],
},
)),
update: sinon.stub(),
},
},
}
@@ -298,14 +300,14 @@ describe('update browser version github action', () => {
description: 'Update Chrome to newer version',
})
expect(github.pulls.list).to.be.calledWith({
expect(github.rest.pulls.list).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
base: 'develop',
head: 'cypress-io:some-branch-name',
})
expect(github.pulls.update).to.be.calledWith({
expect(github.rest.pulls.update).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
pull_number: '123',
@@ -315,13 +317,15 @@ describe('update browser version github action', () => {
it('logs and does not attempt to update pull request title if PR cannot be found', async () => {
const github = {
pulls: {
list: sinon.stub().returns(Promise.resolve(
{
data: [],
},
)),
update: sinon.stub(),
rest: {
pulls: {
list: sinon.stub().returns(Promise.resolve(
{
data: [],
},
)),
update: sinon.stub(),
},
},
}
@@ -342,14 +346,14 @@ describe('update browser version github action', () => {
description: 'Update Chrome to newer version',
})
expect(github.pulls.list).to.be.calledWith({
expect(github.rest.pulls.list).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
base: 'develop',
head: 'cypress-io:some-branch-name',
})
expect(github.pulls.update).not.to.be.called
expect(github.rest.pulls.update).not.to.be.called
expect(console.log).to.be.calledWith('Could not find PR for branch:', 'some-branch-name')
})
})

View File

@@ -73,23 +73,26 @@ const waitForAllJobs = async (jobNames, workflowId) => {
// if a job is pending, its status will be "blocked"
const blockedJobs = _.filter(response.items, { status: 'blocked' })
const failedJobs = _.filter(response.items, { status: 'failed' })
const runningJobs = _.filter(response.items, { status: 'running' })
const successfulJobNames = _.filter(response.items, { status: 'success' }).map((w) => w.name)
const blockedJobNames = _.map(blockedJobs, 'name')
const runningJobNames = _.map(runningJobs, 'name')
const failedJobNames = _.map(failedJobs, 'name')
debug('failed jobs %o', _.map(failedJobs, 'name'))
debug('blocked jobs %o', blockedJobNames)
debug('running jobs %o', runningJobNames)
if (_.intersection(jobNames, failedJobNames).length) {
console.error('At least one failing job has prevented percy-finalize from running', failedJobs)
process.exit(1)
}
debug('failed jobs %o', _.map(failedJobs, 'name'))
debug('blocked jobs %o', blockedJobNames)
debug('running jobs %o', runningJobNames)
const waitOnJobsOnlyJobLeft = !runningJobs.length || (runningJobs.length === 1 && runningJobs[0].name === jobName)
const allWaitForJobsWereSuccessful = _.intersection(jobNames, successfulJobNames).length === jobNames.length
if (!runningJobs.length || (runningJobs.length === 1 && runningJobs[0].name === jobName)) {
if (waitOnJobsOnlyJobLeft && allWaitForJobsWereSuccessful) {
// there are no more jobs to run, or this is the last running job
console.log('all jobs are done, finishing this job')
@@ -100,12 +103,12 @@ const waitForAllJobs = async (jobNames, workflowId) => {
const jobsToWaitFor = _.intersection(jobNames, futureOrRunning)
// logging something every time this runs will avoid CI timing out if there is no activity for 10 mins.
console.log(`waiting for jobs, jobs outstanding: ${jobsToWaitFor.length}`)
console.log(`waiting for ${jobsToWaitFor.length} jobs to finish, jobs outstanding:\n - `, jobsToWaitFor.join('\n - '))
debug('jobs to wait for %o', jobsToWaitFor)
if (!jobsToWaitFor.length) {
console.log('No more jobs to wait for!')
if (!jobsToWaitFor.length && allWaitForJobsWereSuccessful) {
console.log('No more jobs to wait for and all jobs were successful!')
return Promise.resolve()
}