-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
163 lines (148 loc) · 5.36 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
163 lines (148 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
include:
- remote: 'https://raw.githubusercontent.com/pnnl-miscscripts/gitlab-lib/v1/gitlab-lib.yaml'
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_COMMIT_TAG'
- if: '$CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "pipeline"'
- when: never
# ---------------------------------------------------------------------------
# Global configuration
# ---------------------------------------------------------------------------
default:
image: python:3.13-slim
tags:
- k8s
- rzr
- codebuilds
services:
- postgres:18
variables:
POSTGRES_DB: molformula
POSTGRES_USER: coremsdb
POSTGRES_PASSWORD: coremsmolform
POSTGRES_HOST_AUTH_METHOD: trust
COREMS_DATABASE_URL: postgresql://coremsdb:coremsmolform@postgres:5432/molformula
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PIP_ROOT_USER_ACTION: ignore
# Avoids libicu dependency crash when .NET initialises in a slim container
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: "1"
# Kubernetes runner pod sizing — undersized defaults are a common cause of
# slow CI wall time. Override per-job if a stage needs more/less.
KUBERNETES_CPU_REQUEST: "2"
KUBERNETES_CPU_LIMIT: "4"
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 8Gi
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- .cache/pip
- tests/tests_data/lcms/202412_lipid_ref.sqlite
stages:
- test
- build
- publish
- publish-image
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
.install-dotnet: &install-dotnet
- apt-get update -qq && apt-get install -y --no-install-recommends curl ca-certificates libssl3 libkrb5-3 zlib1g gcc python3-dev make
- curl -sSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh
- chmod +x /tmp/dotnet-install.sh
- /tmp/dotnet-install.sh --runtime dotnet --channel 8.0 --install-dir /usr/local/dotnet
- export DOTNET_ROOT=/usr/local/dotnet
- export PATH="$PATH:/usr/local/dotnet"
- rm /tmp/dotnet-install.sh
.test_job_rules: &test_job_rules
- if: '$CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- corems/**/*
- tests/**/*
- examples/**/*
- db/**/*
- ext_lib/**/*
- support_code/**/*
- Dockerfile*
- docker-compose*.yml
- Makefile
- setup.py
- pyproject.toml
- pytest.ini
- conftest.py
- .gitlab-ci.yml
- if: '$CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "pipeline"'
- if: '$CI_COMMIT_TAG'
- when: never
# ---------------------------------------------------------------------------
# Test
# ---------------------------------------------------------------------------
test-source:
stage: test
rules: *test_job_rules
script:
- *install-dotnet
- make ci-test-source LIPIDOMICS_SQLITE_PATH="$CI_PROJECT_DIR/tests/tests_data/lcms/202412_lipid_ref.sqlite"
# ---------------------------------------------------------------------------
# Notebook tests
# ---------------------------------------------------------------------------
test-notebooks:
stage: test
rules: *test_job_rules
script:
- *install-dotnet
- make ci-test-notebooks LIPIDOMICS_SQLITE_PATH="$CI_PROJECT_DIR/tests/tests_data/lcms/202412_lipid_ref.sqlite"
artifacts:
when: on_failure
paths:
- /tmp/*_test.ipynb
expire_in: 3 days
# ---------------------------------------------------------------------------
# Build sdist + wheel
# ---------------------------------------------------------------------------
build-package:
stage: build
script:
- python3 -m pip install --upgrade pip build
- python3 -m build
artifacts:
paths:
- dist/
expire_in: 7 days
# ---------------------------------------------------------------------------
# Publish to PyPI (version tags on the default branch only, e.g. v3.11.0)
# ---------------------------------------------------------------------------
publish-pypi:
stage: publish
needs: [build-package]
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'
- if: '$CI_PIPELINE_SOURCE == "web"'
when: manual
script:
- python3 -m pip install --upgrade twine
- TWINE_USERNAME=__token__ TWINE_PASSWORD="$PYPI_TOKEN" twine upload dist/*
environment:
name: pypi
url: https://pypi.org/project/CoreMS/
# ---------------------------------------------------------------------------
# Build and push the base container image to the GitLab registry
# (runs only on the default branch or version tags)
# ---------------------------------------------------------------------------
publish-image:
extends: .pnnllib-gitlab-build-container-image
stage: publish-image
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'
variables:
KANIKO_EXTRA_ARGS: "--cache=true --cache-copy-layers=true --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA --destination $CI_REGISTRY_IMAGE:latest"
CONTEXT: $CI_PROJECT_DIR
DOCKERFILE: Dockerfile
KUBERNETES_CPU_REQUEST: 100m
KUBERNETES_CPU_LIMIT: "2"
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 8Gi