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

[No QA] Fix too-big checklists #31458

Merged
merged 25 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9a27672
Create callable workflow to create the checklist
roryabraham Nov 15, 2023
91e516d
Add pretty name to each step
roryabraham Nov 15, 2023
92ca8cf
Rename checklist.yml to createDeployChecklist.yml
roryabraham Nov 15, 2023
5c48509
Use callable workflow in platformDeploy.yml
roryabraham Nov 15, 2023
60c172f
Use callable workflow in deployBlocker.yml
roryabraham Nov 15, 2023
4cc5599
Update outdated utils function in preGenerateTest
roryabraham Nov 16, 2023
4afd9be
Include workflow_tests/repo in .gitignore
roryabraham Nov 16, 2023
6557465
Merge branch 'main' into Rory-CallableChecklistJob
roryabraham Nov 16, 2023
e214ad0
Merge branch 'main' into Rory-CallableChecklistJob
roryabraham Nov 16, 2023
9eaaf17
Merge branch 'main' into Rory-CallableChecklistJob
roryabraham Nov 16, 2023
ea53025
Use version from package.json instead of input
roryabraham Nov 16, 2023
fa629c3
Sort PRs for better readability in workflow logs
roryabraham Nov 16, 2023
ff2514c
Log repack command
roryabraham Nov 16, 2023
16d56b1
Add success log
roryabraham Nov 17, 2023
86b8231
Fix sorting
roryabraham Nov 17, 2023
9e27cd1
Create create_basic_pr utility function
roryabraham Nov 17, 2023
e5ec3b4
DRY up script further with deploy_staging and deploy_production
roryabraham Nov 17, 2023
5b33318
Add another test case
roryabraham Nov 17, 2023
cf71429
Simplify didVersionChange
roryabraham Nov 17, 2023
490dd4f
Merge branch 'main' into Rory-CallableChecklistJob
roryabraham Nov 17, 2023
647d0ae
Use the same base tag for shallow-exclude
roryabraham Nov 17, 2023
80c05e2
Make OSBotify create the checklist
roryabraham Nov 17, 2023
402d64f
Fix tests
roryabraham Nov 18, 2023
0c91a09
fix lint
roryabraham Nov 18, 2023
0a95bab
Resolve merge conflicts
mountiny Nov 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ inputs:
GITHUB_TOKEN:
description: Auth token for New Expensify Github
required: true
NPM_VERSION:
description: The new NPM version of the StagingDeployCash issue.
required: false

runs:
using: 'node20'
main: './index.js'
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs');
const format = require('date-fns/format');
const _ = require('underscore');
const core = require('@actions/core');
Expand All @@ -6,8 +7,8 @@ const GithubUtils = require('../../../libs/GithubUtils');
const GitUtils = require('../../../libs/GitUtils');

async function run() {
const newVersion = core.getInput('NPM_VERSION');
console.log('New version found from action input:', newVersion);
// Note: require('package.json').version does not work because ncc will resolve that to a plain string at compile time
const newVersionTag = JSON.parse(fs.readFileSync('package.json')).version;

try {
// Start by fetching the list of recent StagingDeployCash issues, along with the list of open deploy blockers
Expand Down Expand Up @@ -35,14 +36,12 @@ async function run() {
const currentChecklistData = shouldCreateNewDeployChecklist ? {} : GithubUtils.getStagingDeployCashData(mostRecentChecklist);

// Find the list of PRs merged between the current checklist and the previous checklist
// Note that any time we're creating a new checklist we MUST have `NPM_VERSION` passed in as an input
const newTag = newVersion || _.get(currentChecklistData, 'tag');
const mergedPRs = await GitUtils.getPullRequestsMergedBetween(previousChecklistData.tag, newTag);
const mergedPRs = await GitUtils.getPullRequestsMergedBetween(previousChecklistData.tag, newVersionTag);

// Next, we generate the checklist body
let checklistBody = '';
if (shouldCreateNewDeployChecklist) {
checklistBody = await GithubUtils.generateStagingDeployCashBody(newTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber));
checklistBody = await GithubUtils.generateStagingDeployCashBody(newVersionTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber));
} else {
// Generate the updated PR list, preserving the previous state of `isVerified` for existing PRs
const PRList = _.reduce(
Expand Down Expand Up @@ -94,9 +93,9 @@ async function run() {
});
}

const didVersionChange = newVersion ? newVersion !== currentChecklistData.tag : false;
const didVersionChange = newVersionTag !== currentChecklistData.tag;
checklistBody = await GithubUtils.generateStagingDeployCashBody(
newTag,
newVersionTag,
_.pluck(PRList, 'url'),
_.pluck(_.where(PRList, {isVerified: true}), 'url'),
_.pluck(deployBlockers, 'url'),
Expand Down
33 changes: 16 additions & 17 deletions .github/actions/javascript/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/***/ 3926:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const fs = __nccwpck_require__(7147);
const format = __nccwpck_require__(2168);
const _ = __nccwpck_require__(5067);
const core = __nccwpck_require__(2186);
Expand All @@ -15,8 +16,8 @@ const GithubUtils = __nccwpck_require__(7999);
const GitUtils = __nccwpck_require__(669);

async function run() {
const newVersion = core.getInput('NPM_VERSION');
console.log('New version found from action input:', newVersion);
// Note: require('package.json').version does not work because ncc will resolve that to a plain string at compile time
const newVersionTag = JSON.parse(fs.readFileSync('package.json')).version;

try {
// Start by fetching the list of recent StagingDeployCash issues, along with the list of open deploy blockers
Expand Down Expand Up @@ -44,14 +45,12 @@ async function run() {
const currentChecklistData = shouldCreateNewDeployChecklist ? {} : GithubUtils.getStagingDeployCashData(mostRecentChecklist);

// Find the list of PRs merged between the current checklist and the previous checklist
// Note that any time we're creating a new checklist we MUST have `NPM_VERSION` passed in as an input
const newTag = newVersion || _.get(currentChecklistData, 'tag');
const mergedPRs = await GitUtils.getPullRequestsMergedBetween(previousChecklistData.tag, newTag);
const mergedPRs = await GitUtils.getPullRequestsMergedBetween(previousChecklistData.tag, newVersionTag);

// Next, we generate the checklist body
let checklistBody = '';
if (shouldCreateNewDeployChecklist) {
checklistBody = await GithubUtils.generateStagingDeployCashBody(newTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber));
checklistBody = await GithubUtils.generateStagingDeployCashBody(newVersionTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber));
} else {
// Generate the updated PR list, preserving the previous state of `isVerified` for existing PRs
const PRList = _.reduce(
Expand Down Expand Up @@ -103,9 +102,9 @@ async function run() {
});
}

const didVersionChange = newVersion ? newVersion !== currentChecklistData.tag : false;
const didVersionChange = newVersionTag !== currentChecklistData.tag;
checklistBody = await GithubUtils.generateStagingDeployCashBody(
newTag,
newVersionTag,
_.pluck(PRList, 'url'),
_.pluck(_.where(PRList, {isVerified: true}), 'url'),
_.pluck(deployBlockers, 'url'),
Expand Down Expand Up @@ -191,9 +190,9 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007);

/**
* @param {String} tag
* @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster)
*/
function fetchTag(tag) {
const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH);
function fetchTag(tag, shallowExcludeTag = '') {
let shouldRetry = true;
let needsRepack = false;
while (shouldRetry) {
Expand All @@ -209,11 +208,9 @@ function fetchTag(tag) {

command = `git fetch origin tag ${tag} --no-tags`;

// Exclude commits reachable from the previous patch version (i.e: previous checklist),
// so that we don't have to fetch the full history
// Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case
if (previousPatchVersion !== tag) {
command += ` --shallow-exclude=${previousPatchVersion}`;
// Note that this condition is only ever NOT true in the 1.0.0-0 edge case
if (shallowExcludeTag && shallowExcludeTag !== tag) {
command += ` --shallow-exclude=${shallowExcludeTag}`;
}

console.log(`Running command: ${command}`);
Expand All @@ -240,8 +237,10 @@ function fetchTag(tag) {
* @returns {Promise<Array<Object<{commit: String, subject: String, authorName: String}>>>}
*/
function getCommitHistoryAsJSON(fromTag, toTag) {
fetchTag(fromTag);
fetchTag(toTag);
// Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH);
fetchTag(fromTag, previousPatchVersion);
fetchTag(toTag, previousPatchVersion);

console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
return new Promise((resolve, reject) => {
Expand Down
18 changes: 9 additions & 9 deletions .github/actions/javascript/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007);

/**
* @param {String} tag
* @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster)
*/
function fetchTag(tag) {
const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH);
function fetchTag(tag, shallowExcludeTag = '') {
let shouldRetry = true;
let needsRepack = false;
while (shouldRetry) {
Expand All @@ -151,11 +151,9 @@ function fetchTag(tag) {

command = `git fetch origin tag ${tag} --no-tags`;

// Exclude commits reachable from the previous patch version (i.e: previous checklist),
// so that we don't have to fetch the full history
// Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case
if (previousPatchVersion !== tag) {
command += ` --shallow-exclude=${previousPatchVersion}`;
// Note that this condition is only ever NOT true in the 1.0.0-0 edge case
if (shallowExcludeTag && shallowExcludeTag !== tag) {
command += ` --shallow-exclude=${shallowExcludeTag}`;
}

console.log(`Running command: ${command}`);
Expand All @@ -182,8 +180,10 @@ function fetchTag(tag) {
* @returns {Promise<Array<Object<{commit: String, subject: String, authorName: String}>>>}
*/
function getCommitHistoryAsJSON(fromTag, toTag) {
fetchTag(fromTag);
fetchTag(toTag);
// Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH);
fetchTag(fromTag, previousPatchVersion);
fetchTag(toTag, previousPatchVersion);

console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
return new Promise((resolve, reject) => {
Expand Down
18 changes: 9 additions & 9 deletions .github/libs/GitUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = require('../libs/versionUp

/**
* @param {String} tag
* @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster)
*/
function fetchTag(tag) {
const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH);
function fetchTag(tag, shallowExcludeTag = '') {
let shouldRetry = true;
let needsRepack = false;
while (shouldRetry) {
Expand All @@ -24,11 +24,9 @@ function fetchTag(tag) {

command = `git fetch origin tag ${tag} --no-tags`;

// Exclude commits reachable from the previous patch version (i.e: previous checklist),
// so that we don't have to fetch the full history
// Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case
if (previousPatchVersion !== tag) {
command += ` --shallow-exclude=${previousPatchVersion}`;
// Note that this condition is only ever NOT true in the 1.0.0-0 edge case
if (shallowExcludeTag && shallowExcludeTag !== tag) {
command += ` --shallow-exclude=${shallowExcludeTag}`;
}

console.log(`Running command: ${command}`);
Expand All @@ -55,8 +53,10 @@ function fetchTag(tag) {
* @returns {Promise<Array<Object<{commit: String, subject: String, authorName: String}>>>}
*/
function getCommitHistoryAsJSON(fromTag, toTag) {
fetchTag(fromTag);
fetchTag(toTag);
// Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH);
fetchTag(fromTag, previousPatchVersion);
fetchTag(toTag, previousPatchVersion);

console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
return new Promise((resolve, reject) => {
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/createDeployChecklist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Create or update deploy checklist

on:
workflow_call:
workflow_dispatch:

jobs:
createChecklist:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: ./.github/actions/composite/setupNode

- name: Set up git for OSBotify
id: setupGitForOSBotify
uses: ./.github/actions/composite/setupGitForOSBotifyApp
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
OS_BOTIFY_APP_ID: ${{ secrets.OS_BOTIFY_APP_ID }}
OS_BOTIFY_PRIVATE_KEY: ${{ secrets.OS_BOTIFY_PRIVATE_KEY }}

- name: Create or update deploy checklist
uses: ./.github/actions/javascript/createOrUpdateStagingDeploy
with:
GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }}
24 changes: 9 additions & 15 deletions .github/workflows/deployBlocker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,19 @@ on:
- labeled

jobs:
updateChecklist:
if: github.event.label.name == 'DeployBlockerCash'
uses: ./.github/workflows/createDeployChecklist.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be cleaner to call this create or update too

Suggested change
uses: ./.github/workflows/createDeployChecklist.yml
uses: ./.github/workflows/createOrUpdateDeployChecklist.yml


deployBlocker:
if: github.event.label.name == 'DeployBlockerCash'
runs-on: ubuntu-latest
if: ${{ github.event.label.name == 'DeployBlockerCash' }}

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: ./.github/actions/composite/setupGitForOSBotifyApp
id: setupGitForOSBotify
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
OS_BOTIFY_APP_ID: ${{ secrets.OS_BOTIFY_APP_ID }}
OS_BOTIFY_PRIVATE_KEY: ${{ secrets.OS_BOTIFY_PRIVATE_KEY }}

- name: Update StagingDeployCash with new deploy blocker
uses: ./.github/actions/javascript/createOrUpdateStagingDeploy
with:
GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }}

- run: gh issue edit ${{ github.event.issue.number }} --add-label 'Engineering,Hourly' --remove-label 'Daily,Weekly,Monthly'
- name: Give the issue/PR the Hourly, Engineering labels
run: gh issue edit ${{ github.event.issue.number }} --add-label 'Engineering,Hourly' --remove-label 'Daily,Weekly,Monthly'
env:
GITHUB_TOKEN: ${{ github.token }}

Expand All @@ -51,9 +43,11 @@ jobs:
run: |
gh issue comment ${{ github.event.issue.number }} --body "$(cat <<'EOF'
:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! [Check out the open \`StagingDeployCash\` deploy checklist](https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3AStagingDeployCash) to see the list of PRs included in this release, then work quickly to do one of the following:

1. Identify the pull request that introduced this issue and revert it.
2. Find someone who can quickly fix the issue.
3. Fix the issue yourself.

EOF
)"
env:
Expand Down
17 changes: 1 addition & 16 deletions .github/workflows/platformDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,9 @@ jobs:
# Note: we're updating the checklist before running the deploys and assuming that it will succeed on at least one platform
deployChecklist:
name: Create or update deploy checklist
runs-on: ubuntu-latest
uses: ./.github/workflows/createDeployChecklist.yml
if: ${{ github.event_name != 'release' }}
needs: validateActor
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: Expensify/App/.github/actions/composite/setupNode@main

- name: Set version
id: getVersion
run: echo "VERSION=$(npm run print-version --silent)" >> "$GITHUB_OUTPUT"

- name: Create or update staging deploy
uses: Expensify/App/.github/actions/javascript/createOrUpdateStagingDeploy@main
with:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
NPM_VERSION: ${{ steps.getVersion.outputs.VERSION }}

android:
name: Build and deploy Android
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ tsconfig.tsbuildinfo

# Workflow test logs
/workflow_tests/logs/
/workflow_tests/repo/

# Yalc
.yalc
Expand Down
Loading