Skip to content

Commit

Permalink
Merge branch 'main' into expo-image
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Nov 21, 2023
2 parents 0f6ad45 + 72e73ae commit eca74d0
Show file tree
Hide file tree
Showing 156 changed files with 97,852 additions and 97,284 deletions.
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
7 changes: 3 additions & 4 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ In order to bundle actions with their dependencies into a single Node.js executa

- When calling your GitHub Action from one of our workflows, you must:
- First call `@actions/checkout`.
- Use the absolute path of the action in GitHub, including the repo name, path, and branch ref, like so:
- Use the relative path of the action in GitHub from the root of this repo, like so:
```yaml
- name: Generate Version
uses: Expensify/App/.github/actions/javascript/bumpVersion@main
uses: ./.github/actions/javascript/bumpVersion
```
Do not try to use a relative path.
- Confusingly, paths in action metadata files (`action.yml`) _must_ use relative paths.

- You can't use any dynamic values or environment variables in a `uses` statement
- In general, it is a best practice to minimize any side-effects of each action. Using atomic ("dumb") actions that have a clear and simple purpose will promote reuse and make it easier to understand the workflows that use them.
8 changes: 4 additions & 4 deletions .github/workflows/cherryPick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
createNewVersion:
needs: validateActor
if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }}
uses: Expensify/App/.github/workflows/createNewVersion.yml@main
uses: ./.github/workflows/createNewVersion.yml
secrets: inherit

cherryPick:
Expand All @@ -42,15 +42,15 @@ jobs:

- name: Set up git for OSBotify
id: setupGitForOSBotify
uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab
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: Get previous app version
id: getPreviousVersion
uses: Expensify/App/.github/actions/javascript/getPreviousVersion@main
uses: ./.github/actions/javascript/getPreviousVersion
with:
SEMVER_LEVEL: "PATCH"

Expand All @@ -67,7 +67,7 @@ jobs:
- name: Get merge commit for pull request to CP
id: getCPMergeCommit
uses: Expensify/App/.github/actions/javascript/getPullRequestDetails@main
uses: ./.github/actions/javascript/getPullRequestDetails
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.actor }}
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 }}
6 changes: 3 additions & 3 deletions .github/workflows/createNewVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }}

- name: Setup git for OSBotify
uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab
uses: ./.github/actions/composite/setupGitForOSBotifyApp
id: setupGitForOSBotify
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
Expand All @@ -85,7 +85,7 @@ jobs:

- name: Generate version
id: bumpVersion
uses: Expensify/App/.github/actions/javascript/bumpVersion@main
uses: ./.github/actions/javascript/bumpVersion
with:
GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }}
SEMVER_LEVEL: ${{ inputs.SEMVER_LEVEL }}
Expand All @@ -105,6 +105,6 @@ jobs:

- name: Announce failed workflow in Slack
if: ${{ failure() }}
uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main
uses: ./.github/actions/composite/announceFailedWorkflowInSlack
with:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
ref: staging
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab
- uses: ./.github/actions/composite/setupGitForOSBotifyApp
id: setupGitForOSBotify
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
Expand All @@ -38,7 +38,7 @@ jobs:
ref: production
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab
- uses: ./.github/actions/composite/setupGitForOSBotifyApp
id: setupGitForOSBotify
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
Expand All @@ -50,15 +50,15 @@ jobs:

- name: Get Release Pull Request List
id: getReleasePRList
uses: Expensify/App/.github/actions/javascript/getDeployPullRequestList@main
uses: ./.github/actions/javascript/getDeployPullRequestList
with:
TAG: ${{ env.PRODUCTION_VERSION }}
GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }}
IS_PRODUCTION_DEPLOY: true

- name: Generate Release Body
id: getReleaseBody
uses: Expensify/App/.github/actions/javascript/getReleaseBody@main
uses: ./.github/actions/javascript/getReleaseBody
with:
PR_LIST: ${{ steps.getReleasePRList.outputs.PR_LIST }}

Expand Down
Loading

0 comments on commit eca74d0

Please sign in to comment.