From c80b44f0058110dd18998e3dabffd0809e288c94 Mon Sep 17 00:00:00 2001 From: prayansh_chhablani <135210710+prayanshchh@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:58:16 +0530 Subject: [PATCH] reverting workflow changes (#2498) * reverting workflow changes * changes 1 * identation fix --- .github/workflows/pull-request.yml | 141 +++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 74faf8f4e9..7cb9c10f69 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -42,7 +42,7 @@ jobs: - name: Get changed TypeScript files id: changed-files - uses: tj-actions/changed-files@v40 + uses: tj-actions/changed-files@v45 - name: Check formatting if: steps.changed-files.outputs.only_changed != 'true' run: npm run format:check @@ -58,7 +58,7 @@ jobs: - name: Check for linting errors in modified files if: steps.changed-files.outputs.only_changed != 'true' env: - CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }} + CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: npx eslint ${CHANGED_FILES} && python .github/workflows/eslint_disable_check.py - name: Check for TSDoc comments @@ -92,9 +92,10 @@ jobs: - name: Get Changed Unauthorized files id: changed-unauth-files - uses: tj-actions/changed-files@v40 + uses: tj-actions/changed-files@v45 with: files: | + .env* .github/** env.example .node-version @@ -123,6 +124,12 @@ jobs: ISSUE_GUIDELINES.md PR_GUIDELINES.md README.md + *.pem + *.key + *.cert + *.password + *.secret + *.credentials - name: List all changed unauthorized files if: steps.changed-unauth-files.outputs.any_changed == 'true' || steps.changed-unauth-files.outputs.any_deleted == 'true' @@ -144,7 +151,7 @@ jobs: - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v40 + uses: tj-actions/changed-files@v45 - name: Echo number of changed files env: @@ -197,7 +204,7 @@ jobs: - name: Get changed TypeScript files id: changed-files - uses: tj-actions/changed-files@v40 + uses: tj-actions/changed-files@v45 - name: Run Jest Tests if: steps.changed-files.outputs.only_changed != 'true' @@ -230,14 +237,14 @@ jobs: fi done - - name: Upload Coverage to Codecov + - name: Present and Upload coverage to Codecov as ${{env.CODECOV_UNIQUE_NAME}} uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} verbose: true + fail_ci_if_error: false files: './coverage/lcov.info' name: '${{env.CODECOV_UNIQUE_NAME}}' - fail_ci_if_error: false - name: Test acceptable level of code coverage uses: VeryGoodOpenSource/very_good_coverage@v3 @@ -272,6 +279,126 @@ jobs: - name: Validate Documents run: graphql-inspector validate './src/GraphQl/**/*.ts' './talawa-api/schema.graphql' + Start-App-Without-Docker: + name: Check if Talawa Admin app starts (No Docker) + runs-on: ubuntu-latest + needs: [Code-Quality-Checks, Test-Application] + if: github.actor != 'dependabot' + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Install Dependencies + run: npm install + + - name: Build Production App + run: npm run build + + - name: Start Production App + run: | + npm run preview & + echo $! > .pidfile_prod + - name: Check if Production App is running + run: | + timeout=120 + echo "Starting production health check with ${timeout}s timeout" + while ! nc -z localhost 4173 && [ $timeout -gt 0 ]; do + sleep 1 + timeout=$((timeout-1)) + if [ $((timeout % 10)) -eq 0 ]; then + echo "Still waiting for production app to start... ${timeout}s remaining" + fi + done + if [ $timeout -eq 0 ]; then + echo "Timeout waiting for production application to start" + exit 1 + fi + echo "Production app started successfully" + - name: Stop Production App + run: | + if [ -f .pidfile_prod ]; then + kill "$(cat .pidfile_prod)" + fi + - name: Start Development App + run: | + npm run serve & + echo $! > .pidfile_dev + - name: Check if Development App is running + run: | + timeout=120 + echo "Starting development health check with ${timeout}s timeout" + while ! nc -z localhost 4321 && [ $timeout -gt 0 ]; do + sleep 1 + timeout=$((timeout-1)) + if [ $((timeout % 10)) -eq 0 ]; then + echo "Still waiting for development app to start... ${timeout}s remaining" + fi + done + if [ $timeout -eq 0 ]; then + echo "Timeout waiting for development application to start" + exit 1 + fi + echo "Development app started successfully" + - name: Stop Development App + if: always() + run: | + if [ -f .pidfile_dev ]; then + kill "$(cat .pidfile_dev)" + fi + Docker-Start-Check: + name: Check if Talawa Admin app starts in Docker + runs-on: ubuntu-latest + needs: [Code-Quality-Checks, Test-Application] + if: github.actor != 'dependabot' + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + + - name: Set up Docker + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + image=moby/buildkit:latest + - name: Build Docker image + run: | + set -e + echo "Building Docker image..." + docker build -t talawa-admin-app . + echo "Docker image built successfully" + - name: Run Docker Container + run: | + set -e + echo "Started Docker container..." + docker run -d --name talawa-admin-app-container -p 4321:4321 talawa-admin-app + echo "Docker container started successfully" + - name: Check if Talawa Admin App is running + run: | + timeout="${HEALTH_CHECK_TIMEOUT:-120}" + echo "Starting health check with ${timeout}s timeout" + while ! nc -z localhost 4321 && [ $timeout -gt 0 ]; do + sleep 1 + timeout=$((timeout-1)) + if [ $((timeout % 10)) -eq 0 ]; then + echo "Still waiting for app to start... ${timeout}s remaining" + fi + done + if [ $timeout -eq 0 ]; then + echo "Timeout waiting for application to start" + echo "Container logs:" + docker logs talawa-admin-app-container + exit 1 + fi + echo "Port check passed, verifying health endpoint..." + - name: Stop Docker Container + if: always() + run: | + docker stop talawa-admin-app-container + docker rm talawa-admin-app-container Check-Target-Branch: if: ${{ github.actor != 'dependabot[bot]' }}