From 109cd4298190db0d68b10dd71f100d9596caa0f9 Mon Sep 17 00:00:00 2001 From: Harshil Date: Tue, 21 Jan 2025 21:28:20 +0530 Subject: [PATCH 1/5] Added auto docs script --- .github/workflows/pull-request.yml | 98 +++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 54bc5eb15..916bafbaf 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -13,7 +13,7 @@ name: PR Workflow on: pull_request: branches-ignore: - - 'master' + - "master" env: CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }} @@ -33,12 +33,12 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-java@v4 with: - distribution: 'zulu' # See 'Supported distributions' for available options - java-version: '17.0' + distribution: "zulu" # See 'Supported distributions' for available options + java-version: "17.0" - uses: subosito/flutter-action@v2 with: - flutter-version: '3.22.3' - channel: 'stable' # or: 'beta', 'dev' or 'master' + flutter-version: "3.22.3" + channel: "stable" # or: 'beta', 'dev' or 'master' - name: Set default branch. run: git remote set-head origin --auto shell: bash @@ -94,6 +94,71 @@ jobs: echo "Error: Close this PR and try again." exit 1 + generate-docs: + if: github.ref == 'refs/heads/develop-postgres' + runs-on: ubuntu-latest + environment: TALAWA_ENVIRONMENT + + steps: + # Step 1: Check out the repository + - name: Checkout Repository + uses: actions/checkout@v4 + + # Step 2: Set up Java + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: "zulu" # Adjust if required + java-version: "17" # Use a modern version suitable for your project + + # Step 3: Set up Flutter + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "stable" + channel: "stable" + + # Step 4: Set up Dart + - name: Set up Dart + uses: dart-lang/setup-dart@v1 + with: + sdk: "stable" + + # Step 5: Generate Dart and Flutter Documentation + - name: Generate Dart and Flutter Docs + run: | + cd talawa_lint && flutter pub get && cd .. + flutter pub get + flutter analyze + dart analyze + flutter pub global activate dartdoc + flutter pub global run dartdoc --output docs/docs/auto-docs/dart + + # Step 6: Generate Java Documentation + - name: Generate Java Docs + run: | + javadoc -d docs/docs/auto-docs/java -sourcepath src -subpackages com.example + + # Step 7: Check for Documentation Updates + - name: Check for Doc Updates + id: DocUpdated + run: | + if [ -n "$(git status --porcelain docs/docs/auto-docs)" ]; then + echo "updateDoc=true" >> $GITHUB_OUTPUT + echo "Documentation has been updated!" + else + echo "No documentation updates found." + fi + + # Step 8: Commit and Push Updates + - name: Commit and Push Docs + if: steps.DocUpdated.outputs.updateDoc + run: | + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + git add docs/docs/auto-docs + git commit -m "Update auto-generated documentation" + git push Branch-check: if: ${{ github.actor != 'dependabot[bot]' && !contains(github.event.pull_request.labels.*.name, 'ignore-sensitive-files-pr') }} @@ -241,22 +306,25 @@ jobs: name: Test Deployment to https://docs-mobile.talawa.io runs-on: ubuntu-latest needs: [iOS-Build, Android-Build] - # Run only if the develop-postgres branch and not dependabot + # Run only if the develop-postgres branch and not dependabot if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.base.ref == 'develop-postgres' }} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - name: Checkout the Repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 with: - node-version: 22 - cache: yarn - cache-dependency-path: 'docs/' + node-version: "20.x" + # Run Docusaurus in the ./docs directory - name: Install dependencies - working-directory: ./docs - run: yarn install --frozen-lockfile + working-directory: ../docs + run: npm install + - name: Test building the website - working-directory: ./docs - run: yarn build + working-directory: ../docs + run: npm run build Validate-Coderabbit: name: Validate CodeRabbit Approval From 7cd1b0a31113fdc828ac5baa517c7da080edd72c Mon Sep 17 00:00:00 2001 From: Harshil Date: Tue, 21 Jan 2025 22:52:33 +0530 Subject: [PATCH 2/5] Added pre-commit script --- .github/workflows/pull-request.yml | 4 ++-- docs/package.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 916bafbaf..eb78de01e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -319,11 +319,11 @@ jobs: # Run Docusaurus in the ./docs directory - name: Install dependencies - working-directory: ../docs + working-directory: ./docs run: npm install - name: Test building the website - working-directory: ../docs + working-directory: ./docs run: npm run build Validate-Coderabbit: diff --git a/docs/package.json b/docs/package.json index 65e9e455b..635ab6d05 100644 --- a/docs/package.json +++ b/docs/package.json @@ -12,7 +12,8 @@ "serve": "docusaurus serve", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", - "typecheck": "tsc" + "typecheck": "tsc", + "generate-docs": "flutter pub global run dartdoc . --output docs/docs/auto-docs" }, "dependencies": { "@docusaurus/core": "3.6.3", From 1792768185db1025e25033f34a9c16f5ce1892b9 Mon Sep 17 00:00:00 2001 From: Harshil Date: Tue, 21 Jan 2025 23:00:49 +0530 Subject: [PATCH 3/5] update pull-request.yml --- .github/workflows/pull-request.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index eb78de01e..45a3de3b9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -95,7 +95,6 @@ jobs: exit 1 generate-docs: - if: github.ref == 'refs/heads/develop-postgres' runs-on: ubuntu-latest environment: TALAWA_ENVIRONMENT From 035d1871d462a5cac50711f1806d5b424ffcf93a Mon Sep 17 00:00:00 2001 From: Harshil Date: Tue, 21 Jan 2025 23:18:16 +0530 Subject: [PATCH 4/5] update pull-request.yml --- .github/workflows/pull-request.yml | 25 +++++--- docs/package.json | 94 +++++++++++++++--------------- 2 files changed, 64 insertions(+), 55 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 45a3de3b9..f5bf7872c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -95,8 +95,16 @@ jobs: exit 1 generate-docs: + if: github.ref == 'refs/heads/develop-postgres' || (github.event_name == 'pull_request' && github.base_ref == 'develop-postgres') runs-on: ubuntu-latest environment: TALAWA_ENVIRONMENT + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ -z "$GITHUB_TOKEN" ]; then + echo "Error: GITHUB_TOKEN is not set" + exit 1 + fi steps: # Step 1: Check out the repository @@ -105,7 +113,7 @@ jobs: # Step 2: Set up Java - name: Set up Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: "zulu" # Adjust if required java-version: "17" # Use a modern version suitable for your project @@ -128,16 +136,17 @@ jobs: run: | cd talawa_lint && flutter pub get && cd .. flutter pub get - flutter analyze - dart analyze - flutter pub global activate dartdoc - flutter pub global run dartdoc --output docs/docs/auto-docs/dart - + flutter analyze --no-fatal-infos + flutter pub global activate dartdoc flutter pub global run dartdoc \ + --output docs/docs/auto-docs/dart \ + --exclude 'dart:async,dart:collection,dart:convert,dart:core,dart:developer,dart:io' \ + --no-generate-docs-for-dependencies \ + --warnings-as-errors # Step 6: Generate Java Documentation - name: Generate Java Docs run: | - javadoc -d docs/docs/auto-docs/java -sourcepath src -subpackages com.example - + find . -name "*.java" > sources.txt + javadoc -d docs/docs/auto-docs/java @sources.txt # Step 7: Check for Documentation Updates - name: Check for Doc Updates id: DocUpdated diff --git a/docs/package.json b/docs/package.json index 635ab6d05..3ef34e3f4 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,49 +1,49 @@ { - "name": "docs", - "version": "0.0.0", - "private": true, - "scripts": { - "docusaurus": "docusaurus", - "start": "docusaurus start", - "build": "docusaurus build", - "swizzle": "docusaurus swizzle", - "deploy": "docusaurus deploy", - "clear": "docusaurus clear", - "serve": "docusaurus serve", - "write-translations": "docusaurus write-translations", - "write-heading-ids": "docusaurus write-heading-ids", - "typecheck": "tsc", - "generate-docs": "flutter pub global run dartdoc . --output docs/docs/auto-docs" - }, - "dependencies": { - "@docusaurus/core": "3.6.3", - "@docusaurus/preset-classic": "3.6.3", - "@mdx-js/react": "^3.0.0", - "clsx": "^2.0.0", - "docusaurus": "^1.14.7", - "prism-react-renderer": "^2.3.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" - }, - "devDependencies": { - "@docusaurus/module-type-aliases": "3.6.3", - "@docusaurus/tsconfig": "3.6.3", - "@docusaurus/types": "3.6.3", - "typescript": "~5.6.2" - }, - "browserslist": { - "production": [ - ">0.5%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 3 chrome version", - "last 3 firefox version", - "last 5 safari version" - ] - }, - "engines": { - "node": ">=18.0" - } + "name": "docs", + "version": "0.0.0", + "private": true, + "scripts": { + "docusaurus": "docusaurus", + "start": "docusaurus start", + "build": "docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "clear": "docusaurus clear", + "serve": "docusaurus serve", + "write-translations": "docusaurus write-translations", + "write-heading-ids": "docusaurus write-heading-ids", + "typecheck": "tsc", + "generate-docs": "cd .. && flutter pub global run dartdoc . --output docs/docs/auto-docs" + }, + "dependencies": { + "@docusaurus/core": "3.6.3", + "@docusaurus/preset-classic": "3.6.3", + "@mdx-js/react": "^3.0.0", + "clsx": "^2.0.0", + "docusaurus": "^1.14.7", + "prism-react-renderer": "^2.3.0", + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "devDependencies": { + "@docusaurus/module-type-aliases": "3.6.3", + "@docusaurus/tsconfig": "3.6.3", + "@docusaurus/types": "3.6.3", + "typescript": "~5.6.2" + }, + "browserslist": { + "production": [ + ">0.5%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 3 chrome version", + "last 3 firefox version", + "last 5 safari version" + ] + }, + "engines": { + "node": ">=18.0" + } } From 97f81c5fc62ae141d40aaf693ebec5afc2863daa Mon Sep 17 00:00:00 2001 From: Harshil Date: Tue, 21 Jan 2025 23:19:37 +0530 Subject: [PATCH 5/5] update pull-request.yml --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f5bf7872c..4ed239f4c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -122,14 +122,14 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: "stable" + flutter-version: "3.22.3" channel: "stable" # Step 4: Set up Dart - name: Set up Dart uses: dart-lang/setup-dart@v1 with: - sdk: "stable" + sdk: "3.4.4" # Step 5: Generate Dart and Flutter Documentation - name: Generate Dart and Flutter Docs