Skip to content

Commit

Permalink
vx: correctly list all packages from log
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 23, 2022
1 parent db1a4fc commit 00ac61e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ jobs:
run: echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > ~/.npmrc
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Release
run: yarn release
env:
Expand All @@ -52,4 +48,3 @@ jobs:
PUBLIC_REPO_TOKEN: ${{secrets.PUBLIC_REPO_TOKEN}}
EMAIL_ADDRESS: ${{secrets.EMAIL_ADDRESS}}
GIT_NAME: ${{secrets.GIT_NAME}}
CURRENT_BRANCH: ${{ steps.extract_branch.outputs.branch }}
3 changes: 2 additions & 1 deletion vx/scripts/release/genDiffData.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ const {
isReleaseBranch,
isNextBranch,
} = require('vx/util/taggedBranch');
const { CURRENT_BRANCH } = require('vx/util/taggedBranch');
const { usePackage } = require('vx/vxContext');

const packageJson = require('../../util/packageJson');

const determineChangeLevel = require('./determineChangeLevel');
const { TAG_NEXT, TAG_DEV } = require('./releaseKeywords');

const { CURRENT_BRANCH, GITHUB_SHA } = process.env;
const { GITHUB_SHA } = process.env;

// commits: [{title: "...", files: ["..."]}]
function genDiffData(commits) {
Expand Down
22 changes: 11 additions & 11 deletions vx/scripts/release/github/listAllChangedPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ const listAllChangesSinceStableBranch = require('./listAllChangesSinceStableBran

function listAllChangedPackages() {
const changes = listAllChangesSinceStableBranch();
return Object.keys(
changes.reduce((packages, { files = [] }) => {
return files.reduce((packages, file) => {
const packageName = vxPath.packageNameFromPath(file);
if (!packageNames.names[packageName]) {
return packages;
}
packages[packageName] = packages[packageName] || true;

return changes.reduce((packages, { files = [] }) => {
return files.reduce((packages, file) => {
const packageName = vxPath.packageNameFromPath(file);
if (!packageNames.names[packageName]) {
return packages;
}, packages);
}, {})
);
}

packages.add(packageName);

return packages;
}, packages);
}, new Set());
}

module.exports = listAllChangedPackages;
5 changes: 3 additions & 2 deletions vx/scripts/release/github/listAllChangesSinceStableBranch.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const exec = require('child_process').execSync;

const { STABLE_BRANCH, CURRENT_BRANCH } = require('vx/util/taggedBranch');

const IGNORE_PATTERN = require('./commitIgnorePattern');

const { STABLE_BRANCH } = process.env;
/**
* Lists all the commits and their changed files:
* Returns an array of objects that look like this:
Expand All @@ -13,7 +14,7 @@ function listAllChangesSinceStableBranch() {
exec(`git fetch origin ${STABLE_BRANCH}`);

const output = exec(
`git log origin/${STABLE_BRANCH}..HEAD --name-only --pretty='format:%h %s (%an)'`
`git log origin/${STABLE_BRANCH}..origin/${CURRENT_BRANCH} --name-only --pretty='format:%h %s (%an)'`
);

return output
Expand Down
25 changes: 16 additions & 9 deletions vx/scripts/release/packagesToRelease.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ const {
const listAllChangedPackages = require('vx/scripts/release/github/listAllChangedPackages');

// Gets all the packages that need to be released in the correct order
// eslint-disable-next-line complexity
function packagesToRelease() {
const deps = buildDepsTree();

const changedPackages = listAllChangedPackages();
const changedPackagesSet = listAllChangedPackages();

const changedPackagesArray = Array.from(changedPackagesSet);
logger.info(
`💡 The following packages were changed: \n - ${changedPackages.join(
`💡 The following packages were changed: \n - ${changedPackagesArray.join(
'\n - '
)}\n`
);

const queue = [...changedPackages];
const queue = changedPackagesArray;
const release = new Set();

const unchangedDependents = new Set();
Expand All @@ -33,17 +35,22 @@ function packagesToRelease() {

for (const dep in dependents) {
queue.push(dep);
unchangedDependents.add(dep);

if (!changedPackagesSet.has(dep)) {
unchangedDependents.add(dep);
}
}

release.add(name);
}

logger.info(
`🧱 The following packages did not change, but will be released because they depend on changed packages: \n - ${[
...unchangedDependents,
].join('\n - ')} \n`
);
if (unchangedDependents.size) {
logger.info(
`🧱 The following packages did not change, but will be released because they depend on changed packages: \n - ${[
...unchangedDependents,
].join('\n - ')} \n`
);
}

const allPackagesToRelease = sortDependencies([...release]);

Expand Down
2 changes: 1 addition & 1 deletion vx/util/taggedBranch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {
CURRENT_BRANCH = '',
CURRENT_BRANCH = process.env.GITHUB_REF_NAME,
INTEGRATION_BRANCH,
NEXT_BRANCH,
LATEST_BRANCH,
Expand Down

1 comment on commit 00ac61e

@vercel
Copy link

@vercel vercel bot commented on 00ac61e Nov 23, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

vest-next – ./website

vest-website.vercel.app
vest-next-git-latest-ealush.vercel.app
vest-next.vercel.app
vest-next-ealush.vercel.app

Please sign in to comment.