From f47648984e34e202a7f90cee0f995119c841941d Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Thu, 19 Sep 2024 13:19:44 +0300 Subject: [PATCH] fix: PR workflows (#1194) * fix: PR workflows Signed-off-by: Oleksii Orel Co-authored-by: Oleksii Kurinnyi --- .github/workflows/pr.yml | 56 +++++++++++++++++++++++++- scripts/yarn/change_package_manager.sh | 28 ++++++++----- 2 files changed, 73 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c1c52c794..45b5fc744 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -29,10 +29,32 @@ jobs: name: "Checkout Che Dashboard source code" uses: actions/checkout@v4 - - name: "Use Node 18" + name: "Use Node 20" uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 + - + name: "Install dependencies" + run: yarn install + - + name: "Check dependencies usage restrictions" + run: yarn license:check + + dash-licenses-yarn-v1: + runs-on: ubuntu-22.04 + if: ${{ github.base_ref == 'main' }} + steps: + - + name: "Checkout Che Dashboard source code" + uses: actions/checkout@v4 + - + name: "Use Node 20" + uses: actions/setup-node@v4 + with: + node-version: 20 + - + name: "Switch to Yarn 1" + run: scripts/yarn/change_package_manager.sh - name: "Install dependencies" run: yarn @@ -88,6 +110,36 @@ jobs: name: "Run unit tests" run: yarn test + build-and-test-yarn-v1: + runs-on: ubuntu-22.04 + strategy: + matrix: + node-version: [18.x, 20.x] + steps: + - + name: "Checkout Che Dashboard source code" + uses: actions/checkout@v4 + - + name: "Use Node.js ${{ matrix.node-version }}" + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - + name: "Switch to Yarn 1" + run: scripts/yarn/change_package_manager.sh + - + name: "Install dependencies" + run: yarn + - + name: "Build" + run: yarn build + - + name: "Run linters" + run: yarn lint:check + - + name: "Run unit tests" + run: yarn test + docker-build: needs: build-and-test runs-on: ubuntu-22.04 diff --git a/scripts/yarn/change_package_manager.sh b/scripts/yarn/change_package_manager.sh index ccce61883..59e5a48c8 100755 --- a/scripts/yarn/change_package_manager.sh +++ b/scripts/yarn/change_package_manager.sh @@ -10,13 +10,18 @@ # The script is used to change current package manager(yarn 1 vs yarn 3) -export OLD_VERSION_DIR=$(pwd)/scripts/yarn/old_version -export TMP_DIR=$(pwd)/scripts/yarn/tmp +OLD_VERSION_DIR=$(pwd)/scripts/yarn/old_version +TMP_DIR=$(pwd)/scripts/yarn/tmp + +BLUE='\033[0;34m' +GREEN='\033[0;32m' +RED='\033[0;31m' +NC='\033[0m' #==========================Clean temporary directory============================ if [ -d $TMP_DIR ]; then echo "[INFO]: Clean temporary directory" - rm -rf $(pwd)/scripts/yarn/tmp + rm -rf $TMP_DIR else echo "[INFO]: Create temporary directory" fi @@ -49,19 +54,24 @@ fi #==========================Restore old version================================= if [ -d $OLD_VERSION_DIR ]; then echo "[INFO]: Restore old package manager version" - mv -f $OLD_VERSION_DIR/{*,.*} $(pwd)/ > /dev/null 2>&1 + find "$OLD_VERSION_DIR" -mindepth 1 -maxdepth 1 -exec mv -f {} $(pwd)/ \; fi #==========================Cleanup============================================= if [ -d $TMP_DIR ]; then echo "[INFO]: Cleanup" - mv -f $TMP_DIR/{*,.*} $OLD_VERSION_DIR/ > /dev/null 2>&1 + find "$TMP_DIR" -mindepth 1 -maxdepth 1 -exec mv -f {} "$OLD_VERSION_DIR"/ \; fi +#==========================Check current version================================ VER=$(yarn --cwd $(pwd) -v | sed -e s/\\./\\n/g | sed -n 1p) -echo -echo "**********************" -echo "***** Yarn $VER *****" -echo "**********************" +if [ -z "$VER" ]; then + echo "${RED}[ERROR]: Unable to get the current version of yarn. Please check the yarn installation.${NC}" + exit 1 +else + echo "${GREEN}**********************${NC}" + echo "${GREEN}***** Yarn $VER *****${NC}" + echo "${GREEN}**********************${NC}" +fi exit 0