feat: Implement code changes to enhance functionality and improve performance #24
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############################################################################## | |
| ############################################################################## | |
| # | |
| # NOTE! | |
| # | |
| # Please read the README.md file in this directory that defines what should | |
| # be placed in this file | |
| # | |
| ############################################################################## | |
| ############################################################################## | |
| name: PR Workflow | |
| on: | |
| pull_request: | |
| branches: | |
| - '**' | |
| env: | |
| CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }} | |
| jobs: | |
| Code-Quality-Checks: | |
| name: Performs linting, formatting, type-checking, checking for different source and target branch | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: ['24.x'] | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for all branches and tags | |
| - uses: pnpm/action-setup@v4 | |
| name: Install pnpm | |
| with: | |
| run_install: false | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Check formatting | |
| if: steps.changed-files.outputs.only_changed != 'true' | |
| run: pnpm run format:check | |
| - name: Run formatting if check fails | |
| if: failure() | |
| run: pnpm run format:fix | |
| - name: Run TypeScript type checking | |
| run: pnpm run type-check | |
| - name: Run ESLint linting | |
| run: pnpm run lint:check | |
| - name: Check if the source and target branches are different | |
| if: ${{ github.event.pull_request.base.ref == github.event.pull_request.head.ref }} | |
| run: | | |
| echo "Source Branch ${{ github.event.pull_request.head.ref }}" | |
| echo "Target Branch ${{ github.event.pull_request.base.ref }}" | |
| echo "Error: Source and Target Branches are the same. Please ensure they are different." | |
| echo "Error: Close this PR and try again." | |
| exit 1 | |
| Check-Sensitive-Files: | |
| if: ${{ github.actor != 'dependabot[bot]' && !contains(github.event.pull_request.labels.*.name, 'ignore-sensitive-files-pr') }} | |
| name: Checks if sensitive files have been changed without authorization | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get Changed Unauthorized files | |
| id: changed-unauth-files | |
| run: | | |
| SENSITIVE_FILES=( | |
| ".github/" | |
| "CNAME" | |
| "static/CNAME" | |
| "package.json" | |
| "sidebar" | |
| "docusaurus.config.js" | |
| "babel.config.js" | |
| "CODEOWNERS" | |
| "LICENSE" | |
| "./*.md" | |
| "package-lock.json" | |
| "tsconfig.json" | |
| "pnpm.lock" | |
| "static/.nojekyll" | |
| ".gitignore" | |
| ".prettierignore" | |
| ".prettierrc" | |
| ) | |
| CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) | |
| DELETED_FILES=$(git diff --name-only --diff-filter=D ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) | |
| SENSITIVE_CHANGED=false | |
| ALL_CHANGED_FILES="" | |
| for FILE in $CHANGED_FILES $DELETED_FILES; do | |
| for PATTERN in "${SENSITIVE_FILES[@]}"; do | |
| if [[ "$FILE" == "$PATTERN" || "$FILE" == "$PATTERN"* || "$FILE" == *"$PATTERN"* ]]; then | |
| ALL_CHANGED_FILES+="$FILE " | |
| SENSITIVE_CHANGED=true | |
| fi | |
| done | |
| done | |
| echo "all_changed_files=$ALL_CHANGED_FILES" >> $GITHUB_OUTPUT | |
| echo "any_changed=$SENSITIVE_CHANGED" >> $GITHUB_OUTPUT | |
| echo "any_deleted=$([ -n "$DELETED_FILES" ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT | |
| - name: List all changed unauthorized files | |
| if: steps.changed-unauth-files.outputs.any_changed == 'true' || steps.changed-unauth-files.outputs.any_deleted == 'true' | |
| env: | |
| CHANGED_UNAUTH_FILES: ${{ steps.changed-unauth-files.outputs.all_changed_files }} | |
| run: | | |
| for file in ${CHANGED_UNAUTH_FILES}; do | |
| echo "$file is unauthorized to change/delete" | |
| done | |
| echo "To override this, apply the 'ignore-sensitive-files-pr' label" | |
| exit 1 | |
| Test-Docusaurus-Deployment: | |
| name: Test Deployment to https://developer.palisadoes.org | |
| runs-on: ubuntu-latest | |
| needs: [Code-Quality-Checks] | |
| strategy: | |
| matrix: | |
| node-version: ['24.x'] | |
| # Run only if the develop branch and not dependabot | |
| if: ${{ github.event.pull_request.base.ref == 'main' }} | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for all branches and tags | |
| - uses: pnpm/action-setup@v4 | |
| name: Install pnpm | |
| with: | |
| run_install: false | |
| cache: pnpm | |
| cache-dependency-path: | | |
| pnpm-lock.yaml | |
| package.json | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'pnpm' | |
| # Run Docusaurus in the ./docs directory | |
| - name: Install dependencies | |
| working-directory: ./ | |
| run: pnpm install --frozen-lockfile | |
| - name: Test building the website | |
| working-directory: ./ | |
| run: pnpm build | |
| Check-Target-Branch: | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| name: Check Target Branch | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check if the target branch is 'main' | |
| if: github.event.pull_request.base.ref != 'main' | |
| run: | | |
| echo "Error: Pull request target branch must be 'main'. Please refer PR_GUIDELINES.md" | |
| echo "Error: Close this PR and try again." | |
| exit 1 |