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

Opt out of GitHub fetch in push artifact workflow #13801

Merged
merged 2 commits into from
Nov 30, 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
2 changes: 1 addition & 1 deletion .github/workflows/add-push-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
node-version: 14.x
- run: npm install
- run: node ./scripts/enumerate-features.js features.json
- run: node ./scripts/diff-features.js --format=json > features.diff.json
- run: node ./scripts/diff-features.js --no-github --format=json > features.diff.json
- uses: actions/upload-artifact@v2
with:
name: enumerate-features
Expand Down
25 changes: 16 additions & 9 deletions scripts/diff-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require('fs');

const yargs = require('yargs');

function main({ ref1, ref2, format }) {
function main({ ref1, ref2, format, github }) {
let refA, refB;

if (ref1 === undefined && ref2 === undefined) {
Expand All @@ -20,8 +20,8 @@ function main({ ref1, ref2, format }) {
refB = `${ref1}`;
}

let aSide = enumerate(refA);
let bSide = enumerate(refB);
let aSide = enumerate(refA, github === false);
let bSide = enumerate(refB, github === false);

const results = {
added: [...bSide].filter(feature => !aSide.has(feature)),
Expand All @@ -35,13 +35,16 @@ function main({ ref1, ref2, format }) {
}
}

function enumerate(ref) {
try {
return new Set(getEnumerationFromGithub(ref));
} catch {
console.error('Fetching artifact from GitHub failed. Using fallback.');
return new Set(enumerateFeatures(ref));
function enumerate(ref, skipGitHub) {
if (!skipGitHub) {
try {
return new Set(getEnumerationFromGithub(ref));
} catch {
console.error('Fetching artifact from GitHub failed. Using fallback.');
}
}

return new Set(enumerateFeatures(ref));
}

function getEnumerationFromGithub(ref) {
Expand Down Expand Up @@ -144,6 +147,10 @@ const { argv } = yargs.command(
demand: 'a named format is required',
default: 'markdown',
})
.option('no-github', {
type: 'boolean',
description: "Don't fetch artifacts from GitHub.",
})
.example('$0', 'compare HEAD to parent commmit')
.example('$0 176d4ed', 'compare 176d4ed to its parent commmit')
.example('$0 topic-branch main', 'compare a branch to main');
Expand Down