Skip to content

Commit

Permalink
Merge pull request #23818 from cypress-io/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyrohrbough authored Sep 13, 2022
2 parents f1a0794 + 1190c3e commit af415e0
Show file tree
Hide file tree
Showing 267 changed files with 7,280 additions and 2,518 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/snyk_sca_scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Snyk Software Composition Analysis Scan
# This git workflow leverages Snyk actions to perform a Software Composition
# Analysis scan on our Opensource libraries upon Pull Requests to Master &
# Develop branches. We use this as a control to prevent vulnerable packages
# from being introduced into the codebase.
on:
pull_request_target:
types:
- opened
branches:
- master
- develop
jobs:
Snyk_SCA_Scan:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Setting up Node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Installing snyk-delta and dependencies
run: npm i -g snyk-delta
- uses: snyk/actions/setup@master
- name: Perform SCA Scan
continue-on-error: false
run: |
snyk test --yarn-workspaces --strict-out-of-sync=false --detection-depth=6 --exclude=docker,Dockerfile --severity-threshold=critical
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/snyk_static_analysis_scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Snyk Static Analysis Scan
# This git workflow leverages Snyk actions to perform a Static Application
# Testing scan (SAST) on our first-party code upon Pull Requests to Master &
# Develop branches. We use this as a control to prevent vulnerabilities
# from being introduced into the codebase.
on:
pull_request_target:
types:
- opened
branches:
- master
- develop
jobs:
Snyk_SAST_Scan :
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: snyk/actions/setup@master
- name: Perform Static Analysis Test
continue-on-error: true
run: |
snyk code test --yarn-workspaces --strict-out-of-sync=false --detection-depth=6 --exclude=docker,Dockerfile --severity-threshold=high
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# The Following Requires Advanced Security License
# - name: Upload results to Github Code Scanning
# uses: github/codeql-action/upload-sarif@v1
# with:
# sarif_file: snyk_sarif
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Add issue/PR to project
name: 'Triage: add issue/PR to project'

on:
issues:
types:
- opened
pull_request:
pull_request_target:
types:
- opened

Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/triage_add_to_routed_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Triage: route to team project board'
on:
issues:
types:
- labeled
jobs:
route-to-e2e:
if: github.event.label.name == 'routed-to-e2e'
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
ORGANIZATION: 'cypress-io'
PROJECT_NUMBER: 10
run: |
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectV2(number: $number) {
id
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq -r '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
- name: add issue to e2e project
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
gh api graphql -f query='
mutation($project:ID!, $issue:ID!) {
addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) {
item {
id
}
}
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID
93 changes: 93 additions & 0 deletions .github/workflows/triage_closed_issue_comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: 'Triage: closed issue comment'
on:
issue_comment:
types:
- created
jobs:
move-to-new-issue-status:
if: |
!github.event.issue.pull_request &&
github.event.issue.state == 'closed' &&
github.event.comment.created_at != github.event.issue.closed_at &&
github.event.sender.login != 'cypress-bot'
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
ORGANIZATION: 'cypress-io'
REPOSITORY: 'cypress'
PROJECT_NUMBER: 9
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
gh api graphql -f query='
query($org: String!, $repo: String!, $project: Int!, $issue: Int!) {
organization(login: $org) {
repository(name: $repo) {
issue(number: $issue) {
projectItems(first: 10, includeArchived: false) {
nodes {
id
fieldValueByName(name: "Status") {
... on ProjectV2ItemFieldSingleSelectValue {
name
field {
... on ProjectV2SingleSelectField {
project {
... on ProjectV2 {
id
number
}
}
}
}
}
}
}
}
}
}
projectV2(number: $project) {
field(name: "Status") {
... on ProjectV2SingleSelectField {
id
options {
id
name
}
}
}
}
}
}' -f org=$ORGANIZATION -f repo=$REPOSITORY -F issue=$ISSUE_NUMBER -F project=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq -r '.data.organization.repository.issue.projectItems.nodes[].fieldValueByName.field.project | select(.number == ${{ env.PROJECT_NUMBER }}) | .id' project_data.json) >> $GITHUB_ENV
echo 'PROJECT_ITEM_ID='$(jq -r '.data.organization.repository.issue.projectItems.nodes[] | select(.fieldValueByName.field.project.number == ${{ env.PROJECT_NUMBER }}) | .id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq -r '.data.organization.projectV2.field | .id' project_data.json) >> $GITHUB_ENV
echo 'STATUS='$(jq -r '.data.organization.repository.issue.projectItems.nodes[].fieldValueByName | select(.field.project.number == ${{ env.PROJECT_NUMBER }}) | .name' project_data.json) >> $GITHUB_ENV
echo 'NEW_ISSUE_OPTION_ID='$(jq -r '.data.organization.projectV2.field.options[] | select(.name== "New Issue") | .id' project_data.json) >> $GITHUB_ENV
- name: Move issue to New Issue status
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
if: env.STATUS == 'Closed'
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
) {
updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: {
singleSelectOptionId: $status_value
}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$PROJECT_ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=$NEW_ISSUE_OPTION_ID
114 changes: 114 additions & 0 deletions .github/workflows/triage_issue_metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: 'Triage: issue metrics'

on:
workflow_dispatch:
inputs:
startDate:
description: 'Start date (YYYY-MM-DD)'
type: date
endDate:
description: 'End date (YYYY-MM-DD)'
type: date
jobs:
seven-day-close:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
env:
ORGANIZATION: 'cypress-io'
REPOSITORY: 'cypress'
PROJECT_NUMBER: 9
with:
github-token: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
script: |
const ROUTED_TO_LABELS = ['routed-to-e2e', 'routed-to-ct']
const MS_PER_DAY = 1000 * 60 * 60 * 24
const { REPOSITORY, ORGANIZATION, PROJECT_NUMBER } = process.env
const issues = []
const determineDateRange = () => {
const inputStartDate = '${{ inputs.startDate }}'
const inputEndDate = '${{ inputs.endDate }}'
if (inputStartDate && inputEndDate) {
return { startDate: inputStartDate, endDate: inputEndDate }
}
if (inputStartDate || inputEndDate) {
core.setFailed('Both startDate and endDate are required if one is provided.')
}
const startDate = new Date()
startDate.setDate(startDate.getDate() - 6)
return { startDate: startDate.toISOString().split('T')[0], endDate: (new Date()).toISOString().split('T')[0] }
}
const dateRange = determineDateRange()
const query = `is:issue+repo:${ORGANIZATION}/${REPOSITORY}+project:${ORGANIZATION}/${PROJECT_NUMBER}+created:${dateRange.startDate}..${dateRange.endDate}`
const findLabelDateTime = async (issueNumber) => {
const iterator = github.paginate.iterator(github.rest.issues.listEventsForTimeline, {
owner: ORGANIZATION,
repo: REPOSITORY,
issue_number: issueNumber,
})
for await (const { data: timelineData } of iterator) {
for (const timelineItem of timelineData) {
if (timelineItem.event === 'labeled' && ROUTED_TO_LABELS.includes(timelineItem.label.name)) {
return timelineItem.created_at
}
}
}
}
const calculateElapsedDays = (createdAt, routedOrClosedAt) => {
return Math.round((new Date(routedOrClosedAt) - new Date(createdAt)) / MS_PER_DAY, 0)
}
const iterator = github.paginate.iterator(github.rest.search.issuesAndPullRequests, {
q: query,
per_page: 100,
})
for await (const { data } of iterator) {
for (const issue of data) {
let routedOrClosedAt
if (!issue.pull_request) {
const routedLabel = issue.labels.find((label) => ROUTED_TO_LABELS.includes(label.name))
if (routedLabel) {
routedOrClosedAt = await findLabelDateTime(issue.number)
} else if (issue.state === 'closed') {
routedOrClosedAt = issue.closed_at
}
let elapsedDays
if (routedOrClosedAt) {
elapsedDays = calculateElapsedDays(issue.created_at, routedOrClosedAt)
}
issues.push({
number: issue.number,
title: issue.title,
state: issue.state,
url: issue.html_url,
createdAt: issue.created_at,
routedOrClosedAt,
elapsedDays,
})
}
}
}
const issuesRoutedOrClosedIn7Days = issues.filter((issue) => issue.elapsedDays <= 7).length
const percentage = Number(issues.length > 0 ? issuesRoutedOrClosedIn7Days / issues.length : 0).toLocaleString(undefined, { style: 'percent', minimumFractionDigits: 2 })
console.log(`Triage Metrics (${dateRange.startDate} - ${dateRange.endDate})`)
console.log('Total issues:', issues.length)
console.log(`Issues routed/closed within 7 days: ${issuesRoutedOrClosedIn7Days} (${percentage})`)
3 changes: 2 additions & 1 deletion browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"chrome:beta": "105.0.5195.28",
"chrome:stable": "104.0.5112.101"
"chrome:stable": "104.0.5112.101",
"chrome:minimum": "64.0.3282.0"
}
Loading

0 comments on commit af415e0

Please sign in to comment.