Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMongo: Restore the GraphQL Introspection GitHub Action Test #3485

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 97 additions & 109 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ jobs:
- name: Count number of lines
run: |
chmod +x ./.github/workflows/scripts/countline.py
./.github/workflows/scripts/countline.py --lines 600 --exclude_files src/screens/LoginPage/LoginPage.tsx src/GraphQl/Queries/Queries.ts src/screens/OrgList/OrgList.tsx src/GraphQl/Mutations/mutations.ts src/components/EventListCard/EventListCardModals.tsx src/components/TagActions/TagActionsMocks.ts src/utils/interfaces.ts src/screens/MemberDetail/MemberDetail.tsx src/components/OrgPostCard/OrgPostCard.tsx src/components/UsersTableItem/UsersTableItem.tsx
./.github/workflows/scripts/countline.py --lines 600 --exclude_files src/screens/LoginPage/LoginPage.tsx src/GraphQl/Queries/Queries.ts src/screens/OrgList/OrgList.tsx src/GraphQl/Mutations/mutations.ts src/components/EventListCard/EventListCardModals.tsx src/components/TagActions/TagActionsMocks.ts src/utils/interfaces.ts src/screens/MemberDetail/MemberDetail.tsx

- name: Get changed TypeScript files
id: changed-files
uses: tj-actions/changed-files@v45

- name: Check formatting
if: steps.changed-files.outputs.only_changed != 'true'
run: npm run format:check
Expand All @@ -66,7 +65,9 @@ jobs:
run: npm run check-tsdoc # Run the TSDoc check script

- name: Check for localStorage Usage
run: npx tsx scripts/githooks/check-localstorage-usage.ts --scan-entire-repo
run: |
chmod +x scripts/githooks/check-localstorage-usage.js
node scripts/githooks/check-localstorage-usage.js --scan-entire-repo

- name: Compare translation files
run: |
Expand Down Expand Up @@ -95,9 +96,6 @@ jobs:
uses: tj-actions/changed-files@v45
with:
files: |
.flake8
.pydocstyle
pyproject.toml
.env*
vitest.config.js
src/App.tsx
Expand Down Expand Up @@ -203,7 +201,6 @@ jobs:
run: |
python .github/workflows/scripts/eslint_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}


Check-Code-Coverage-Disable:
name: Check for code coverage disable
runs-on: ubuntu-latest
Expand Down Expand Up @@ -243,63 +240,108 @@ jobs:
- name: Get changed TypeScript files
id: changed-files
uses: tj-actions/changed-files@v45

- name: Run Jest Tests
if: steps.changed-files.outputs.only_changed != 'true'
env:
NODE_V8_COVERAGE: './coverage/jest-coverage'
run: |
npm run test -- --watchAll=false --coverage

- name: Run Vitest Tests
if: steps.changed-files.outputs.any_changed == 'true'
if: steps.changed-files.outputs.only_changed != 'true'
env:
NODE_V8_COVERAGE: './coverage/vitest'
run: |
npm run test:vitest:coverage

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
exclude: 'docs/'
files: ./coverage/vitest/lcov.info
fail_ci_if_error: true

- name: Merge Coverage Reports
if: steps.changed-files.outputs.only_changed != 'true'
run: |
mkdir -p coverage
# Create empty coverage files if directories don't exist
mkdir -p coverage/jest-coverage coverage/vitest
touch coverage/jest-coverage/lcov.info coverage/vitest/lcov.info
if ! npx lcov-result-merger 'coverage/*/lcov.info' > 'coverage/lcov.info'; then
echo "Failed to merge coverage reports"
exit 1
fi

- name: TypeScript compilation for changed files
run: |
for file in ${{ steps.changed-files.outputs.all_files }}; do
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ "$file" == *.ts || "$file" == *.tsx ]]; then
npx tsc --noEmit "$file"
fi
done

- name: Present and Upload coverage to Codecov as ${{env.CODECOV_UNIQUE_NAME}}
if: github.event.pull_request.head.repo.full_name == github.repository && vars.CODECOV_TOKEN != ''
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}}'

- name: Test acceptable level of code coverage
uses: VeryGoodOpenSource/very_good_coverage@v3
with:
path: "./coverage/vitest/lcov.info"
min_coverage: 0

# Graphql-Inspector:
# if: ${{ github.actor != 'dependabot[bot]' }}
# name: Runs Introspection on the GitHub talawa-api repo on the schema.graphql file
# runs-on: ubuntu-latest
# steps:
# - name: Checkout the Repository
# uses: actions/checkout@v4

# - name: Set up Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '22.x'

# - name: resolve dependency
# run: npm install -g @graphql-inspector/cli
path: "./coverage/lcov.info"
min_coverage: 0.0

- name: Install GraphQL Inspector
run: npm install @graphql-inspector/cli

- name: Validate GraphQL schema
run: npx graphql-inspector validate schema.graphql src/**/*.graphql

Graphql-Inspector:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Runs Introspection on the GitHub talawa-api repo on the schema.graphql file
runs-on: ubuntu-latest
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: Clone API Repository
# run: |
# # Retrieve the complete branch name directly from the GitHub context
# FULL_BRANCH_NAME=${{ github.base_ref }}
# echo "FULL_Branch_NAME: $FULL_BRANCH_NAME"
- name: Clone API Repository
run: |
# Retrieve the complete branch name directly from the GitHub context
FULL_BRANCH_NAME=${{ github.base_ref }}
echo "FULL_BRANCH_NAME: $FULL_BRANCH_NAME"

# # Clone the specified repository using the extracted branch name
# git clone --branch $FULL_BRANCH_NAME https://github.com/PalisadoesFoundation/talawa-api && ls -a
# Clone the specified repository using the extracted branch name
if ! git ls-remote --heads https://github.com/PalisadoesFoundation/talawa-api.git $FULL_BRANCH_NAME | grep -q .; then
echo "Error: Branch $FULL_BRANCH_NAME does not exist in talawa-api repository"
exit 1
fi

if ! git clone --branch $FULL_BRANCH_NAME --depth 1 https://github.com/PalisadoesFoundation/talawa-api; then
echo "Error: Failed to clone talawa-api repository"
exit 1
fi

# - name: Validate Documents
# run: graphql-inspector validate './src/GraphQl/**/*.ts' './talawa-api/schema.graphql'
- name: Validate Documents
run: |
if [ ! -f './talawa-api/schema.graphql' ]; then
echo "Error: schema.graphql not found in talawa-api"
exit 1
fi
GRAPHQL_FILES=$(find ./src/GraphQl -name "*.ts" -type f)
if [ -z "$GRAPHQL_FILES" ]; then
echo "Error: No GraphQL TypeScript files found"
exit 1
fi
graphql-inspector validate './src/GraphQl/**/*.ts' './talawa-api/schema.graphql'

Start-App-Without-Docker:
name: Check if Talawa Admin app starts (No Docker)
Expand Down Expand Up @@ -384,30 +426,27 @@ jobs:
run: |
docker stop talawa-admin-app-container
docker rm talawa-admin-app-container


Test-Docusaurus-Deployment:
name: Test Deployment to https://docs-admin.talawa.io
runs-on: ubuntu-latest
needs: [Docker-Start-Check, Start-App-Without-Docker]
# 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:
- name: Checkout the Repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'

node-version: 22
cache: yarn
cache-dependency-path: 'docs/'
# Run Docusaurus in the ./docs directory
- name: Install dependencies
working-directory: ./docs
run: npm install

run: yarn install --frozen-lockfile
- name: Test building the website
working-directory: ./docs
run: npm run build
run: yarn build

Check-Target-Branch:
if: ${{ github.actor != 'dependabot[bot]' }}
Expand All @@ -431,60 +470,9 @@ jobs:
uses: actions/checkout@v4
- name: Validate CodeRabbit.ai Approval
run: |
chmod +x .github/workflows/scripts/validate-coderabbit.sh
.github/workflows/scripts/validate-coderabbit.sh
chmod +x $GITHUB_WORKSPACE/.github/workflows/scripts/validate-coderabbit.sh
$GITHUB_WORKSPACE/.github/workflows/scripts/validate-coderabbit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}


Python-Compliance:
name: Check Python Code Style
runs-on: ubuntu-latest
needs: [Code-Quality-Checks]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r .github/workflows/requirements.txt

- name: Run Black Formatter Check
run: |
source venv/bin/activate
black --check .

- name: Run Flake8 Linter
run: |
source venv/bin/activate
flake8 --docstring-convention google --ignore E402,E722,E203,F401,W503 .github

- name: Run pydocstyle
run: |
source venv/bin/activate
pydocstyle --convention=google --add-ignore=D415,D205 .github

- name: Run docstring compliance check
run: |
source venv/bin/activate
python .github/workflows/scripts/check_docstrings.py --directories .github
Loading
Loading