Skip to content

Commit

Permalink
Add Startup Script of Compute Engine (#24562)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca authored and pull[bot] committed Sep 6, 2023
1 parent 647c69e commit 3263303
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
29 changes: 29 additions & 0 deletions integrations/compute_engine/README.md
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
34 changes: 34 additions & 0 deletions integrations/compute_engine/startup-script.sh
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

0 comments on commit 3263303

Please sign in to comment.