Skip to content

Commit

Permalink
ci: Fix CI version check (parse-community#9039)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Mar 22, 2024
1 parent 854ac9a commit 1c0eced
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 898 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci-automated-check-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: CI Environments Check
Expand Down
35 changes: 15 additions & 20 deletions ci/ciCheck.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

const CiVersionCheck = require('./CiVersionCheck');
const mongoVersionList = require('mongodb-version-list');
const allNodeVersions = require('all-node-versions');
const { exec } = require('child_process');

async function check() {
// Run checks
Expand All @@ -14,12 +13,13 @@ async function check() {
* Check the MongoDB versions used in test environments.
*/
async function checkMongoDbVersions() {
const releasedVersions = await new Promise((resolve, reject) => {
mongoVersionList(function (error, versions) {
const latestStableVersion = await new Promise((resolve, reject) => {
exec('m --latest', (error, stdout) => {
if (error) {
reject(error);
return;
}
resolve(versions);
resolve(stdout.trim());
});
});

Expand All @@ -29,37 +29,32 @@ async function checkMongoDbVersions() {
yamlFilePath: './.github/workflows/ci.yml',
ciEnvironmentsKeyPath: 'jobs.check-mongo.strategy.matrix.include',
ciVersionKey: 'MONGODB_VERSION',
releasedVersions,
latestComponent: CiVersionCheck.versionComponents.minor,
ignoreReleasedVersions: [
'<4.0.0', // Versions reached their MongoDB end-of-life support date
'~4.1.0', // Development release according to MongoDB support
'~4.3.0', // Development release according to MongoDB support
'~4.7.0', // Development release according to MongoDB support
],
releasedVersions: [latestStableVersion],
latestComponent: CiVersionCheck.versionComponents.major,
ignoreReleasedVersions: [],
}).check();
}

/**
* Check the Nodejs versions used in test environments.
*/
async function checkNodeVersions() {
const allVersions = await allNodeVersions();
const releasedVersions = allVersions.versions;
const allVersions = (await import('all-node-versions')).default;
const { versions } = await allVersions();
const nodeVersions = versions.map(version => version.node);

await new CiVersionCheck({
packageName: 'Node.js',
packageSupportUrl: 'https://github.com/nodejs/node/blob/master/CHANGELOG.md',
yamlFilePath: './.github/workflows/ci.yml',
ciEnvironmentsKeyPath: 'jobs.check-mongo.strategy.matrix.include',
ciVersionKey: 'NODE_VERSION',
releasedVersions,
releasedVersions: nodeVersions,
latestComponent: CiVersionCheck.versionComponents.minor,
ignoreReleasedVersions: [
'<12.0.0', // These versions have reached their end-of-life support date
'>=13.0.0 <14.0.0', // These versions have reached their end-of-life support date
'>=15.0.0 <16.0.0', // These versions have reached their end-of-life support date
'>=19.0.0', // These versions are not officially supported yet
'<18.0.0', // These versions have reached their end-of-life support date
'>=19.0.0 <20.0.0', // These versions have reached their end-of-life support date
'>=21.0.0', // These versions are not officially supported yet
],
}).check();
}
Expand Down
Loading

0 comments on commit 1c0eced

Please sign in to comment.