The JS build step was reporting the JS source folder as an artifact. I've updated it to use the output folder instead.
235 lines
5.1 KiB
YAML
235 lines
5.1 KiB
YAML
stages:
|
|
- analysis
|
|
- testing
|
|
- build
|
|
- package
|
|
- deploy
|
|
|
|
# Re-usable block to install (and cache) Poetry and openflexure-microscope-server
|
|
.python-install-template: &python-install
|
|
before_script:
|
|
- python3 -m venv .venv # NB this does not overwrite an existing cached venv
|
|
- source .venv/bin/activate
|
|
- pip install pipenv # Should be cached after first run
|
|
- pipenv install --dev --deploy # Should be cached after first run - will just check packages are present
|
|
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 js/
|
|
- npm install
|
|
cache:
|
|
key: "${CI_COMMIT_REF_SLUG}"
|
|
paths:
|
|
- js/node_modules
|
|
|
|
# Python static analysis with PyLint
|
|
pylint:
|
|
stage: analysis
|
|
image: python:3.7
|
|
retry: 1
|
|
|
|
<<: *python-install
|
|
|
|
script:
|
|
- poe pylint
|
|
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# Python type checking with Mypy
|
|
mypy:
|
|
stage: analysis
|
|
image: python:3.7
|
|
retry: 1
|
|
|
|
<<: *python-install
|
|
|
|
script:
|
|
- poe mypy
|
|
|
|
artifacts:
|
|
reports:
|
|
cobertura: openflexure_microscope/cobertura.xml
|
|
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# Python style analysis with Black
|
|
black:
|
|
stage: analysis
|
|
image: python:3.7
|
|
retry: 1
|
|
allow_failure: true
|
|
|
|
<<: *python-install
|
|
|
|
script:
|
|
# Run static build script
|
|
- poe black_check
|
|
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# Python unit tests with PyTest
|
|
pytest:
|
|
stage: testing
|
|
image: python:3.7
|
|
retry: 1
|
|
|
|
<<: *python-install
|
|
|
|
script:
|
|
- poe test
|
|
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
artifacts:
|
|
when: always
|
|
reports:
|
|
junit: pytest_report.xml
|
|
|
|
openapi:
|
|
stage: testing
|
|
image: python:3.7
|
|
retry: 1
|
|
|
|
<<: *python-install
|
|
|
|
script:
|
|
- mkdir -p docs/build/
|
|
- ofm-generate-openapi -o docs/build/swagger.yaml --validate
|
|
artifacts:
|
|
name: "openapi"
|
|
expose_as: "OpenAPI Description"
|
|
expire_in: 1 week
|
|
paths:
|
|
- "./docs/build/swagger.yaml"
|
|
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# JavaScript linting with ESLint (via Vue CLI)
|
|
eslint:
|
|
stage: analysis
|
|
image: node:15
|
|
|
|
<<: *node-install
|
|
|
|
script:
|
|
# Build JS application for production
|
|
- npm run lint
|
|
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# Build JS app
|
|
build:
|
|
stage: build
|
|
image: node:15
|
|
|
|
<<: *node-install
|
|
|
|
script:
|
|
# Build JS application for production
|
|
- npm run build
|
|
|
|
artifacts:
|
|
name: "dist"
|
|
expire_in: 1 week
|
|
paths:
|
|
- "openflexure_microscope/static/dist/"
|
|
|
|
only:
|
|
- master
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# Package application into distribution tarball
|
|
package:
|
|
stage: package
|
|
dependencies:
|
|
- build
|
|
- openapi
|
|
|
|
image: ubuntu:latest
|
|
|
|
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 .
|
|
- tar -c --exclude-vcs --exclude-from .tarignore -vzf dist/openflexure-microscope-webapp-${CI_COMMIT_REF_NAME}.tar.gz ./openflexure_microscope/api/static/dist/
|
|
- cp docs/build/swagger.yaml dist/openflexure-microscope-api-${CI_COMMIT_REF_NAME}.yaml
|
|
- cd dist/
|
|
- sha256sum openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz > openflexure-microscope-server-${CI_COMMIT_REF_NAME}.tar.gz.sha256
|
|
- sha256sum openflexure-microscope-webapp-${CI_COMMIT_REF_NAME}.tar.gz > openflexure-microscope-webapp-${CI_COMMIT_REF_NAME}.tar.gz.sha256
|
|
- sha256sum openflexure-microscope-api-${CI_COMMIT_REF_NAME}.yaml > openflexure-microscope-api-${CI_COMMIT_REF_NAME}.yaml.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"
|
|
- "./dist/openflexure-microscope-webapp-${CI_COMMIT_REF_NAME}.tar.gz"
|
|
- "./dist/openflexure-microscope-webapp-${CI_COMMIT_REF_NAME}.tar.gz.sha256"
|
|
|
|
only:
|
|
- master
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# Deploy to builds.openflexure.org
|
|
deploy:
|
|
stage: deploy
|
|
dependencies:
|
|
- package
|
|
|
|
image: ubuntu:latest
|
|
|
|
before_script:
|
|
- "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )"
|
|
- eval $(ssh-agent -s)
|
|
- ssh-add <(echo "$SSH_PRIVATE_KEY_BATH_OPENFLEXURE_BASE64" | base64 --decode)
|
|
- mkdir -p ~/.ssh
|
|
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
|
|
|
|
script:
|
|
# Install rsync if not already installed
|
|
- "which rsync || ( apt-get update -y && apt-get install rsync -y )"
|
|
|
|
# Upload the builds folder to openflexure-microscope builds
|
|
- rsync -hrvz -e ssh dist/ ci-user@openflexure.bath.ac.uk:/var/www/build/openflexure-microscope-server
|
|
|
|
# Run update-latest.py on the build server
|
|
- ssh -t ci-user@openflexure.bath.ac.uk "/var/www/build/update-latest.py"
|
|
|
|
only:
|
|
- tags
|
|
- web
|