Skip to content

Commit

Permalink
adding pagination to get more buried releases, removes testing for pr…
Browse files Browse the repository at this point in the history
…ereleases
  • Loading branch information
signorecello committed Jan 22, 2024
1 parent b473998 commit 6477d55
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions .github/scripts/latest.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
const { writeFileSync } = require('fs');

const GITHUB_PAGES = 3;

async function main() {
const fetchOpts = {
params: { per_page: 100 },
headers: {},
};

if (process.env.GITHUB_TOKEN)
fetchOpts.headers = { Authorization: `token ${process.env.GITHUB_TOKEN}` };

const res = await fetch('https://api.github.com/repos/noir-lang/noir/releases', fetchOpts);

const data = await res.json();

const filtered = data.filter(
release => !release.tag_name.includes('aztec') && !release.tag_name.includes('nightly'),
);

const latestStable = filtered.find(release => !release.prerelease).tag_name.substring(1);
const latestPreRelease = filtered.find(release => release.prerelease).tag_name.substring(1);
const versions = [];
for (let i = 0; i < GITHUB_PAGES; i++) {
const res = await fetch(
`https://api.github.com/repos/noir-lang/noir/releases?page=${i + 1}`,
fetchOpts,
);

const data = await res.json();

const filtered = data.filter(
release => !release.tag_name.includes('aztec') && !release.tag_name.includes('nightly'),
);
versions.push(...filtered);
}

const latestStable = versions.find(release => !release.prerelease).tag_name.substring(1);

/**
* TODO: test the prerelease!
*
* The problem with the prerelease is that if the test runs for both the stable and the prerelease,
* and the prerelease has a breaking change, then the stable will fail.
*
* If we update the the starter to match the prerelease, then the stable will fail.
*
* This means that if there is a breaking change in a prerelease, we will ALWAYS get a warning 😄, which defeats the purpose.
*
* A solution would be to have a separate "prerelease" branch that is updated with the prerelease. And the CI runs on that branch.
* However, Noir hasn't yet reached a state where, for example, there is ALWAYS a prerelease newer than the stable.
* Sometimes the stable is the last one, and there is a prerelease buried somewhere that never got the honor of being promoted to stable.
*
* So for now, we will just ignore the prerelease.
*/

// const latestPreRelease = versions.find(release => release.prerelease).tag_name.substring(1);

// TODO: add the prerelease to this object!
const workflowOutput = JSON.stringify({
stable: latestStable,
prerelease: latestPreRelease,
// prerelease: latestPreRelease,
});
console.log(workflowOutput); // DON'T REMOVE, GITHUB WILL CAPTURE THIS OUTPUT
}
Expand Down

0 comments on commit 6477d55

Please sign in to comment.