Skip to content

Commit

Permalink
Fix changeset checker (#5100)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored Jul 7, 2021
1 parent 977edee commit d10bd00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit d10bd00

Please sign in to comment.