diff --git a/.github/workflows/CI_Workflow.yml b/.github/workflows/CI_Workflow.yml new file mode 100644 index 00000000..3ff45e6a --- /dev/null +++ b/.github/workflows/CI_Workflow.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/install_dependencies.yml b/.github/workflows/install_dependencies.yml deleted file mode 100644 index 4cd2d02a..00000000 --- a/.github/workflows/install_dependencies.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Install & Build - -on: - pull_request: - branches: - - 'master' - -jobs: - install: - 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: '16' - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Install NPM dependencies - working-directory: frontend - run: npm install --legacy-peer-deps - - - 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 diff --git a/frontend/src/App.test.tsx b/frontend/src/App.test.tsx index 2a68616d..e9d70bf6 100644 --- a/frontend/src/App.test.tsx +++ b/frontend/src/App.test.tsx @@ -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(); - const linkElement = screen.getByText(/learn react/i); + const linkElement = screen.getByText(/File/i); expect(linkElement).toBeInTheDocument(); });