diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 144d7c6..0030ec4 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -5,48 +5,108 @@ on: pull_request: jobs: - lint-and-test: - name: Check & Test (Frontend + Backend) + frontend-jobs: + name: Set up Node and other necessary dependencies for Frontend Tests and Build runs-on: ubuntu-latest steps: - #Checkout repository - #- name: Checkout repository - # uses: actions/checkout@v4 - - name: Checkout repository manually + - name: Info run: | - git clone ${{ gitea.repository.clone_url }} + echo "Triggered by ${{ gitea.event_name }} event" + echo "Branch: ${{ gitea.ref }}" + echo "Repository: ${{ gitea.repository }}" - #Set up Node.js for React tests - - name: Set up Node.js - uses: actions/setup-node@v4 + - name: Install Node.js, npm, and Yarn (optimized) + run: | + set -e + echo "Preparing Node.js, npm, and Yarn setup..." + + if command -v apt >/dev/null 2>&1; then + echo "→ Using apt (Debian/Ubuntu)..." + export DEBIAN_FRONTEND=noninteractive + apt-get update -qq >/dev/null + apt-get install -y -qq curl ca-certificates >/dev/null + curl -fsSL https://deb.nodesource.com/setup_20.x | bash - >/dev/null 2>&1 + apt-get install -y -qq nodejs >/dev/null + npm install -g yarn --silent + + elif command -v apk >/dev/null 2>&1; then + echo "→ Using apk (Alpine)..." + apk add --no-cache curl nodejs npm >/dev/null + npm install -g yarn --silent + + elif command -v dnf >/dev/null 2>&1; then + echo "→ Using dnf (Fedora/RHEL)..." + dnf install -y -q curl ca-certificates nodejs npm >/dev/null + npm install -g yarn --silent + + else + echo "No supported package manager found (apt, apk, dnf)." + exit 1 + fi + + echo "Node.js, npm, and Yarn installed successfully:" + node -v + npm -v + yarn -v + + - name: Checkout repository manually + env: + TOKEN: ${{ secrets.ACCESS_TOKEN }} + CLONE_URL: ${{ vars.CLONE_URL }} + run: | + echo "Cloning from $CLONE_URL" + echo "Cloning ALL_REPO_TOKEN $ALL_REPO_TOKEN" + CLONE_URL_WITH_AUTH=$(echo "$CLONE_URL" | sed "s#https://#https://$ALL_REPO_TOKEN@#") + git clone --quiet "$CLONE_URL_WITH_AUTH" . + echo "${{ gitea.repository }} cloned successfully." + + #Check frontend linting + - name: Check frontend linting + working-directory: ./frontend + run: yarn lint + + # Install frontend dependencies and run tests + - name: Install frontend dependencies and run tests + #uses: actions/cache@v3 + working-directory: ./frontend with: - node-version: '20' # adjust to your project version or via env - cache: 'yarn' # or 'npm' if you use npm - - #Install frontend dependencies - - name: Install frontend dependencies - working-directory: ./frontend # adjust if your React app folder differs + path: | + ~/.yarn/cache + ./node_modules + key: frontend-${{ runner.os }}-yarn-${{ hashFiles('frontend/yarn.lock') }} + restore-keys: | + frontend-${{ runner.os }}-yarn- run: | yarn install --frozen-lockfile + yarn test --watchAll=false --ci - #Run React unit tests - #- name: Run React unit tests - # working-directory: ./frontend - # run: | - # yarn test --watchAll=false --ci + backend-jobs: + name: Set up Java for Backend Tests and Build + runs-on: ubuntu-latest - #Set up Java for backend tests - - name: Set up Java + steps: + # Setup Java 21 and Maven with caching + - name: Set up Java & Maven uses: actions/setup-java@v4 with: distribution: temurin - java-version: '21' # adjust to match your backend version - cache: maven # or 'gradle' if you use Gradle + java-version: '21' + cache: maven + + - name: Cache Maven dependencies + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + maven-${{ runner.os }}- - #Build & test backend - name: Build & test backend - working-directory: src # adjust if your Spring Boot project path differs + working-directory: ./src run: | + mvn clean install -B mvn clean verify package -B - # or ./gradlew clean test build if using Gradle + + - name: Done + run: echo "Workflow successfully completed." diff --git a/pom.xml b/pom.xml index f6de4ec..1964257 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ - 17 + 21 @@ -48,6 +48,8 @@ org.projectlombok lombok + 1.18.36 + provided