Combined PR of ROS1 laser block and CI Workflow with basic frontend test #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |