Skip to content

Commit

Permalink
Merge pull request #19 from microsoft/stage-build-artifact.sh
Browse files Browse the repository at this point in the history
Adding stage_build_artifact capability
  • Loading branch information
bigtallcampbell authored Jun 17, 2024
2 parents bc325ee + cc53f59 commit d70f12d
Show file tree
Hide file tree
Showing 10 changed files with 397 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@
}
},
"remoteUser": "root",
"initializeCommand": "${localWorkspaceFolder}/.vscode/copy_to_spacedev.sh --output_dir ${localWorkspaceFolder}/.devcontainer/features/spacefx-dev/azure-orbital-space-sdk-setup"
"initializeCommand": "${localWorkspaceFolder}/.vscode/copy_to_spacedev.sh --output-dir ${localWorkspaceFolder}/.devcontainer/features/spacefx-dev/azure-orbital-space-sdk-setup"
}
24 changes: 24 additions & 0 deletions .devcontainer/features/spacefx-dev/updateContent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,29 @@ function pull_config_yamls(){
}


############################################################
# Add any extra build artifacts passed from the devcontainer.json to the stage cmd
############################################################
function pull_extra_build_artifacts(){
info_log "START: ${FUNCNAME[0]}"

if [[ ${#DOWNLOAD_ARTIFACTS[@]} -eq 0 ]]; then
info_log "...no build artifacts specified in devcontainer.json. Nothing to do"
info_log "END: ${FUNCNAME[0]}"
return
fi

for artifact in "${DOWNLOAD_ARTIFACTS[@]}"; do
if [[ -z "${artifact}" ]]; then
continue
fi
info_log "...adding build artifact '${artifact}' to stage_spacefx cmd..."
STAGE_SPACE_FX_CMD_EXTRAS="${STAGE_SPACE_FX_CMD_EXTRAS} --build-artifact ${artifact}"
done

info_log "END: ${FUNCNAME[0]}"
}

############################################################
# Add any extra containers passed from the devcontainer.json to the stage cmd
############################################################
Expand Down Expand Up @@ -202,6 +225,7 @@ function main() {
calculate_helm_groups
pull_config_yamls
pull_extra_containers
pull_extra_build_artifacts
info_log "Starting stage_spacefx.sh..."
run_a_script_on_host "${SPACEFX_DIR}/scripts/stage_spacefx.sh ${STAGE_SPACE_FX_CMD_EXTRAS}"
info_log "...stage_spacefx.sh completed successfully"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/devcontainer-feature-build-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: spacefx-dev-build-publish

on:
on:
workflow_dispatch:
push:
branches:
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Build and publish devcontainer feature
shell: bash
run: |
echo "Sourcing environment variables..."
echo "Sourcing environment variables..."
source ./env/spacefx.env
# Validate the output directory exists and clean it out if there is content already present
Expand All @@ -45,7 +45,7 @@ jobs:
# Copy the scripts ino the entry point for the devcontainer feature
echo "Copying all files to /var/spacedev..."
./.vscode/copy_to_spacedev.sh --output_dir ./.devcontainer/features/spacefx-dev/azure-orbital-space-sdk-setup
./.vscode/copy_to_spacedev.sh --output-dir ./.devcontainer/features/spacefx-dev/azure-orbital-space-sdk-setup
# Build the devcontainer feature
echo "Building the devcontainer feature..."
Expand Down
2 changes: 1 addition & 1 deletion .vscode/copy_to_spacedev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OUTPUT_DIR=""
############################################################
while [[ "$#" -gt 0 ]]; do
case $1 in
--output_dir)
--output-dir)
shift
OUTPUT_DIR=$1
;;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ARTIFACT_PATH=./output/spacefx-dev/devcontainer-feature-spacefx-dev.tgz
[[ -d ./output/spacefx-dev ]]; sudo rm ./output/spacefx-dev/* -rf
# Copy the scripts ino the entry point for the devcontainer feature
./.vscode/copy_to_spacedev.sh --output_dir ./.devcontainer/features/spacefx-dev/azure-orbital-space-sdk-setup
./.vscode/copy_to_spacedev.sh --output-dir ./.devcontainer/features/spacefx-dev/azure-orbital-space-sdk-setup
# Build the devcontainer feature
devcontainer features package --force-clean-output-folder ./.devcontainer/features --output-folder ./output/spacefx-dev
Expand Down
1 change: 1 addition & 0 deletions modules/load_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ source "${MODULE_DIR}/m_110_debugshim.sh"
SCRIPT_NAME=$(basename "$0")
LOG_DIR="${SPACEFX_DIR}/logs"
LOG_FILE="${LOG_DIR}/${SCRIPT_NAME}.log"
LOG_FILE_BASENAME=$(basename "${LOG_FILE}")
RETURN_CODE=""
HOST_ARCHITECTURE=""
ARCHITECTURE=""
Expand Down
56 changes: 56 additions & 0 deletions modules/m_5_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,62 @@ function _calculate_for_sudo(){
}


############################################################
# Determine the sha256 hash of a file
############################################################
function calculate_hash_for_file(){

local file=""
local returnResult=""
local ignoreMissing=false
fileHash=""

while [[ "$#" -gt 0 ]]; do
case $1 in
--file)
shift
file=$1
;;
--result)
shift
returnResult=$1
;;
--ignore_missing)
shift
ignoreMissing=true
;;
*)
echo "Unknown parameter '$1'"
exit 1
;;
esac
shift
done

if [[ -z "${file}" ]] || [[ -z "${returnResult}" ]]; then
exit_with_error "Missing a parameter. Please use function like calculate_hash_for_file --file \"/var/tmp/file.txt\" --result \"returnResult\". Please supply all parameters."
fi

if [[ ! -f "${file}" ]] && [[ "${ignoreMissing}" == false ]]; then
exit_with_error "File '${file}' not found. Unable to calculate hash"
fi

if [[ ! -f "${file}" ]] && [[ "${ignoreMissing}" == true ]]; then
warn_log "File '${file}' not found; ignoreMissing set to true. Returning empty hash"
eval "$returnResult=''"
return
fi

trace_log "Calculating hash for file '${file}'..."
run_a_script "sha256sum ${file}" fileHash
fileHash="${fileHash%% *}"
trace_log "...Hash calculated as '${fileHash}'."

eval "$returnResult='${fileHash}'"


}


############################################################
# Helper function to write to a file with run a script and tee
Expand Down
Loading

0 comments on commit d70f12d

Please sign in to comment.