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

Fix changeset checker #5100

Merged
merged 5 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .github/workflows/check-changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Check Changeset

on: pull_request

env:
GITHUB_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
GITHUB_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}

jobs:
check_changeset:
name: Check changeset vs changed files
Expand Down
12 changes: 7 additions & 5 deletions scripts/check_changeset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import fs from 'mz/fs';
const root = resolve(__dirname, '..');
const git = simpleGit(root);

const baseRef = process.env.GITHUB_PULL_REQUEST_BASE_SHA || 'master';
const headRef = process.env.GITHUB_PULL_REQUEST_HEAD_SHA || 'HEAD';

// Version bump text converted to rankable numbers.
const bumpRank: Record<string, number> = {
'patch': 0,
Expand Down Expand Up @@ -65,7 +68,7 @@ async function getDiffData(): Promise<{
changedPackages: Set<string>;
changesetFile: string;
} | null> {
const diff = await git.diff(['--name-only', 'origin/master...HEAD']);
const diff = await git.diff(['--name-only', `${baseRef}...${headRef}`]);
const changedFiles = diff.split('\n');
let changesetFile = '';
const changedPackages = new Set<string>();
Expand Down Expand Up @@ -120,7 +123,7 @@ async function parseChangesetFile(changesetFile: string) {
async function main() {
const errors = [];
try {
await exec('yarn changeset status');
await exec(`yarn changeset status --since ${baseRef}`);
console.log(`::set-output name=BLOCKING_FAILURE::false`);
} catch (e) {
if (e.message.match('No changesets present')) {
Expand Down Expand Up @@ -173,9 +176,8 @@ async function main() {

// Check for packages with a minor or major bump where 'firebase' hasn't been
// bumped high enough or at all.
const { highestBump, bumpText, bumpPackage } = getHighestBump(
changesetPackages
);
const { highestBump, bumpText, bumpPackage } =
getHighestBump(changesetPackages);
if (highestBump > bumpRank.patch) {
if (changesetPackages['firebase'] == null) {
errors.push(
Expand Down