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
14#define DELIVERY_PLATFORM_MAX 4
15#define DELIVERY_PLATFORM_MAXLEN 65
16#define DELIVERY_PLATFORM 0
17#define DELIVERY_PLATFORM_CONDA_SUBDIR 1
18#define DELIVERY_PLATFORM_CONDA_INSTALLER 2
19#define DELIVERY_PLATFORM_RELEASE 3
20
21#define DELIVERY_REWRITE_SPEC_STAGE_1 0
22#define DELIVERY_REWRITE_SPEC_STAGE_2 1
23
24#define INSTALL_PKG_CONDA 1 << 1
25#define INSTALL_PKG_CONDA_DEFERRED 1 << 2
26#define INSTALL_PKG_PIP 1 << 3
27#define INSTALL_PKG_PIP_DEFERRED 1 << 4
28
29#define DEFER_CONDA 0
30#define DEFER_PIP 1
31
32struct Content {
33 unsigned type;
34 char *filename;
35 char *data;
36};
37
39#define TEST_NUM_ALLOC_INITIAL 10
40
59
63struct Delivery {
68 struct INIFILE *delivery;
69 struct INIFILE *cfg;
70 struct INIFILE *mission;
71 char *delivery_path;
72 char *cfg_path;
73 char *mission_path;
74 } _stasis_ini_fp;
75
79 struct System {
80 char *arch;
81 char **platform;
82 } system;
83
111
115 struct Meta {
116 char *name;
117 char *version;
118 int rc;
119 char *python;
121 char *based_on;
122 char *mission;
123 char *codename;
124 bool final;
125 } meta;
126
130 struct Info {
132 char *build_name;
133 char *build_number;
134 struct tm *time_info;
135 time_t time_now;
137 } info;
138
161
165 struct Runtime {
166 RuntimeEnv *environ;
167 } runtime;
168
169 struct Tests {
170 struct Test **test;
171 size_t num_used;
172 size_t num_alloc;
173 } *tests;
174
175 struct Deploy {
176 struct JFRT_Auth jfrog_auth;
177
178 struct JFrog {
179 struct StrList *files;
180 struct JFRT_Upload upload_ctx;
181 char *repo;
182 char *dest;
183 } jfrog[1000];
184
185 struct Docker {
186 struct DockerCapabilities capabilities;
187 char *image_compression;
188 char *dockerfile;
189 char *registry;
190 char *test_script;
191 struct StrList *build_args;
192 struct StrList *tags;
193 } docker;
194 } deploy;
195
196 struct Rule {
197 struct INIFILE *_handle;
202 struct Content content[1000];
203 } rules;
204};
205
213int delivery_init(struct Delivery *ctx, int render_mode);
214
219void delivery_free(struct Delivery *ctx);
220
225void delivery_meta_show(struct Delivery *ctx);
226
231void delivery_conda_show(struct Delivery *ctx);
232
237void delivery_tests_show(struct Delivery *ctx);
238
243void delivery_runtime_show(struct Delivery *ctx);
244
251int delivery_build_recipes(struct Delivery *ctx);
252
259struct StrList *delivery_build_wheels(struct Delivery *ctx);
260
268
275char *delivery_get_release_header(struct Delivery *ctx);
276
284void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage);
285
293
301
307int delivery_get_conda_installer(struct Delivery *ctx, char *installer_url);
308
316void delivery_get_conda_installer_url(struct Delivery *ctx, char *result, size_t maxlen);
317
329int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, char *env_name, int type, struct StrList *manifest[]);
330
338
343void delivery_tests_run(struct Delivery *ctx);
344
352void delivery_defer_packages(struct Delivery *ctx, int type);
353
359void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir);
360
366void delivery_install_conda(char *install_script, char *conda_install_dir);
367
391int delivery_format_str(struct Delivery *ctx, char **dest, size_t maxlen, const char *fmt);
392
393// helper function
394int delivery_gather_tool_versions(struct Delivery *ctx);
395
396// helper function
397int delivery_init_tmpdir(struct Delivery *ctx);
398
399void delivery_init_dirs_stage1(struct Delivery *ctx);
400
401void delivery_init_dirs_stage2(struct Delivery *ctx);
402
403int delivery_init_platform(struct Delivery *ctx);
404
405int delivery_init_artifactory(struct Delivery *ctx);
406
407int delivery_artifact_upload(struct Delivery *ctx);
408
409int delivery_mission_render_files(struct Delivery *ctx);
410
411int delivery_docker(struct Delivery *ctx);
412
413int delivery_fixup_test_results(struct Delivery *ctx);
414
415int bootstrap_build_info(struct Delivery *ctx);
416
417int delivery_dump_metadata(struct Delivery *ctx);
418
419int populate_info(struct Delivery *ctx);
420
421int populate_delivery_cfg(struct Delivery *ctx, int render_mode);
422
423int populate_delivery_ini(struct Delivery *ctx, int render_mode);
424
425int populate_mission_ini(struct Delivery **ctx, int render_mode);
426
427void validate_delivery_ini(struct INIFILE *ini);
428
429int filter_repo_tags(char *repo, struct StrList *patterns);
430
431#define DELIVERY_NOT_FOUND 0
432#define DELIVERY_FOUND 1
438int delivery_exists(struct Delivery *ctx);
439
440int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_name);
441
450int delivery_conda_enforce_package_version(struct Delivery *ctx, const char *env_name, const char *name);
451
459int delivery_series_sync(struct Delivery *ctx);
460
471int delivery_purge_packages(struct Delivery *ctx, const char *env_name, int use_pkg_manager);
472
479void delivery_export(const struct Delivery *ctx, char *envs[]);
480
487void delivery_rewrite_stage1(struct Delivery *ctx, char *specfile);
488
495void delivery_rewrite_stage2(struct Delivery *ctx, char *specfile);
496
502struct Delivery *delivery_duplicate(struct Delivery *ctx);
503
509struct Tests *tests_init(size_t num_tests);
510
517int tests_add(struct Tests *tests, struct Test *x);
518
523void test_free(struct Test **x);
524
529void tests_free(struct Tests **x);
530
535struct Test *test_init();
536
537
538#endif //STASIS_DELIVERY_H
struct Delivery * delivery_duplicate(struct Delivery *ctx)
Definition delivery.c:4
void delivery_runtime_show(struct Delivery *ctx)
Definition delivery_show.c:97
void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir)
Definition delivery_conda.c:106
int delivery_copy_conda_artifacts(struct Delivery *ctx)
Definition delivery_postprocess.c:180
int delivery_exists(struct Delivery *ctx)
Definition delivery_init.c:400
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:140
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:279
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:198
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:293
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:293
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
struct StrList * delivery_build_wheels(struct Delivery *ctx)
Definition delivery_build.c:371
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:357
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
Definition delivery.h:32
Conda configuration.
Definition delivery.h:144
struct StrList * pip_packages_defer
Python packages to be built for delivery.
Definition delivery.h:157
char * installer_version
Version of installer.
Definition delivery.h:147
char * installer_baseurl
URL describing where Conda will be downloaded from.
Definition delivery.h:145
char * installer_platform
Platform/OS target of installer.
Definition delivery.h:148
struct StrList * wheels_packages
Wheel packages built for delivery.
Definition delivery.h:159
struct StrList * conda_packages_purge
Conda packages to remove from a delivery (for: based_on)
Definition delivery.h:155
char * installer_name
Name of installer (Miniconda3, Miniforge3, etc)
Definition delivery.h:146
char * tool_build_version
Installed version of "build" package.
Definition delivery.h:152
struct StrList * pip_packages_purge
Python packages to remove from a delivery (for: based_on)
Definition delivery.h:158
char * tool_version
Installed version of conda.
Definition delivery.h:151
struct StrList * pip_packages
Python packages to install (pip)
Definition delivery.h:156
struct StrList * conda_packages
Conda packages to deliver.
Definition delivery.h:153
char * installer_path
Absolute path of installer on-disk.
Definition delivery.h:150
struct StrList * conda_packages_defer
Conda recipes to be built for delivery.
Definition delivery.h:154
char * installer_arch
CPU architecture target of installer.
Definition delivery.h:149
Definition delivery.h:185
Definition delivery.h:178
Definition delivery.h:175
Release information (name & datetime)
Definition delivery.h:130
time_t time_now
Time stamp for when STASIS execution started.
Definition delivery.h:135
char * time_str_epoch
String representation of Unix epoch.
Definition delivery.h:136
struct tm * time_info
Delivery time structure.
Definition delivery.h:134
char * release_name
The fully combined release string.
Definition delivery.h:131
Metadata related to the delivery.
Definition delivery.h:115
int rc
build iteration
Definition delivery.h:118
char * python
version of python to use
Definition delivery.h:119
char * name
delivery name
Definition delivery.h:116
char * codename
HST uses codenames.
Definition delivery.h:123
char * based_on
URL to previous final configuration.
Definition delivery.h:121
char * python_compact
shortened python identifier
Definition delivery.h:120
char * version
delivery version
Definition delivery.h:117
char * mission
hst, jwst, roman
Definition delivery.h:122
Definition delivery.h:196
bool enable_final
true=allow rc value replacement, false=keep rc value even if final release
Definition delivery.h:198
char * build_number_fmt
Build number format string.
Definition delivery.h:201
char * build_name_fmt
Build name format string.
Definition delivery.h:200
char * release_fmt
Release format string.
Definition delivery.h:199
Global runtime variables.
Definition delivery.h:165
RuntimeEnv * environ
Environment variables.
Definition delivery.h:166
Container for INIFILE handles.
Definition delivery.h:67
Storage paths.
Definition delivery.h:86
char * package_dir
Base path to where all packages are stored.
Definition delivery.h:94
char * tools_dir
Tools storage.
Definition delivery.h:92
char * build_recipes_dir
Path to store conda recipes.
Definition delivery.h:106
char * wheel_artifact_dir
Base path to store compiled wheel packages (Unused)
Definition delivery.h:102
char * build_sources_dir
Path to store source code.
Definition delivery.h:107
char * docker_artifact_dir
Base path to store saved docker images.
Definition delivery.h:101
char * output_dir
Base path to where all artifacts are stored.
Definition delivery.h:89
char * build_testing_dir
Path to store test data (Unused)
Definition delivery.h:108
char * conda_staging_dir
Base path to copy compiled conda packages.
Definition delivery.h:99
char * results_dir
Base path to where test results are stored.
Definition delivery.h:95
char * wheel_staging_dir
Base path to copy compiled wheel packages (Unused)
Definition delivery.h:103
char * delivery_dir
Delivery artifact output directory.
Definition delivery.h:90
char * tmpdir
Temporary storage area (within root)
Definition delivery.h:88
char * conda_staging_url
URL to access compiled conda packages.
Definition delivery.h:100
char * cfgdump_dir
Base path to where input configuration dumps are stored.
Definition delivery.h:91
char * conda_artifact_dir
Base path to store compiled conda packages.
Definition delivery.h:98
char * wheel_staging_url
URL to access compiled wheel packages (Unused)
Definition delivery.h:104
char * conda_install_prefix
Path to install Conda.
Definition delivery.h:97
char * build_dir
Base path to store source code and recipes.
Definition delivery.h:105
char * meta_dir
Base path to where metadata records are stored.
Definition delivery.h:96
char * mission_dir
Mission data storage.
Definition delivery.h:93
char * root
Top-level storage area.
Definition delivery.h:87
char * build_docker_dir
Path to store docker build script.
Definition delivery.h:109
System information.
Definition delivery.h:79
char * arch
System CPU architecture ident.
Definition delivery.h:80
char ** platform
System platform name.
Definition delivery.h:81
Definition delivery.h:169
A structure describing a full delivery object.
Definition delivery.h:63
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:44
char * repository
Git repository of package.
Definition delivery.h:47
char * script_setup
Commands to execute before the main script.
Definition delivery.h:48
char * name
Name of package.
Definition delivery.h:45
struct StrList * repository_remove_tags
Git tags to remove (to fix duplicate commit tags)
Definition delivery.h:55
char * repository_info_ref
Git commit hash.
Definition delivery.h:53
bool disable
Toggle a test block.
Definition delivery.h:50
struct Runtime * runtime
Environment variables specific to the test context.
Definition delivery.h:56
char * repository_info_tag
Git tag (first parent)
Definition delivery.h:54
bool parallel
Toggle parallel or serial execution.
Definition delivery.h:51
char * version
Version of package.
Definition delivery.h:46
int timeout
Timeout in seconds.
Definition delivery.h:57
char * script
Commands to execute.
Definition delivery.h:49
char * build_recipe
Conda recipe to build (optional)
Definition delivery.h:52