-
Notifications
You must be signed in to change notification settings - Fork 0
[POC] CI automation scripts #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: wasbDepCodeReview
Are you sure you want to change the base?
Changes from all commits
bd91890
556ca8c
c3f5935
1d61fb6
131e66a
2752ca1
37ba557
2aae4ef
4678058
bfe34e1
548b4f8
c92c764
1f76c2e
6bc44ad
af28a74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,44 @@ fnsBlobConfigFileCheck() { | |
| fi | ||
| } | ||
|
|
||
| checkCronjobDependencies() { | ||
| if ! [ "$(command -v az)" ]; then | ||
| echo "Azure CLI (az) could not be found. Installing Azure CLI..." | ||
| if ! sudo apt update || ! sudo apt install -y azure-cli; then | ||
| echo "Failed to install Azure CLI. Exiting..." | ||
| exit 1 | ||
| fi | ||
| echo "Azure CLI installed successfully." | ||
| fi | ||
| } | ||
|
|
||
| uploadToAzure() { | ||
| azureConfigFilePath="${accountSettingsDir}runresult${accountConfigFileSuffix}" | ||
| testResultsAccountName=$(xmlstarlet sel -t -v '//property[name = "fs.azure.test.results.account.name"]/value' -n $azureConfigFilePath) | ||
| testResultsAccountKey=$(xmlstarlet sel -t -v '//property[name = "fs.azure.test.results.account.key"]/value' -n $azureConfigFilePath) | ||
| branchName="${branchName,,}" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the two commas needed here ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are used to convert into lowercase letters in Bash |
||
| containerName="$(xmlstarlet sel -t -v '//property[name = "fs.azure.container.name"]/value' -n $azureConfigFilePath)" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this can also be |
||
| printAggregate | ||
|
|
||
| year=$(date +"%Y") | ||
| month=$(date +"%m") | ||
| day=$(date +"%d") | ||
|
|
||
| directoryStructure="$year-$month-$day/$branchName" | ||
| AggregatedTestFolder="$testOutputLogFolder" | ||
|
|
||
| checkCronjobDependencies | ||
| if ! az storage container create --name $containerName --account-name $testResultsAccountName --account-key "$testResultsAccountKey"; then | ||
| echo "Failed to create container. Exiting..." | ||
| exit 1 | ||
| fi | ||
| if ! az storage blob upload-batch --destination "$containerName/$directoryStructure" --source $AggregatedTestFolder --account-name $testResultsAccountName --account-key "$testResultsAccountKey"; then | ||
| echo "Failed upload test results in the destination. Exiting..." | ||
| exit 1 | ||
| fi | ||
| echo "Upload complete." | ||
| } | ||
|
|
||
| triggerRun() | ||
| { | ||
| echo ' ' | ||
|
|
@@ -214,14 +252,17 @@ init() { | |
| aggregatedTestResult="$testOutputLogFolder/Test-Results.txt" | ||
| } | ||
|
|
||
| printAggregate() { | ||
| echo :::: AGGREGATED TEST RESULT :::: | ||
| cat "$aggregatedTestResult" | ||
| printAggregate() { | ||
| branchName=$(git rev-parse --abbrev-ref HEAD) | ||
| commitHash=$(git rev-parse HEAD) | ||
|
|
||
| echo "Branch: $branchName, Commit: $commitHash" >> "$aggregatedTestResult" | ||
|
|
||
| fullRunEndTime=$(date +%s) | ||
| fullRunTimeInSecs=$((fullRunEndTime - fullRunStartTime)) | ||
| mins=$((fullRunTimeInSecs / 60)) | ||
| secs=$((fullRunTimeInSecs % 60)) | ||
| printf "\nTime taken: %s mins %s secs.\n" "$mins" "$secs" | ||
| printf "\nTime taken: %s mins %s secs.\n" "$mins" "$secs" >> "$aggregatedTestResult" | ||
| } | ||
|
|
||
| logOutput() { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if cron job is running and these test result account details are not added?