wrolpi/.circleci/config.yml

182 lines
5.2 KiB
YAML

# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
app-tests-18:
docker:
- image: cimg/node:18.12
resource_class: small
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "app/package-lock.json" }}
- run: cd app && npm install --legacy-peer-deps
- save_cache:
key: dependency-cache-{{ checksum "app/package-lock.json" }}
paths:
- ./app/node_modules
- run: cd app && npm run test
app-tests-20:
docker:
- image: cimg/node:20.13
resource_class: small
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "app/package-lock.json" }}
- run: cd app && npm install --legacy-peer-deps
- save_cache:
key: dependency-cache-{{ checksum "app/package-lock.json" }}
paths:
- ./app/node_modules
- run: cd app && npm run test
app-tests-22:
docker:
- image: cimg/node:22.1
resource_class: small
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "app/package-lock.json" }}
- run: cd app && npm install --legacy-peer-deps
- save_cache:
key: dependency-cache-{{ checksum "app/package-lock.json" }}
paths:
- ./app/node_modules
- run: cd app && npm run test
api-tests-3-11:
docker:
- image: cimg/python:3.11
- image: cimg/postgres:15.6
environment:
POSTGRES_USER: postgres
POSTGRES_DB: wrolpi
POSTGRES_PASSWORD: "wrolpi"
resource_class: medium
steps:
- checkout
- run: sudo apt-get update
- run: sudo apt-get install -y ffmpeg catdoc
- restore_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-2
- run:
name: Install Requirements
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-2
paths:
- "venv"
- run:
command: './venv/bin/pytest -svv --junitxml=test-results.xml'
- store_test_results:
path: test-results.xml
api-tests-3-12:
docker:
- image: cimg/python:3.12
- image: cimg/postgres:15.6
environment:
POSTGRES_USER: postgres
POSTGRES_DB: wrolpi
POSTGRES_PASSWORD: "wrolpi"
resource_class: medium
steps:
- checkout
- run: sudo apt-get update
- run: sudo apt-get install -y ffmpeg catdoc
- restore_cache:
key: deps-3.12-{{ checksum "requirements.txt" }}-2
- run:
name: Install Requirements
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps-3.12-{{ checksum "requirements.txt" }}-2
paths:
- "venv"
- run:
command: './venv/bin/pytest -svv'
sanic-api-start:
docker:
- image: cimg/python:3.11
steps:
- checkout
- restore_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-2
- run:
name: Install dependencies
command: |
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
sudo mkdir -p /media/wrolpi
- run:
name: Start Sanic API
command: |
. venv/bin/activate
sanic main:api_app -H 0.0.0.0 -p 8081
background: true
- run:
name: Test Sanic API
command: |
sleep 20
curl http://0.0.0.0:8081/api/echo
- run:
name: Stop Sanic API
command: pkill -f sanic
react-app-build:
docker:
- image: cimg/node:20.13
resource_class: large
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "app/package-lock.json" }}
- run: cd app && npm install --legacy-peer-deps
- run:
name: Build React App
command: cd app && DISABLE_ESLINT_PLUGIN=true npm run build
react-app-start:
docker:
- image: cimg/node:20.13
resource_class: small
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "app/package-lock.json" }}
- run: cd app && npm install --legacy-peer-deps
- run:
name: Start React App
command: |
cd app
npm run start
background: true
- run:
name: Test React App
command: |
sleep 20
curl http://0.0.0.0:3000/manifest.json
- run:
name: Stop React App
command: pkill -f npm
workflows:
wrolpi-api-tests:
jobs:
- sanic-api-start
- api-tests-3-11
# - api-tests-3-12 Sanic does not yet support 3.12.
wrolpi-app-test:
jobs:
- app-tests-18
- app-tests-20
- app-tests-22
- react-app-build
- react-app-start