Skip to content

Commit

Permalink
Merge pull request #308 from BkPankaj/gitActions/CIWorkflow
Browse files Browse the repository at this point in the history
Added CI Workflow with basic frontend test
  • Loading branch information
BkPankaj committed Jun 3, 2024
2 parents 34c630d + d8bed49 commit d479405
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 47 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/CI_Workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI Workflow

on:
pull_request:
branches:
- 'master'

jobs:
setup:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Install frontend dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
working-directory: frontend
run: npm ci --legacy-peer-deps

- name: Cache Node modules
if: steps.cache-node-modules.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Create virtual environment
run: python -m venv .venv

- name: Activate virtual environment
run: source .venv/bin/activate

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
- name: Add .env file
run: cp backend/.env.template backend/.env

- name: Generate static files
run: python backend/manage.py collectstatic

- name: Save venv
uses: actions/upload-artifact@v4
with:
name: venv
path: .venv

frontend-tests:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Restore Node modules cache
id: restore-node-modules
uses: actions/cache@v4
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/frontend/package-lock.json') }}

- name: Install frontend dependencies
if: steps.restore-node-modules.outputs.cache-hit != 'true'
working-directory: frontend
run: npm ci --legacy-peer-deps

- name: Permissions for node_modules
run: chmod -R +x frontend/node_modules/.bin

- name: Verify node_modules restoration
run: |
ls -la frontend/node_modules
ls -la frontend/node_modules/.bin
- name: Run frontend test
run: npm test -- --watchAll=false
working-directory: frontend
45 changes: 0 additions & 45 deletions .github/workflows/install_dependencies.yml

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
test('renders App for test', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
const linkElement = screen.getByText(/File/i);
expect(linkElement).toBeInTheDocument();
});

0 comments on commit d479405

Please sign in to comment.