test(s3): only list S3 when AWS creds present in CI; skip otherwise

pull/729/head
Frostebite 2025-09-05 02:28:43 +01:00
parent 3de8cac128
commit 1e2fa056a8
1 changed files with 9 additions and 10 deletions

View File

@ -23,14 +23,11 @@ describe('Cloud Runner pre-built S3 steps', () => {
});
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';
let awsAvailable = false;
if (!isCI) {
// Only check AWS CLI locally, skip the test if not available
try {
// Use synchronous check for AWS CLI availability
const { execSync } = require('child_process');
execSync('aws --version', { stdio: 'ignore' });
awsAvailable = true;
@ -38,9 +35,11 @@ describe('Cloud Runner pre-built S3 steps', () => {
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
if (isCI || awsAvailable) {
// Only run the test if we have AWS creds in CI, or the AWS CLI is available locally
if (shouldRunS3) {
it('Run build and prebuilt s3 cache pull, cache push and upload build', async () => {
const overrides = {
versioning: 'None',
@ -57,8 +56,8 @@ describe('Cloud Runner pre-built S3 steps', () => {
CloudRunnerLogger.log(`run 2 succeeded`);
expect(results2Object.BuildSucceeded).toBe(true);
// Only run S3 operations if we're in CI or AWS CLI is available
if (isCI || awsAvailable) {
// Only run S3 operations if environment supports it
if (shouldRunS3) {
const results = await CloudRunnerSystem.RunAndReadLines(
`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);
} else {
it.skip('Run build and prebuilt s3 cache pull, cache push and upload build - AWS CLI not available locally', () => {
CloudRunnerLogger.log('AWS CLI not available locally, skipping S3 test');
it.skip('Run build and prebuilt s3 cache pull, cache push and upload build - AWS not configured', () => {
CloudRunnerLogger.log('AWS not configured (no creds/CLI); skipping S3 test');
});
}
})();