302 lines
7.9 KiB
YAML
302 lines
7.9 KiB
YAML
stages:
|
|
- prepare
|
|
- analysis
|
|
- testing
|
|
- build
|
|
- integration
|
|
- package
|
|
- deploy
|
|
|
|
meta-build-image:
|
|
image: docker:stable
|
|
services:
|
|
- docker:dind
|
|
stage: prepare
|
|
script:
|
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
- cd .meta-testimage-python
|
|
- docker build -t $CI_REGISTRY/openflexure/openflexure-microscope-server/testimage-python:latest .
|
|
- docker push $CI_REGISTRY/openflexure/openflexure-microscope-server/testimage-python:latest
|
|
only:
|
|
refs: # commented out for initial run
|
|
- v3
|
|
changes:
|
|
- .meta/Dockerfile
|
|
|
|
|
|
# Re-usable block to install (and cache) Poetry and openflexure-microscope-server
|
|
.python:
|
|
image: registry.gitlab.com/openflexure/openflexure-microscope-server/testimage-python
|
|
retry: 1
|
|
before_script:
|
|
- python --version
|
|
- python -m venv .venv # NB this does not overwrite an existing cached venv
|
|
- source .venv/bin/activate
|
|
- pip install -e .[dev]
|
|
cache:
|
|
key: "${CI_COMMIT_REF_SLUG}"
|
|
paths:
|
|
- .cache/pip
|
|
- .venv
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
.javascript:
|
|
image: node:18
|
|
before_script:
|
|
- cd webapp
|
|
- npm install
|
|
cache:
|
|
key: "${CI_COMMIT_REF_SLUG}"
|
|
paths:
|
|
- webapp/node_modules
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# Check webapp and server have matching version string
|
|
version-check:
|
|
stage: analysis
|
|
#use a base python image as nothing needs to be installed
|
|
image: python:3.11
|
|
script:
|
|
- ./check_version_sync.py
|
|
only:
|
|
- branches
|
|
- merge_requests
|
|
- tags
|
|
- web
|
|
|
|
# Python static analysis with ruff
|
|
ruff-lint:
|
|
stage: analysis
|
|
extends: .python
|
|
script:
|
|
- ruff check
|
|
|
|
# Increased checking of the code with ruff this is allowed to fail
|
|
# while we improve the code quality. Rules from this are
|
|
# slowly moved into the main check
|
|
ruff-lint-increased:
|
|
stage: analysis
|
|
extends: .python
|
|
allow_failure: true
|
|
script:
|
|
- ruff --config ruff-increased-checking.toml check
|
|
|
|
# Python formatting with ruff
|
|
ruff-format:
|
|
stage: analysis
|
|
extends: .python
|
|
script:
|
|
- ruff format --check
|
|
|
|
# Python type checking with Mypy
|
|
mypy:
|
|
stage: analysis
|
|
extends: .python
|
|
script:
|
|
- mypy --cobertura-xml-report mypy --no-error-summary src | tee mypy/stdout.txt
|
|
after_script:
|
|
- cat mypy/stdout.txt | mypy-gitlab-code-quality > codequality.json
|
|
allow_failure: true
|
|
|
|
artifacts:
|
|
reports:
|
|
codequality: codequality.json
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: mypy/cobertura.xml
|
|
|
|
# Python unit tests with PyTest
|
|
pytest:
|
|
stage: testing
|
|
extends: .python
|
|
script:
|
|
- pytest
|
|
# --gitlab-code-quality-report=pytest-warnings.json # can restore when it installs ok
|
|
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
|
|
artifacts:
|
|
when: always
|
|
paths:
|
|
- report.xml
|
|
reports:
|
|
junit: report.xml
|
|
# codequality: pytest-warnings.json
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coverage.xml
|
|
|
|
# Generate and validate OpenAPI description - needs updating to work with v3
|
|
# openapi:
|
|
# stage: testing
|
|
# extends: .python
|
|
# 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"
|
|
|
|
# JavaScript linting with ESLint (via Vue CLI)
|
|
eslint:
|
|
stage: analysis
|
|
extends: .javascript
|
|
script:
|
|
# Build JS application for production
|
|
- npm run lint
|
|
|
|
# Build JS app
|
|
build:
|
|
stage: build
|
|
extends: .javascript
|
|
script:
|
|
- export NODE_OPTIONS=--openssl-legacy-provider
|
|
# Build JS application for production
|
|
- npm run build
|
|
artifacts:
|
|
name: "dist"
|
|
expire_in: 1 week
|
|
paths:
|
|
- "src/openflexure_microscope_server/static/"
|
|
|
|
build-docs:
|
|
extends: .python
|
|
stage: build
|
|
script:
|
|
- |
|
|
pydoctor -W \
|
|
--docformat restructuredtext \
|
|
--project-name "OpenFlexure Microscope Server" \
|
|
--project-version $CI_COMMIT_REF_NAME \
|
|
--theme readthedocs \
|
|
--html-viewsource-base https://gitlab.com/openflexure/openflexure-microscope-server/-/tree/$CI_COMMIT_SHA/ \
|
|
src/openflexure_microscope_server
|
|
- echo "JOB_ID=$CI_JOB_ID" > build-docs.env
|
|
artifacts:
|
|
expire_in: 1 week
|
|
name: "${CI_PROJECT_NAME}-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}-docs"
|
|
paths:
|
|
- apidocs
|
|
reports:
|
|
dotenv: build-docs.env
|
|
environment:
|
|
name: review/$CI_COMMIT_REF_SLUG
|
|
url: https://$CI_PROJECT_ROOT_NAMESPACE.gitlab.io/-/openflexure-microscope-server/-/jobs/$JOB_ID/artifacts/apidocs/index.html
|
|
|
|
|
|
server_integration_tests:
|
|
extends: .python
|
|
stage: integration
|
|
needs:
|
|
- job: build
|
|
artifacts: true
|
|
script:
|
|
- integration-tests/testfile.py
|
|
|
|
|
|
# # 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_server/static/
|
|
# - 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/"
|
|
|
|
# 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
|
|
|
|
# zenodo:
|
|
# stage: deploy
|
|
# image: ubuntu:20.04
|
|
# before_script:
|
|
# - apt-get update -qq
|
|
# - apt-get -y -qq install git python3-pip
|
|
# - pip3 install -r scripts/zenodo/requirements.txt
|
|
# variables:
|
|
# ZENODO_USE_SANDBOX: "false"
|
|
# script:
|
|
# - git archive "${CI_COMMIT_REF_NAME}" --format=zip --output="${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}-source.zip"
|
|
# - python3 scripts/zenodo/upload_to_zenodo.py "${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}-source.zip" dist/*
|
|
# artifacts:
|
|
# # this is only a small html link, let's just keep it forever
|
|
# # gitlab doesn't understand "expire_in: never" yet though
|
|
# expire_in: 100000 years
|
|
# name: zenodo-${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}-link.html
|
|
# paths:
|
|
# - zenodo-link.html
|
|
# only:
|
|
# - tags
|
|
# - web
|
|
|
|
pages:
|
|
needs:
|
|
- job: build-docs
|
|
artifacts: true
|
|
stage: deploy
|
|
image: "alpine:latest"
|
|
script:
|
|
- mv apidocs public
|
|
artifacts:
|
|
paths:
|
|
- public
|
|
only:
|
|
- v3
|