Skip to content

Commit

Permalink
fix: PR workflows (#1194)
Browse files Browse the repository at this point in the history
* fix: PR workflows

Signed-off-by: Oleksii Orel <[email protected]>
Co-authored-by: Oleksii Kurinnyi <[email protected]>
  • Loading branch information
olexii4 and akurinnoy authored Sep 19, 2024
1 parent 3b8fefa commit f476489
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 11 deletions.
56 changes: 54 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 19 additions & 9 deletions scripts/yarn/change_package_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit f476489

Please sign in to comment.