STASIS
A pipeline delivery generator
Loading...
Searching...
No Matches
delivery.h
Go to the documentation of this file.
1
2
3#ifndef STASIS_DELIVERY_H
4#define STASIS_DELIVERY_H
5
6#include <string.h>
7#include <stdbool.h>
8#include "artifactory.h"
9#include "docker.h"
10#include "environment.h"
11#include "ini.h"
12#include "multiprocessing.h"
13#include "conda.h"
14
15#define DELIVERY_PLATFORM_MAX 4
16#define DELIVERY_PLATFORM_MAXLEN 65
17#define DELIVERY_PLATFORM 0
18#define DELIVERY_PLATFORM_CONDA_SUBDIR 1
19#define DELIVERY_PLATFORM_CONDA_INSTALLER 2
20#define DELIVERY_PLATFORM_RELEASE 3
21
22#define DELIVERY_REWRITE_SPEC_STAGE_1 0
23#define DELIVERY_REWRITE_SPEC_STAGE_2 1
24
25#define INSTALL_PKG_CONDA 1 << 1
26#define INSTALL_PKG_CONDA_DEFERRED 1 << 2
27#define INSTALL_PKG_PIP 1 << 3
28#define INSTALL_PKG_PIP_DEFERRED 1 << 4
29
30#define DEFER_CONDA 0
31#define DEFER_PIP 1
32
33enum {
34 DM_NONE = 0,
35 DM_VCS_URL_IN_SETUP,
36};
37extern const char *DELIVERY_MESSAGES[]; // see delivery.c
38
39struct Content {
40 unsigned type;
41 char *filename;
42 char *data;
43};
44
46#define TEST_NUM_ALLOC_INITIAL 10
47
66
70struct Delivery {
75 struct INIFILE *delivery;
76 struct INIFILE *cfg;
77 struct INIFILE *mission;
78 char *delivery_path;
79 char *cfg_path;
80 char *mission_path;
81 } _stasis_ini_fp;
82
86 struct System {
87 char *arch;
88 char **platform;
89 } system;
90
118
122 struct Meta {
123 char *name;
124 char *version;
125 int rc;
126 char *python;
128 char *based_on;
129 char *mission;
130 char *codename;
131 bool final;
132 } meta;
133
137 struct Info {
139 char *build_name;
140 char *build_number;
141 struct tm *time_info;
142 time_t time_now;
144 } info;
145
169
173 struct Runtime {
174 RuntimeEnv *environ;
175 } runtime;
176
177 struct Tests {
178 struct Test **test;
179 size_t num_used;
180 size_t num_alloc;
181 } *tests;
182
183 struct Deploy {
184 struct JFRT_Auth jfrog_auth;
185
186 struct JFrog {
187 struct StrList *files;
188 struct JFRT_Upload upload_ctx;
189 char *repo;
190 char *dest;
191 } jfrog[1000];
192
193 struct Docker {
194 struct DockerCapabilities capabilities;
195 char *image_compression;
196 char *dockerfile;
197 char *registry;
198 char *test_script;
199 struct StrList *build_args;
200 struct StrList *tags;
201 } docker;
202 } deploy;
203
204 struct Rule {
205 struct INIFILE *_handle;
210 struct Content content[1000];
211 } rules;
212};
213
221int delivery_init(struct Delivery *ctx, int render_mode);
222
227void delivery_free(struct Delivery *ctx);
228
233void delivery_meta_show(struct Delivery *ctx);
234
239void delivery_conda_show(struct Delivery *ctx);
240
245void delivery_tests_show(struct Delivery *ctx);
246
251void delivery_runtime_show(struct Delivery *ctx);
252
259int delivery_build_recipes(struct Delivery *ctx);
260
267struct StrList *delivery_build_wheels(struct Delivery *ctx);
268
276
283char *delivery_get_release_header(struct Delivery *ctx);
284
292void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage);
293
301
309
315int delivery_get_conda_installer(struct Delivery *ctx, char *installer_url);
316
324void delivery_get_conda_installer_url(struct Delivery *ctx, char *result, size_t maxlen);
325
337int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, char *env_name, int type, struct StrList *manifest[]);
338
346
351void delivery_tests_run(struct Delivery *ctx);
352
360void delivery_defer_packages(struct Delivery *ctx, int type);
361
366void delivery_conda_enable(struct Delivery *ctx);
367
373void delivery_install_conda(char *install_script, char *conda_install_dir);
374
398int delivery_format_str(struct Delivery *ctx, char **dest, size_t maxlen, const char *fmt);
399
400// helper function
401int delivery_gather_tool_versions(struct Delivery *ctx);
402
403// helper function
404int delivery_init_tmpdir(struct Delivery *ctx);
405
406void delivery_init_dirs_stage1(struct Delivery *ctx);
407
408void delivery_init_dirs_stage2(struct Delivery *ctx);
409
410int delivery_init_platform(struct Delivery *ctx);
411
412int delivery_init_artifactory(struct Delivery *ctx);
413
414int delivery_artifact_upload(struct Delivery *ctx);
415
416int delivery_mission_render_files(struct Delivery *ctx);
417
418int delivery_docker(struct Delivery *ctx);
419
420int delivery_fixup_test_results(struct Delivery *ctx);
421
422int bootstrap_build_info(struct Delivery *ctx);
423
424int delivery_dump_metadata(struct Delivery *ctx);
425
426int populate_info(struct Delivery *ctx);
427
428int populate_delivery_cfg(struct Delivery *ctx, int render_mode);
429
430int populate_delivery_ini(struct Delivery *ctx, int render_mode);
431
432int populate_mission_ini(struct Delivery **ctx, int render_mode);
433
434void validate_delivery_ini(struct INIFILE *ini);
435
436int filter_repo_tags(char *repo, struct StrList *patterns);
437
438void delivery_autoresolve_vcs_urls(const char *srcdir);
439
440#define DELIVERY_NOT_FOUND 0
441#define DELIVERY_FOUND 1
447int delivery_exists(struct Delivery *ctx);
448
449int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_name);
450
459int delivery_conda_enforce_package_version(struct Delivery *ctx, const char *env_name, const char *name);
460
468int delivery_series_sync(struct Delivery *ctx);
469
480int delivery_purge_packages(struct Delivery *ctx, const char *env_name, int use_pkg_manager);
481
488void delivery_export(const struct Delivery *ctx, char *envs[]);
489
496void delivery_rewrite_stage1(struct Delivery *ctx, char *specfile);
497
504void delivery_rewrite_stage2(struct Delivery *ctx, char *specfile);
505
511struct Delivery *delivery_duplicate(struct Delivery *ctx);
512
518struct Tests *tests_init(size_t num_tests);
519
526int tests_add(struct Tests *tests, struct Test *x);
527
532void test_free(struct Test **x);
533
538void tests_free(struct Tests **x);
539
544struct Test *test_init();
545
546
547#endif //STASIS_DELIVERY_H
struct Delivery * delivery_duplicate(struct Delivery *ctx)
Definition delivery.c:107
void delivery_runtime_show(struct Delivery *ctx)
Definition delivery_show.c:97
int delivery_copy_conda_artifacts(struct Delivery *ctx)
Definition delivery_postprocess.c:180
int delivery_exists(struct Delivery *ctx)
Definition delivery_init.c:391
int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, char *env_name, int type, struct StrList *manifest[])
int delivery_conda_enforce_package_version(struct Delivery *ctx, const char *env_name, const char *name)
Definition delivery_install.c:134
int tests_add(struct Tests *tests, struct Test *x)
Definition delivery_test.c:20
int delivery_init(struct Delivery *ctx, int render_mode)
Definition delivery_init.c:270
int delivery_index_conda_artifacts(struct Delivery *ctx)
Definition delivery_postprocess.c:204
int delivery_build_recipes(struct Delivery *ctx)
Definition delivery_build.c:7
void delivery_rewrite_stage1(struct Delivery *ctx, char *specfile)
Definition delivery_export.c:64
void delivery_install_conda(char *install_script, char *conda_install_dir)
Definition delivery_conda.c:66
void delivery_conda_show(struct Delivery *ctx)
Definition delivery_show.c:34
struct Test * test_init()
Definition delivery_test.c:37
int delivery_get_conda_installer(struct Delivery *ctx, char *installer_url)
Definition delivery_conda.c:37
void delivery_free(struct Delivery *ctx)
Definition delivery.c:301
void tests_free(struct Tests **x)
Definition delivery_test.c:72
void delivery_tests_run(struct Delivery *ctx)
Definition delivery_test.c:85
void delivery_rewrite_stage2(struct Delivery *ctx, char *specfile)
Definition delivery_export.c:73
void delivery_tests_show(struct Delivery *ctx)
Definition delivery_show.c:85
void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage)
Definition delivery_postprocess.c:71
void test_free(struct Test **x)
Definition delivery_test.c:52
void delivery_export(const struct Delivery *ctx, char *envs[])
Definition delivery_export.c:51
int delivery_purge_packages(struct Delivery *ctx, const char *env_name, int use_pkg_manager)
Definition delivery_install.c:287
int delivery_copy_wheel_artifacts(struct Delivery *ctx)
Definition delivery_postprocess.c:208
int delivery_format_str(struct Delivery *ctx, char **dest, size_t maxlen, const char *fmt)
Definition delivery.c:398
struct Tests * tests_init(size_t num_tests)
Definition delivery_test.c:3
void delivery_meta_show(struct Delivery *ctx)
Definition delivery_show.c:12
void delivery_conda_enable(struct Delivery *ctx)
Definition delivery_conda.c:106
struct StrList * delivery_build_wheels(struct Delivery *ctx)
Definition delivery_build.c:388
void delivery_get_conda_installer_url(struct Delivery *ctx, char *result, size_t maxlen)
Definition delivery_conda.c:4
void delivery_defer_packages(struct Delivery *ctx, int type)
Definition delivery.c:463
int delivery_series_sync(struct Delivery *ctx)
Definition delivery_artifactory.c:194
int delivery_index_wheel_artifacts(struct Delivery *ctx)
Definition delivery_postprocess.c:216
char * delivery_get_release_header(struct Delivery *ctx)
Definition delivery_postprocess.c:14
Collection of feature flags to support older, newer, and transitional versions of conda/mamba.
Definition conda.h:34
Definition delivery.h:39
Conda configuration.
Definition delivery.h:151
struct StrList * pip_packages_defer
Python packages to be built for delivery.
Definition delivery.h:164
char * installer_version
Version of installer.
Definition delivery.h:154
char * installer_baseurl
URL describing where Conda will be downloaded from.
Definition delivery.h:152
char * installer_platform
Platform/OS target of installer.
Definition delivery.h:155
struct StrList * wheels_packages
Wheel packages built for delivery.
Definition delivery.h:166
struct StrList * conda_packages_purge
Conda packages to remove from a delivery (for: based_on).
Definition delivery.h:162
char * installer_name
Name of installer (Miniconda3, Miniforge3, etc).
Definition delivery.h:153
char * tool_build_version
Installed version of "build" package.
Definition delivery.h:159
struct StrList * pip_packages_purge
Python packages to remove from a delivery (for: based_on).
Definition delivery.h:165
char * tool_version
Installed version of conda.
Definition delivery.h:158
struct StrList * pip_packages
Python packages to install (pip).
Definition delivery.h:163
struct StrList * conda_packages
Conda packages to deliver.
Definition delivery.h:160
char * installer_path
Absolute path of installer on-disk.
Definition delivery.h:157
struct StrList * conda_packages_defer
Conda recipes to be built for delivery.
Definition delivery.h:161
char * installer_arch
CPU architecture target of installer.
Definition delivery.h:156
struct CondaCapabilities capabilities
Capability information.
Definition delivery.h:167
Definition delivery.h:193
Definition delivery.h:186
Definition delivery.h:183
Release information (name & datetime).
Definition delivery.h:137
time_t time_now
Time stamp for when STASIS execution started.
Definition delivery.h:142
char * time_str_epoch
String representation of Unix epoch.
Definition delivery.h:143
struct tm * time_info
Delivery time structure.
Definition delivery.h:141
char * release_name
The fully combined release string.
Definition delivery.h:138
Metadata related to the delivery.
Definition delivery.h:122
int rc
build iteration
Definition delivery.h:125
char * python
version of python to use
Definition delivery.h:126
char * name
delivery name
Definition delivery.h:123
char * codename
HST uses codenames.
Definition delivery.h:130
char * based_on
URL to previous final configuration.
Definition delivery.h:128
char * python_compact
shortened python identifier
Definition delivery.h:127
char * version
delivery version
Definition delivery.h:124
char * mission
hst, jwst, roman
Definition delivery.h:129
Definition delivery.h:204
bool enable_final
true=allow rc value replacement, false=keep rc value even if final release
Definition delivery.h:206
char * build_number_fmt
Build number format string.
Definition delivery.h:209
char * build_name_fmt
Build name format string.
Definition delivery.h:208
char * release_fmt
Release format string.
Definition delivery.h:207
Global runtime variables.
Definition delivery.h:173
RuntimeEnv * environ
Environment variables.
Definition delivery.h:174
Container for INIFILE handles.
Definition delivery.h:74
Storage paths.
Definition delivery.h:93
char * package_dir
Base path to where all packages are stored.
Definition delivery.h:101
char * tools_dir
Tools storage.
Definition delivery.h:99
char * build_recipes_dir
Path to store conda recipes.
Definition delivery.h:113
char * wheel_artifact_dir
Base path to store compiled wheel packages (Unused).
Definition delivery.h:109
char * build_sources_dir
Path to store source code.
Definition delivery.h:114
char * docker_artifact_dir
Base path to store saved docker images.
Definition delivery.h:108
char * output_dir
Base path to where all artifacts are stored.
Definition delivery.h:96
char * build_testing_dir
Path to store test data (Unused).
Definition delivery.h:115
char * conda_staging_dir
Base path to copy compiled conda packages.
Definition delivery.h:106
char * results_dir
Base path to where test results are stored.
Definition delivery.h:102
char * wheel_staging_dir
Base path to copy compiled wheel packages (Unused).
Definition delivery.h:110
char * delivery_dir
Delivery artifact output directory.
Definition delivery.h:97
char * tmpdir
Temporary storage area (within root).
Definition delivery.h:95
char * conda_staging_url
URL to access compiled conda packages.
Definition delivery.h:107
char * cfgdump_dir
Base path to where input configuration dumps are stored.
Definition delivery.h:98
char * conda_artifact_dir
Base path to store compiled conda packages.
Definition delivery.h:105
char * wheel_staging_url
URL to access compiled wheel packages (Unused).
Definition delivery.h:111
char * conda_install_prefix
Path to install Conda.
Definition delivery.h:104
char * build_dir
Base path to store source code and recipes.
Definition delivery.h:112
char * meta_dir
Base path to where metadata records are stored.
Definition delivery.h:103
char * mission_dir
Mission data storage.
Definition delivery.h:100
char * root
Top-level storage area.
Definition delivery.h:94
char * build_docker_dir
Path to store docker build script.
Definition delivery.h:116
System information.
Definition delivery.h:86
char * arch
System CPU architecture ident.
Definition delivery.h:87
char ** platform
System platform name.
Definition delivery.h:88
Definition delivery.h:177
A structure describing a full delivery object.
Definition delivery.h:70
Definition docker.h:20
A structure to describe an INI configuration file.
Definition ini.h:82
JFrog Artifactory Authentication struct.
Definition artifactory.h:11
JFrog Artifactory Upload struct.
Definition artifactory.h:25
Definition strlist.h:16
An array of tests.
Definition delivery.h:51
char * repository
Git repository of package.
Definition delivery.h:54
char * script_setup
Commands to execute before the main script.
Definition delivery.h:55
char * name
Name of package.
Definition delivery.h:52
struct StrList * repository_remove_tags
Git tags to remove (to fix duplicate commit tags).
Definition delivery.h:62
char * repository_info_ref
Git commit hash.
Definition delivery.h:60
bool disable
Toggle a test block.
Definition delivery.h:57
struct Runtime * runtime
Environment variables specific to the test context.
Definition delivery.h:63
char * repository_info_tag
Git tag (first parent).
Definition delivery.h:61
bool parallel
Toggle parallel or serial execution.
Definition delivery.h:58
char * version
Version of package.
Definition delivery.h:53
int timeout
Timeout in seconds.
Definition delivery.h:64
char * script
Commands to execute.
Definition delivery.h:56
char * build_recipe
Conda recipe to build (optional).
Definition delivery.h:59