@knapsack-pro/core
Version:
Knapsack Pro Core library splits tests across CI nodes and makes sure that tests will run in optimal time on each CI node. This library gives core features like communication with KnapsackPro.com API. This library is a dependency for other projects specif
52 lines (51 loc) • 1.49 kB
JavaScript
import { AppVeyor, Buildkite, CircleCI, CirrusCI, CodefreshCI, Codeship, GithubActions, GitlabCI, HerokuCI, SemaphoreCI, SemaphoreCI2, TravisCI, UnsupportedCI, } from '../ci-providers/index.js';
export const detectCI = () => {
const detected = [
AppVeyor,
Buildkite,
CircleCI,
CirrusCI,
CodefreshCI,
Codeship,
GithubActions,
GitlabCI,
HerokuCI,
SemaphoreCI,
SemaphoreCI2,
TravisCI,
]
.map((provider) => provider.detect)
.filter(Boolean)[0];
return detected || UnsupportedCI;
};
export const isCI = () => (process.env.CI || 'false').toLowerCase() === 'true' ||
detectCI() !== UnsupportedCI;
export class CIEnvConfig {
static get ciNodeTotal() {
return this.ciEnvFor('ciNodeTotal');
}
static get ciNodeIndex() {
return this.ciEnvFor('ciNodeIndex');
}
static get ciNodeBuildId() {
return this.ciEnvFor('ciNodeBuildId');
}
static get ciNodeRetryCount() {
return this.ciEnvFor('ciNodeRetryCount');
}
static get commitHash() {
return this.ciEnvFor('commitHash');
}
static get branch() {
return this.ciEnvFor('branch');
}
static get userSeat() {
return this.ciEnvFor('userSeat');
}
static get fixedQueueSplit() {
return this.ciEnvFor('fixedQueueSplit');
}
static ciEnvFor(functionName) {
return detectCI()[functionName];
}
}