Commit f5012cdd authored by Joel Collins's avatar Joel Collins
Browse files

Added eslint and cache to CI

parent 3c2b5f56
Loading
Loading
Loading
Loading
Loading
+69 −24
Original line number Diff line number Diff line
stages:
  - analysis
  - build
  - package
  - deploy

# Cache modules in between jobs
# Re-usable block to install (and cache) Poetry and openflexure-microscope-server
.poetry-install-template: &poetry-install
  before_script:
    - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
    - $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}
    key: "${CI_COMMIT_REF_SLUG}"
    paths:
    - node_modules/
      - openflexure_microscope/api/static/node_modules

pylint:
  stage: analysis
  image: python:3.7
  retry: 1

  before_script:
    - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
  <<: *poetry-install

  script:
    # Install server
    - $HOME/.poetry/bin/poetry install
    # Run static build script
    - $HOME/.poetry/bin/poetry run pylint ./openflexure_microscope/

  only:
@@ -34,12 +47,9 @@ black:
  image: python:3.7
  retry: 1

  before_script:
    - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
  <<: *poetry-install

  script:
    # Install server
    - $HOME/.poetry/bin/poetry install
    # Run static build script
    - $HOME/.poetry/bin/poetry run black --check .

@@ -49,19 +59,52 @@ black:
    - tags
    - web

# Electron app build
# Lint JS app
eslint:
  stage: analysis
  image: node:15

  <<: *node-install

  script:
    # Build JS application for production
    - npm run lint

  only:
    - merge_requests
    - tags
    - web

# Build JS app
build:
  stage: build
  image: nikolaik/python-nodejs:python3.7-nodejs14
  image: node:15

  before_script:
    - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
  <<: *node-install

  script:
    # Build JS application for production
    - npm run build

  artifacts:
    name: "dist"
    expire_in: 1 week
    paths:
      - "./dist/*"

  only:
    - merge_requests
    - tags
    - web

# Package
package:
  stage: package

  dependencies:
    - build

  script:
    # Install server
    - $HOME/.poetry/bin/poetry install
    # Run static build script
    - $HOME/.poetry/bin/poetry run build_static
    # Build distribution archive
    - mkdir -p dist
    - tar -c --exclude-vcs --exclude-from .tarignore -vzf dist/openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz .
@@ -72,7 +115,8 @@ build:
    name: "dist"
    expire_in: 1 week
    paths:
      - "./dist/*"
      - "./dist/openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz"
      - "./dist/openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz.sha256"

  only:
    - merge_requests
@@ -83,7 +127,8 @@ build:
deploy:
  stage: deploy
  dependencies:
    - build
    - package

  image: ubuntu:latest

  before_script: