-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Startup Script of Compute Engine (#24562)
- Loading branch information
1 parent
647c69e
commit 3263303
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Startup Script of Compute Engine | ||
|
||
A startup script is a file that contains commands that run when a virtual | ||
machine instance boots. Compute Engine provides support for running startup | ||
scripts on Linux and Windows virtual machines. | ||
|
||
### Create a virtual machine instance using startup script | ||
|
||
The `startup-script.sh` could be used as the startup script of a virtual machine | ||
instance which run Matter coverage report and publish the result via an App | ||
Engine service. | ||
|
||
You can create a virtual machine instance by using the gcloud compute instances | ||
create command with the `--metadata-from-file` flag. | ||
|
||
``` | ||
gcloud compute instances create VM_NAME \ | ||
--image-project=PROJECT_NAME \ | ||
--image-family=ubuntu-22.04 \ | ||
--metadata-from-file=startup-script=FILE_PATH | ||
``` | ||
|
||
Replace the following: | ||
|
||
`PROJECT_NAME`: the name of the project host the virtual machine instance | ||
|
||
`VM_NAME`: the name of the virtual machine instance | ||
|
||
`FILE_PATH`: the relative path to the startup script file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
cd /tmp | ||
rm -rf connectedhomeip | ||
git clone --recurse-submodules https://github.com/project-chip/connectedhomeip.git | ||
cd connectedhomeip | ||
./scripts/build_coverage.sh 2>&1 | tee /tmp/matter_build.log | ||
cd out/coverage/coverage | ||
gcloud app deploy webapp_config.yaml 2>&1 | tee /tmp/matter_publish.log | ||
versions=$(gcloud app versions list \ | ||
--service default \ | ||
--sort-by '~VERSION.ID' \ | ||
--format 'value(VERSION.ID)' | sed 1,5d) | ||
for version in "$versions"; do | ||
gcloud app versions delete "$version" \ | ||
--service default \ | ||
--quiet | ||
done |