Added eslint and cache to CI

This commit is contained in:
Joel Collins 2020-11-23 10:44:41 +00:00
parent 3c2b5f56a1
commit f5012cddec

View file

@ -1,26 +1,39 @@
stages: stages:
- analysis - analysis
- build - build
- package
- deploy - deploy
# Cache modules in between jobs # Re-usable block to install (and cache) Poetry and openflexure-microscope-server
cache: .poetry-install-template: &poetry-install
key: ${CI_COMMIT_REF_SLUG} before_script:
paths: - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
- node_modules/ - $HOME/.poetry/bin/poetry config virtualenvs.in-project true
- $HOME/.poetry/bin/poetry install -vv
cache:
key: "${CI_COMMIT_REF_SLUG}"
paths:
- .cache/pip
- .venv
# Re-usable block to install (and cache) openflexure-microscope-server static app
.node-install-template: &node-install
before_script:
- cd openflexure_microscope/api/static/
- npm install
cache:
key: "${CI_COMMIT_REF_SLUG}"
paths:
- openflexure_microscope/api/static/node_modules
pylint: pylint:
stage: analysis stage: analysis
image: python:3.7 image: python:3.7
retry: 1 retry: 1
before_script: <<: *poetry-install
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
script: script:
# Install server
- $HOME/.poetry/bin/poetry install
# Run static build script
- $HOME/.poetry/bin/poetry run pylint ./openflexure_microscope/ - $HOME/.poetry/bin/poetry run pylint ./openflexure_microscope/
only: only:
@ -34,12 +47,9 @@ black:
image: python:3.7 image: python:3.7
retry: 1 retry: 1
before_script: <<: *poetry-install
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
script: script:
# Install server
- $HOME/.poetry/bin/poetry install
# Run static build script # Run static build script
- $HOME/.poetry/bin/poetry run black --check . - $HOME/.poetry/bin/poetry run black --check .
@ -49,24 +59,32 @@ black:
- tags - tags
- web - web
# Electron app build # Lint JS app
build: eslint:
stage: build stage: analysis
image: nikolaik/python-nodejs:python3.7-nodejs14 image: node:15
before_script: <<: *node-install
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
script: script:
# Install server # Build JS application for production
- $HOME/.poetry/bin/poetry install - npm run lint
# Run static build script
- $HOME/.poetry/bin/poetry run build_static only:
# Build distribution archive - merge_requests
- mkdir -p dist - tags
- tar -c --exclude-vcs --exclude-from .tarignore -vzf dist/openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz . - web
- cd dist/
- sha256sum openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz > openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz.sha256 # Build JS app
build:
stage: build
image: node:15
<<: *node-install
script:
# Build JS application for production
- npm run build
artifacts: artifacts:
name: "dist" name: "dist"
@ -79,11 +97,38 @@ build:
- tags - tags
- web - web
# Package
package:
stage: package
dependencies:
- build
script:
# Build distribution archive
- mkdir -p dist
- tar -c --exclude-vcs --exclude-from .tarignore -vzf dist/openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz .
- cd dist/
- sha256sum openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz > openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz.sha256
artifacts:
name: "dist"
expire_in: 1 week
paths:
- "./dist/openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz"
- "./dist/openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz.sha256"
only:
- merge_requests
- tags
- web
# Deploy to builds.openflexure.org # Deploy to builds.openflexure.org
deploy: deploy:
stage: deploy stage: deploy
dependencies: dependencies:
- build - package
image: ubuntu:latest image: ubuntu:latest
before_script: before_script: