From 99f4666c51f635dc64d5f3a7a528c4562b0ebdc4 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 31 Oct 2025 15:37:18 +0100 Subject: [PATCH] ma jdk ch --- .gitea/workflows/jdk.yaml | 123 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 .gitea/workflows/jdk.yaml diff --git a/.gitea/workflows/jdk.yaml b/.gitea/workflows/jdk.yaml new file mode 100644 index 0000000..3b8a66b --- /dev/null +++ b/.gitea/workflows/jdk.yaml @@ -0,0 +1,123 @@ +name: checks + +on: + push: + pull_request: + +jobs: + frontend-jobs: + name: Set up Node and other necessary dependencies for Frontend Tests and Build + runs-on: ubuntu-latest + + steps: + - name: Info + run: | + echo "Triggered by ${{ gitea.event_name }} event" + echo "Branch: ${{ gitea.ref }}" + echo "Repository: ${{ gitea.repository }}" + + - 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." + + # Install frontend dependencies and run tests + - name: Install frontend dependencies and run tests + #uses: actions/cache@v3 + working-directory: ./frontend + with: + 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 + + #Check frontend linting + - name: Check frontend linting + working-directory: ./frontend + run: yarn lint + + backend-jobs: + name: Set up Java for Backend Tests and Build + runs-on: ubuntu-latest + #container: + #image: eclipse-temurin:21-jdk + + steps: + # Install Maven manually + - name: Download and extract OpenJDK 21 + run: | + download_url="https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz" + wget -O $RUNNER_TEMP/java_package.tar.gz $download_url + + mkdir -p $RUNNER_TEMP/jdk-extracted + tar -xzf $RUNNER_TEMP/java_package.tar.gz -C $RUNNER_TEMP/jdk-extracted + + # Detect the inner directory name (e.g., jdk-21.0.1) + extracted_dir=$(find $RUNNER_TEMP/jdk-extracted -maxdepth 1 -type d -name "jdk*" | head -n 1) + + echo "Detected JDK directory: $extracted_dir" + echo "JAVA_HOME=$extracted_dir" >> $GITHUB_ENV + echo "$extracted_dir/bin" >> $GITHUB_PATH + + - name: Verify Java setup + run: | + ls -l $JAVA_HOME/bin/java + file $JAVA_HOME/bin/java || true + java -version + + # 4️⃣ Build and test with Maven + - name: Build with Maven + run: mvn -B verify + + # Run backend tests and build + - name: Test & build backend + working-directory: ./src + run: mvn clean verify -B + + - name: Done + run: echo "Workflow successfully completed." \ No newline at end of file