Skip to content

Commit

Permalink
added docker check to workflow (#2414)
Browse files Browse the repository at this point in the history
* added docker check to workflow

* made recommended changes to docker check in workflow

* added changes to docker check inn workflow as recommended

* added changes

* updated indentation in pull-request.yml file

* updated indentation in pull-request.yml file

* added Dockerfile and Docker-compose.yml file

* added Dockerfile and Docker-compose.yml file

* updated .docker-ignore file

* added recommended changes by code rabbit

* added recommended changes by code rabbit

* added recommended changes by code rabbit

* added recommended changes by code rabbit

* added recommended changes by code rabbit

* added recommended changes by code rabbit

* properly formatted code

* trying to make docker check pass

* trying to make docker check pass

* updated INSTALLATION.md

* updated INSTALLATION.md

* added recommended changes to INSTALLATION.md

* added recommended changes to INSTALLATION.md

* added recommended changes to INSTALLATION.md

* updated docker workflow

* updated INSTALLATION.md
  • Loading branch information
VanshikaSabharwal authored Nov 17, 2024
1 parent d16b95e commit 15513f5
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 41 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
node_modules
npm-debug.log
Dockerfile
.git
.gitignore
.env
.env.*
dist
coverage
.nyc_output
*.md
.github
tests
__tests__
*.test.*
*.spec.*
# Development files
*.log
*.lock
.DS_Store
.idea
.vscode
# Build artifacts
build
out
90 changes: 73 additions & 17 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Check formatting
if: steps.changed-files.outputs.only_changed != 'true'
run: npm run format:check

- name: Run formatting if check fails
if: failure()
run: npm run format
Expand All @@ -57,10 +57,10 @@ jobs:

- name: Check for linting errors in modified files
if: steps.changed-files.outputs.only_changed != 'true'
env:
env:
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
run: npm run check-tsdoc # Run the TSDoc check script

Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Changed Unauthorized files
id: changed-unauth-files
uses: tj-actions/changed-files@v40
Expand Down Expand Up @@ -123,10 +123,10 @@ jobs:
ISSUE_GUIDELINES.md
PR_GUIDELINES.md
README.md
- name: List all changed unauthorized files
if: steps.changed-unauth-files.outputs.any_changed == 'true' || steps.changed-unauth-files.outputs.any_deleted == 'true'
env:
env:
CHANGED_UNAUTH_FILES: ${{ steps.changed-unauth-files.outputs.all_changed_files }}
run: |
for file in ${CHANGED_UNAUTH_FILES}; do
Expand All @@ -147,14 +147,14 @@ jobs:
uses: tj-actions/changed-files@v40

- name: Echo number of changed files
env:
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:
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."
Expand Down Expand Up @@ -194,23 +194,23 @@ jobs:

- name: Install Dependencies
run: npm install

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

- name: Run tests
if: steps.changed-files.outputs.only_changed != 'true'
run: npm run test -- --watchAll=false --coverage
run: npm run test -- --watchAll=false --coverage

- name: TypeScript compilation for changed files
run: |
for file in ${{ steps.changed-files.outputs.all_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}}
uses: codecov/codecov-action@v4
with:
Expand All @@ -222,7 +222,7 @@ jobs:
- name: Test acceptable level of code coverage
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: "./coverage/lcov.info"
path: './coverage/lcov.info'
min_coverage: 95.0

Graphql-Inspector:
Expand All @@ -240,19 +240,75 @@ jobs:

- name: resolve dependency
run: npm install -g @graphql-inspector/cli

- 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
git clone --branch $FULL_BRANCH_NAME https://github.com/PalisadoesFoundation/talawa-api && ls -a
- name: Validate Documents
run: graphql-inspector validate './src/GraphQl/**/*.ts' './talawa-api/schema.graphql'

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]' }}
name: Check Target Branch
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20.10.0 AS build

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

EXPOSE 4321

CMD ["npm", "run", "serve"]
Loading

0 comments on commit 15513f5

Please sign in to comment.