Skip to content

Commit

Permalink
ANother attempt to set the proper code into the test envirohnment.
Browse files Browse the repository at this point in the history
  • Loading branch information
robotrapta committed Jan 20, 2025
1 parent 8998ef4 commit bd4d841
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,10 @@ jobs:
run: |
uv run pulumi whoami
- name: Preview pulumi stack
- name: Prepare and preview pulumi stack
run: |
uv run pulumi stack init ${STACK_NAME}
uv run pulumi config set ee-cicd:targetCommit ${{ github.sha }}
uv run pulumi config
uv run pulumi preview
Expand Down
5 changes: 5 additions & 0 deletions cicd/bin/install-on-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ if [ -n "$SPECIFIC_COMMIT" ]; then
# See if the string got substituted. Note can't compare to the whole thing
# because that would be substituted too!
if [ "${SPECIFIC_COMMIT:0:10}" != "__EE_COMMIT" ]; then
echo "Checking out commit ${SPECIFIC_COMMIT}"
git checkout ${SPECIFIC_COMMIT}
else
echo "It appears the commit hash was not substituted. Staying on main."
fi
else
echo "A blank commit hash was provided. Staying on main."
fi

# Set up k3s with GPU support
Expand Down
5 changes: 3 additions & 2 deletions cicd/pulumi/.envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#uv venv
#source .venv/bin/activate
echo "This is a uv project. Remember to 'uv run ...' everything"
uv sync

3 changes: 3 additions & 0 deletions cicd/pulumi/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ runtime:
description: CI/CD for Edge Endpoint
config:
ee-cicd:instanceType: g4dn.xlarge
# Default to "main" so things are sensible if this doesn't get customized.
# But for testing purposes, this should be set to the specific commit you want to test.
ee-cicd:targetCommit: main
14 changes: 8 additions & 6 deletions cicd/pulumi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ def get_instance_profile_by_tag(tag_key: str, tag_value: str) -> str:
return profile["InstanceProfileName"]
raise ValueError(f"No instance profile found with tag {tag_key}: {tag_value}")

def get_current_commit() -> str:
"""Gets the current commit hash."""
return subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("utf-8").strip()
def get_target_commit() -> str:
"""Gets the target commit hash."""
return config.require("targetCommit")

def load_user_data_script() -> str:
"""Loads and customizes the user data script for the instance, which is used to install
everything on the instance."""
with open('../bin/install-on-ubuntu.sh', 'r') as file:
user_data_script = file.read()
current_commit = get_current_commit()
user_data_script = user_data_script.replace("__EE_COMMIT_HASH__", current_commit)
return user_data_script
target_commit = get_target_commit()
# Async substitution of the commit hash into the user data script, because Pulumi.
out0 = user_data_script
out1 = target_commit.apply(lambda commit: out0.replace("__EE_COMMIT_HASH__", commit))
return out1

instance_profile_name = get_instance_profile_by_tag("Name", "edge-device-instance-profile")

Expand Down

0 comments on commit bd4d841

Please sign in to comment.