* Runs the check.
()
| 219 | * Runs the check. |
| 220 | */ |
| 221 | async check() { |
| 222 | const core = await import('@actions/core'); |
| 223 | /* eslint-disable no-console */ |
| 224 | try { |
| 225 | console.log(`\nChecking ${this.packageName} versions in CI environments...`); |
| 226 | |
| 227 | // Validate released versions syntax |
| 228 | try { |
| 229 | this._validateVersionSyntax(this.releasedVersions); |
| 230 | } catch (e) { |
| 231 | core.setFailed(`Failed to check ${this.packageName} versions because released version '${e}' does not follow semver syntax (x.y.z).`); |
| 232 | return; |
| 233 | } |
| 234 | |
| 235 | // Sort versions descending |
| 236 | semver.sort(this.releasedVersions).reverse() |
| 237 | |
| 238 | // Get tested package versions from CI |
| 239 | const tests = await this.getTests(); |
| 240 | |
| 241 | // Is true if any of the checks failed |
| 242 | let failed = false; |
| 243 | |
| 244 | // Check whether each tested version is the latest patch |
| 245 | for (const test of tests) { |
| 246 | const version = test[this.ciVersionKey]; |
| 247 | |
| 248 | // Validate version syntax |
| 249 | try { |
| 250 | this._validateVersionSyntax([version]); |
| 251 | } catch (e) { |
| 252 | core.setFailed(`Failed to check ${this.packageName} versions because environment version '${e}' does not follow semver syntax (x.y.z).`); |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | const newer = this.getNewerVersion(this.releasedVersions, version, this.latestComponent); |
| 257 | if (newer) { |
| 258 | console.log(`❌ CI environment '${test.name}' uses an old ${this.packageName} ${this.latestComponent} version ${version} instead of ${newer}.`); |
| 259 | failed = true; |
| 260 | } else { |
| 261 | console.log(`✅ CI environment '${test.name}' uses the latest ${this.packageName} ${this.latestComponent} version ${version}.`); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | // Check whether there is a newer component version available that is not tested |
| 266 | const testedVersions = tests.map(test => test[this.ciVersionKey]); |
| 267 | const untested = this.getUntestedVersions(this.releasedVersions, testedVersions, this.latestComponent); |
| 268 | if (untested.length > 0) { |
| 269 | console.log(`❌ CI does not have environments using the following versions of ${this.packageName}: ${untested.join(', ')}.`); |
| 270 | failed = true; |
| 271 | } else { |
| 272 | console.log(`✅ CI has environments using all recent versions of ${this.packageName}.`); |
| 273 | } |
| 274 | |
| 275 | if (failed) { |
| 276 | core.setFailed( |
| 277 | `CI environments are not up-to-date with the latest ${this.packageName} versions.` + |
| 278 | `\n\nCheck the error messages above and update the ${this.packageName} versions in the CI YAML ` + |
no test coverage detected