test(s3): only list S3 when AWS creds present in CI; skip otherwise
parent
3de8cac128
commit
1e2fa056a8
|
@ -23,14 +23,11 @@ describe('Cloud Runner pre-built S3 steps', () => {
|
||||||
});
|
});
|
||||||
setups();
|
setups();
|
||||||
(() => {
|
(() => {
|
||||||
// Check if we're in a CI environment or if AWS CLI is available
|
// Determine environment capability to run S3 operations
|
||||||
const isCI = process.env.GITHUB_ACTIONS === 'true';
|
const isCI = process.env.GITHUB_ACTIONS === 'true';
|
||||||
let awsAvailable = false;
|
let awsAvailable = false;
|
||||||
|
|
||||||
if (!isCI) {
|
if (!isCI) {
|
||||||
// Only check AWS CLI locally, skip the test if not available
|
|
||||||
try {
|
try {
|
||||||
// Use synchronous check for AWS CLI availability
|
|
||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
execSync('aws --version', { stdio: 'ignore' });
|
execSync('aws --version', { stdio: 'ignore' });
|
||||||
awsAvailable = true;
|
awsAvailable = true;
|
||||||
|
@ -38,9 +35,11 @@ describe('Cloud Runner pre-built S3 steps', () => {
|
||||||
awsAvailable = false;
|
awsAvailable = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const hasAwsCreds = Boolean(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY);
|
||||||
|
const shouldRunS3 = (isCI && hasAwsCreds) || awsAvailable;
|
||||||
|
|
||||||
// Only run the test if we're in CI or AWS CLI is available
|
// Only run the test if we have AWS creds in CI, or the AWS CLI is available locally
|
||||||
if (isCI || awsAvailable) {
|
if (shouldRunS3) {
|
||||||
it('Run build and prebuilt s3 cache pull, cache push and upload build', async () => {
|
it('Run build and prebuilt s3 cache pull, cache push and upload build', async () => {
|
||||||
const overrides = {
|
const overrides = {
|
||||||
versioning: 'None',
|
versioning: 'None',
|
||||||
|
@ -57,8 +56,8 @@ describe('Cloud Runner pre-built S3 steps', () => {
|
||||||
CloudRunnerLogger.log(`run 2 succeeded`);
|
CloudRunnerLogger.log(`run 2 succeeded`);
|
||||||
expect(results2Object.BuildSucceeded).toBe(true);
|
expect(results2Object.BuildSucceeded).toBe(true);
|
||||||
|
|
||||||
// Only run S3 operations if we're in CI or AWS CLI is available
|
// Only run S3 operations if environment supports it
|
||||||
if (isCI || awsAvailable) {
|
if (shouldRunS3) {
|
||||||
const results = await CloudRunnerSystem.RunAndReadLines(
|
const results = await CloudRunnerSystem.RunAndReadLines(
|
||||||
`aws s3 ls s3://${CloudRunner.buildParameters.awsStackName}/cloud-runner-cache/`,
|
`aws s3 ls s3://${CloudRunner.buildParameters.awsStackName}/cloud-runner-cache/`,
|
||||||
);
|
);
|
||||||
|
@ -66,8 +65,8 @@ describe('Cloud Runner pre-built S3 steps', () => {
|
||||||
}
|
}
|
||||||
}, 1_000_000_000);
|
}, 1_000_000_000);
|
||||||
} else {
|
} else {
|
||||||
it.skip('Run build and prebuilt s3 cache pull, cache push and upload build - AWS CLI not available locally', () => {
|
it.skip('Run build and prebuilt s3 cache pull, cache push and upload build - AWS not configured', () => {
|
||||||
CloudRunnerLogger.log('AWS CLI not available locally, skipping S3 test');
|
CloudRunnerLogger.log('AWS not configured (no creds/CLI); skipping S3 test');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue