Skip to content
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

Missing submit button #15

Merged
123 changes: 123 additions & 0 deletions scripts/build-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env bash

#
# Copyright (c) 2020 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.
#

ME=$(basename "$0")
ROOT_DIR=$(realpath $(dirname "$0")/..)
cd $ROOT_DIR

DEFAULT_IMAGE=csa-certification-tool-frontend


GHCR_ORG="ghcr.io"
ORG=${DOCKER_BUILD_ORG:-project-chip}

# Latest commit hash
GIT_SHA=$(git rev-parse --short HEAD)

# If working copy has changes, append `-local` to hash
GIT_DIFF=$(git diff -s --exit-code || echo "-local")
if [[ $GIT_DIFF ]]; then
echo " 🔴 Git repo has changes. Please commit all changes before publishing."
fi
GIT_REV=$GIT_SHA$GIT_DIFF
echo "$GIT_REV"


IMAGE=${DOCKER_BUILD_IMAGE:-$DEFAULT_IMAGE}

# version
VERSION=${DOCKER_BUILD_VERSION:-$GIT_REV}

# verify that repo is clean
DIRTY=`git status --porcelain --untracked-files=no`


# help
[[ ${*/--help//} != "${*}" ]] && {
set +x
echo "Usage: $me <OPTIONS>

Build and (optionally tag as latest, push) a docker image from Dockerfile in CWD

Options:
--no-cache passed as a docker build argument
--latest update latest to the current built version (\"$VERSION\")
--push push image(s) to $GHCR_ORG (requires docker login for \"$ORG\")
--skip-build skip the build/prune step
--help get this message
--squash squash docker layers before push them to $GHCR_ORG (requires docker-squash python module)
--clear remove images after after publishing them

"
exit 0
}

die() {
echo "$me: *** ERROR: $*"
exit 1
}

set -ex

[[ -n $VERSION ]] || die "version cannot be empty"

BUILD_ARGS=()
if [[ ${*/--no-cache//} != "${*}" ]]; then
BUILD_ARGS+=(--no-cache)
fi

# Don't run `docker build` and `docker image prune` when `--skip-build` in arguments
[[ ${*/--skip-build//} != "${*}" ]] || {
docker build "${BUILD_ARGS[@]}" --build-arg TARGETPLATFORM="$TARGET_PLATFORM_TYPE" --build-arg GIT_SHA="$GIT_REV" --build-arg VERSION="$VERSION" -t "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" .
docker image prune --force
}

[[ ${*/--squash//} != "${*}" ]] && {
command -v docker-squash >/dev/null &&
docker-squash "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" -t "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed
}

[[ ${*/--latest//} != "${*}" ]] && {
if [[ ${*/--squash//} != "${*}" ]]; then
docker tag "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed "$GHCR_ORG"/"$ORG"/"$IMAGE":latest
else
docker tag "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" "$GHCR_ORG"/"$ORG"/"$IMAGE":latest
fi
}

[[ ${*/--push//} != "${*}" ]] && {
if [[ $GIT_DIFF ]]; then
die "Don't push image with local changes"
fi
docker push "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION"
[[ ${*/--latest//} != "${*}" ]] && {
docker push "$GHCR_ORG"/"$ORG"/"$IMAGE":latest
}
}

[[ ${*/--clear//} != "${*}" ]] && {
docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION"
[[ ${*/--latest//} != "${*}" ]] && {
docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":latest
}
[[ ${*/--squash//} != "${*}" ]] && {
docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed
}
}

docker images --filter=reference="$GHCR_ORG/$ORG/*"
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class TestExecutionSandbox {
];
popupObject.inputItems = inputItems;
popupObject.buttons = buttons;
} else if (promptData.payload.path) { // Displaying the file upload popup
} else if (promptType === 'file_upload_request') { // Displaying the file upload popup
popupObject.popupId = 'FILE_UPLOAD_' + promptData.payload.message_id;
const inputItems = [
{ id: 1,
Expand All @@ -82,6 +82,7 @@ export class TestExecutionSandbox {
}
];
popupObject.inputItems = inputItems;
popupObject.buttons = buttons;
}
this.sharedAPI.setCustomPopupData(popupObject);
this.sharedAPI.setShowCustomPopup(popupObject.popupId);
Expand Down Expand Up @@ -133,4 +134,4 @@ export class TestExecutionSandbox {
}
return testData;
}
}
}
1 change: 1 addition & 0 deletions src/app/shared/core_apis/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class WebSocketAPI {
} else if (dataObject.type === 'prompt_request' ||
dataObject.type === 'options_request' ||
dataObject.type === 'message_request' ||
dataObject.type === 'file_upload_request' ||
dataObject.type === 'custom_upload') {
this.testExecutionSandbox.showExecutionPrompt(dataObject);
} else if (dataObject.type === 'time_out_notification') {
Expand Down