Skip to content

Added queries and mutations for action items #6946

Added queries and mutations for action items

Added queries and mutations for action items #6946

Workflow file for this run

##############################################################################
##############################################################################
#
# NOTE!
#
# Please read the README.md file in this directory that defines what should
# be placed in this file.
#
##############################################################################
##############################################################################
name: Pull request workflow
on:
pull_request:
branches:
- "**"
jobs:
check_base_branch:
# only run the job if the pull request actor is not dependabot
if: ${{ github.actor != 'dependabot[bot]' }}
name: Check base branch of the pull request to be develop-postgres
runs-on: ubuntu-latest
steps:
- if: github.event.pull_request.base.ref != 'develop-postgres'
name: Check base branch
run: |
echo "Pull requests are only allowed against the 'develop-postgres' branch. Please refer to the pull request guidelines."
echo "Error: Close this PR and try again."
exit 1
Code-Quality-Checks:
name: Checking code quality
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Build talawa api non production environment docker image
run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./
- name: Check type errors
run: docker container run talawa_api pnpm check_code_quality
- 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
python_checks:
name: Run Python Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
run: |
echo "all_changed_files=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Run Biome Ignore Check
run: |
python .github/workflows/scripts/biome_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
- name: Run Code Coverage Disable Check
run: |
python .github/workflows/scripts/code_coverage_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
- name: Run TS Ignore Check
run: |
python .github/workflows/scripts/detect_ts_ignore.py --files ${{ steps.changed-files.outputs.all_changed_files }}
check_gql_tada:
name: Check gql tada files and configuration
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Build talawa api non production environment docker image
run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./
- name: Check gql tada
run: docker container run talawa_api pnpm check_gql_tada
check_drizzle_migrations:
name: Check drizzle migration files
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Build talawa api non production environment docker image
run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./
- name: Check drizzle migrations
run: docker container run --env-file ./envFiles/.env.ci talawa_api pnpm check_drizzle_migrations
check_type_errors:
name: Check type errors
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Build talawa api non production environment docker image
run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./
- name: Check type errors
run: docker container run talawa_api pnpm check_type_errors
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
needs: [Code-Quality-Checks]
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
with:
fetch-depth: 0
- id: changed_files
name: Get changed files
run: |
SENSITIVE_FILES=(
.coderabbit.yaml
Caddyfile
codegen.ts
"Dockerfile*"
"docker-compose*"
"drizzle_migrations/**"
.dockerignore
.env.sample
.env_test
eslint.config.mjs
"envFiles/**"
.gitignore
init-mongo.sh
.prettierignore
.prettierrc.json
.pylintrc
".github/**"
biome.jsonc
renovate.json
requirements.txt
schema.graphql
CODEOWNERS
LICENSE
tsconfig.json
vitest.config.ts
pnpm-lock.yaml
package.json
package-lock.json
.nojekyll
docs/docusaurus.config.ts
"docs/sidebar*"
setup.ts
"src/graphql/types/Mutation/**"
"src/graphql/types/Query/**"
tsconfig.build.json
vite.config.mts
CNAME
CODE_OF_CONDUCT.md
CODE_STYLE.md
CONTRIBUTING.md
DOCUMENTATION.md
INSTALLATION.md
ISSUE_GUIDELINES.md
PR_GUIDELINES.md
README.md
)
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 PATTERN in "${SENSITIVE_FILES[@]}"; do
for FILE in $CHANGED_FILES $DELETED_FILES; do
if [[ "$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
- env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
if: steps.changed_files.outputs.any_changed == 'true' || steps.changed_files.outputs.any_deleted == 'true'
name: Show changed files
run: |
echo "Unauthorized changes were made in the following files:"
for FILE in ${CHANGED_FILES}; do
echo "$FILE"
done
echo "To override this, apply the 'ignore-sensitive-files-pr' label"
exit 1
Run-Tests:
name: Run tests for talawa api
runs-on: ubuntu-latest
needs:
[
Code-Quality-Checks,
python_checks,
check_type_errors,
check_drizzle_migrations,
check_gql_tada,
]
env:
CODECOV_UNIQUE_NAME: ${{github.workflow}}-${{github.ref_name}}
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Create .env file for talawa api testing environment
run: cp ./envFiles/.env.ci ./.env
- name: Build talawa api compose testing environment
run: docker compose build
- name: Run tests
run: docker compose up --exit-code-from api
- name: Copy coverage from container
run: |
CONTAINER_ID=$(docker ps -aq --filter "ancestor=talawa-api")
docker cp $CONTAINER_ID:/home/talawa/api/coverage ./coverage
- name: Present and upload coverage to Codecov as ${{env.CODECOV_UNIQUE_NAME}}
uses: codecov/codecov-action@v4
with:
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
name: "${{env.CODECOV_UNIQUE_NAME}}"
- name: Test acceptable level of code coverage
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: "./coverage/lcov.info"
min_coverage: 57.0
Test-Docusaurus-Deployment:
name: Test Deployment to https://docs-api.talawa.io
runs-on: ubuntu-latest
needs: [Run-Tests]
# 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: pnpm/action-setup@v4
with:
cache: pnpm
cache-dependency-path: |
docs/pnpm-lock.yaml
docs/package.json
# Run Docusaurus in the ./docs directory
- name: Install dependencies
working-directory: ./docs
run: pnpm install --frozen-lockfile
- name: Test building the website
working-directory: ./docs
run: pnpm build
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
Count-Changed-Files:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Checks if number of files changed is acceptable
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Get changed files
id: changed-files
run: |
# Get the base branch ref
BASE_SHA=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
# Count all changed files
ALL_CHANGED_FILES_COUNT=$(git diff --name-only --diff-filter=ACMRT $BASE_SHA ${{ github.event.pull_request.head.sha }} | wc -l | tr -d ' ')
echo "all_changed_files_count=$ALL_CHANGED_FILES_COUNT" >> $GITHUB_OUTPUT
- name: Echo number of changed files
env:
CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
run: |
echo "Number of files changed: $CHANGED_FILES_COUNT"
- name: Check if the number of changed files is less than 100
if: steps.changed-files.outputs.all_changed_files_count > 100
env:
CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
run: |
echo "Error: Too many files (greater than 100) changed in the pull request."
echo "Possible issues:"
echo "- Contributor may be merging into an incorrect branch."
echo "- Source branch may be incorrect please use develop as source branch."
exit 1
Check-App-Startup:
name: Check App Startup and Health
runs-on: ubuntu-latest
needs: [Run-Tests]
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Install Devcontainer CLI
run: npm install -g @devcontainers/cli
- name: Copy devcontainer environment file
run: cp envFiles/.env.devcontainer .env
- name: Bring up devcontainer
run: devcontainer up --workspace-folder .
- name: Wait for Devcontainer to be ready
run: |
echo "Waiting for devcontainer services to be ready..."
sleep 10
- name: Verify Running Containers
run: docker ps
- name: Install dependencies inside the container
run: docker exec talawa-api-1 /bin/bash -c 'pnpm install'
- name: Start server and monitor logs
run: |
docker exec talawa-api-1 /bin/bash -c 'pnpm run start_development_server' &
sleep 10
- name: Wait for GraphQL endpoint to become available
if: always()
run: |
echo "Waiting for the GraphQL endpoint to become available..."
for i in {1..60}; do
# Check if container exists first
if ! docker ps | grep -q talawa-api-1; then
echo "Container talawa-api-1 not found. Waiting..."
sleep 2
continue
fi
docker exec talawa-api-1 which curl >/dev/null 2>&1 || {
docker exec talawa-api-1 apt-get update && docker exec talawa-api-1 apt-get install -y curl
}
RESPONSE=$(docker exec talawa-api-1 curl -s -X POST http://127.0.0.1:4000/graphql -H "Content-Type: application/json" -d '{"query":"{__typename}"}' 2>/dev/null || echo "Connection failed")
if echo "$RESPONSE" | grep -q '__typename'; then
echo "GraphQL endpoint is available!"
exit 0
fi
echo "GraphQL endpoint not ready. Retrying in 2 seconds..."
sleep 2
done
echo "GraphQL endpoint did not become available within the expected time."
exit 1
- name: Cleanup - Free ports by stopping containers
if: always()
run: docker compose down