Skip to content

Commit

Permalink
chore: improve developer scripts
Browse files Browse the repository at this point in the history
Signed-off-by: olexii4 <[email protected]>
  • Loading branch information
olexii4 committed Jun 30, 2023
1 parent ffaa1dd commit b74fce1
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Eclipse Che is a next generation Eclipse IDE. This repository is licensed under

## Requirements

- Node.js `v14` and later.
- Node.js `v16` and later.
- yarn `v1.20.0` or higher.

**Note**:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"start": "${PWD}/run/local-run.sh $@",
"start:prepare": "${PWD}/run/prepare-local-run.sh",
"start:cleanup": "${PWD}/run/revert-local-run.sh",
"license:check": "docker run --rm -t -v ${PWD}/:/workspace/project quay.io/che-incubator/dash-licenses@sha256:72290f67f297a31b7b9b343d19f42cc0ecc90e1d36cc9f18473c586a70e4b7eb --check",
"license:generate": "docker run --rm -t -v ${PWD}/:/workspace/project quay.io/che-incubator/dash-licenses:next",
"license:check": "${PWD}/scripts/dash-licenses.sh --check",
"license:generate": "${PWD}/scripts/dash-licenses.sh",
"test": "lerna run test --stream -- --no-cache $@",
"pretest": "yarn run prebuild",
"test:coverage": "yarn run test -- --coverage",
Expand Down
18 changes: 13 additions & 5 deletions run/build-and-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ fi
TAG=$(git branch --show-current)'_'$(date '+%Y_%m_%d_%H_%M_%S')
CHE_DASHBOARD_IMAGE="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/che-dashboard:${TAG}"

echo "Build a new image '${CHE_DASHBOARD_IMAGE}'..."
echo "[INFO] Build a new image '${CHE_DASHBOARD_IMAGE}'..."

podman build . -f build/dockerfiles/Dockerfile -t $CHE_DASHBOARD_IMAGE
if [[ -z "$(ps aux | grep -v grep | grep docker)" ]]; then
echo "[INFO] Using Podman platform."
TARGET_COMMAND='podman'
else
echo "[INFO] Using Docker platform."
TARGET_COMMAND='docker'
fi

$TARGET_COMMAND build . -f build/dockerfiles/Dockerfile -t $CHE_DASHBOARD_IMAGE

echo "Push the image '${CHE_DASHBOARD_IMAGE}'..."
echo "[INFO] Push the image '${CHE_DASHBOARD_IMAGE}'..."

podman push $CHE_DASHBOARD_IMAGE
$TARGET_COMMAND push $CHE_DASHBOARD_IMAGE

echo "Patching checluster with the new dashboard image '${CHE_DASHBOARD_IMAGE}'..."
echo "[INFO] Patching checluster with the new dashboard image '${CHE_DASHBOARD_IMAGE}'..."

CHE_NAMESPACE="${CHE_NAMESPACE:-eclipse-che}"
DASHBOARD_POD_NAME=$(kubectl get pods -n $CHE_NAMESPACE -o=custom-columns=:metadata.name | grep dashboard)
Expand Down
59 changes: 59 additions & 0 deletions scripts/dash-licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

usage() {
cat <<EOF
This scripts helps to run a wrapper for The Eclipse Dash License Tool that allows easily to generate
dependencies files with container image without the need to compile dash-licenses jar.
Arguments:
-c|--check : This option allows to check all dependencies without creating any new files in the project
directory (except a temporary one) but checks if the dependencies info is up-to-date and
then validates all found dependencies.
Examples:
$0
$0 --check
EOF
}


parse_args() {
while [[ "$#" -gt 0 ]]; do
case $1 in
'-c' | '--check')
CHECK="true"
shift 0
;;
'--help')
usage
exit 0
;;
*)
echo "[ERROR] Unknown parameter is used: $1."
usage
exit 1
;;
esac
shift 1
done
}

if [[ -z "$(ps aux | grep -v grep | grep docker)" ]]; then
echo "[INFO] Using Podman platform."
TARGET_COMMAND='podman'
else
echo "[INFO] Using Docker platform."
TARGET_COMMAND='docker'
fi

if [ "$CHECK" == "true" ]; then
echo "[INFO] Check dependencies."
$TARGET_COMMAND run --rm -t -v ${PWD}/:/workspace/project quay.io/che-incubator/dash-licenses@sha256:72290f67f297a31b7b9b343d19f42cc0ecc90e1d36cc9f18473c586a70e4b7eb --check
else
echo "[INFO] Generate dependencies info."
$TARGET_COMMAND run --rm -t -v "${PWD}"/:/workspace/project quay.io/che-incubator/dash-licenses:next
fi

echo '[INFO] Done.'

0 comments on commit b74fce1

Please sign in to comment.