From 49d0c1f7fa51ced87547fd75f904a52fc6f53b90 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 14 Nov 2020 19:03:21 +0100 Subject: Add another example configuration Signed-off-by: Matthias Beyer --- examples/packages/example_3/a/pkg.toml | 17 ++++ examples/packages/example_3/b/pkg.toml | 14 ++++ examples/packages/example_3/c/pkg.toml | 14 ++++ examples/packages/example_3/config.toml | 50 +++++++++++ examples/packages/example_3/pkg.toml | 60 ++++++++++++++ examples/packages/example_3/src/schema.rs | 132 ++++++++++++++++++++++++++++++ 6 files changed, 287 insertions(+) create mode 100644 examples/packages/example_3/a/pkg.toml create mode 100644 examples/packages/example_3/b/pkg.toml create mode 100644 examples/packages/example_3/c/pkg.toml create mode 100644 examples/packages/example_3/config.toml create mode 100644 examples/packages/example_3/pkg.toml create mode 100644 examples/packages/example_3/src/schema.rs (limited to 'examples') diff --git a/examples/packages/example_3/a/pkg.toml b/examples/packages/example_3/a/pkg.toml new file mode 100644 index 0000000..64364a2 --- /dev/null +++ b/examples/packages/example_3/a/pkg.toml @@ -0,0 +1,17 @@ +name = "a" +version = "1" + +[dependencies] +runtime = ["b =2", "c =3"] + +[phases] +package.script = ''' + mkdir /outputs + echo "#BUTIDO:PHASE:package" + echo "#BUTIDO:PROGRESS:90" + + touch /outputs/a-1.pkg + + echo "#BUTIDO:PROGRESS:100" + echo "#BUTIDO:STATE:OK:finished" +''' diff --git a/examples/packages/example_3/b/pkg.toml b/examples/packages/example_3/b/pkg.toml new file mode 100644 index 0000000..f197abf --- /dev/null +++ b/examples/packages/example_3/b/pkg.toml @@ -0,0 +1,14 @@ +name = "b" +version = "2" + +[phases] +package.script = ''' + mkdir /outputs + echo "#BUTIDO:PHASE:package" + echo "#BUTIDO:PROGRESS:90" + + touch /outputs/b-2.pkg + + echo "#BUTIDO:PROGRESS:100" + echo "#BUTIDO:STATE:OK:finished" +''' diff --git a/examples/packages/example_3/c/pkg.toml b/examples/packages/example_3/c/pkg.toml new file mode 100644 index 0000000..538c576 --- /dev/null +++ b/examples/packages/example_3/c/pkg.toml @@ -0,0 +1,14 @@ +name = "c" +version = "3" + +[phases] +package.script = ''' + mkdir /outputs + echo "#BUTIDO:PHASE:package" + echo "#BUTIDO:PROGRESS:90" + + touch /outputs/c-3.pkg + + echo "#BUTIDO:PROGRESS:100" + echo "#BUTIDO:STATE:OK:finished" +''' diff --git a/examples/packages/example_3/config.toml b/examples/packages/example_3/config.toml new file mode 100644 index 0000000..73777aa --- /dev/null +++ b/examples/packages/example_3/config.toml @@ -0,0 +1,50 @@ +# Configuration file for BUTIDO for this repository + +# repository of package definitions +repository = "/tmp/example-3-repo" +releases = "/tmp/example-3-releases" +staging = "/tmp/example-3-staging" +source_cache = "/tmp/example-3-sources" +log_dir = "/tmp/example-3-logs" + +script_highlight_theme = "Solarized (dark)" + +# #### +# +# Log database configuration +# +# #### + +# The database to use +# +# Can be overridden via environment vairbale BUTIDO_DATABASE_URI or set via CLI. +database_host = "localhost" +database_port = 5432 +database_user = "pgdev" +database_password = "password" +database_name = "butido" + + +# Phases which can be configured in the packages +available_phases = [ "unpack", "depinst", "configure", "build", "install", "package" ] + +[docker] +# Images which can be used to build +# images not listed here are automatically rejected +images = [ "debian:bullseye" ] +verify_images_present = true + +# List of docker endpoints +[[docker.endpoints]] +name = "example host name" +uri = "http://0.0.0.0:8095" +endpoint_type = "http" +speed = 1 +maxjobs = 10 + + +[containers] +# environment variables which are allowed during container start +# This way, errors (typos) when passing environment to a build can be prevented +allowed_env = [ "PATH" ] + diff --git a/examples/packages/example_3/pkg.toml b/examples/packages/example_3/pkg.toml new file mode 100644 index 0000000..f844921 --- /dev/null +++ b/examples/packages/example_3/pkg.toml @@ -0,0 +1,60 @@ +version = "1" +version_is_semver = false + +# no patches by default +patches = [] + +[source] +url = "https://github.com/user/repo/archive/sources.tar.gz" +hash.type = "sha1" +hash.hash = "5e8bcaa3c758f84f01935a914e2bbf01309462ae" + +[dependencies] +system = [] +system_runtime = [] +build = [] +runtime = [] + +# Root description of phases +# can be overridden as well +[phases] + +unpack.script = ''' + mkdir /build + echo "#BUTIDO:PHASE:unpack" +''' + +# We use a depinst phase here because we don't want to add a Dockerfile to the +# repo where we prepare a build container. +# This is, of course, not be the way it would be done in a real-world scenario! +depinst.script = ''' + echo "#BUTIDO:PHASE:depinst" + echo "#BUTIDO:PROGRESS:0" + for n in {1..10}; do sleep 0.1; done + echo "#BUTIDO:PROGRESS:10" +''' + +configure.script = ''' + echo "#BUTIDO:PHASE:configure-preparing" + for n in {1..10}; do sleep 0.1; done + + echo "#BUTIDO:PROGRESS:20" + for n in {1..10}; do sleep 0.1; done +''' + +build.script = ''' + echo "#BUTIDO:PHASE:build" + + for n in {1..10}; do sleep 0.1; done + + echo "#BUTIDO:PROGRESS:60" +''' + +install.script = ''' + echo "#BUTIDO:PHASE:install" + for n in {1..10}; do sleep 0.1; done + + echo "#BUTIDO:PROGRESS:80" +''' + + diff --git a/examples/packages/example_3/src/schema.rs b/examples/packages/example_3/src/schema.rs new file mode 100644 index 0000000..aa777a6 --- /dev/null +++ b/examples/packages/example_3/src/schema.rs @@ -0,0 +1,132 @@ +table! { + artifacts (id) { + id -> Int4, + path -> Varchar, + } +} + +table! { + endpoints (id) { + id -> Int4, + name -> Varchar, + } +} + +table! { + envvars (id) { + id -> Int4, + name -> Varchar, + value -> Varchar, + } +} + +table! { + githashes (id) { + id -> Int4, + hash -> Varchar, + } +} + +table! { + images (id) { + id -> Int4, + name -> Varchar, + } +} + +table! { + job_envs (id) { + id -> Int4, + job_id -> Int4, + env_id -> Int4, + } +} + +table! { + job_input_artifacts (id) { + id -> Int4, + job_id -> Int4, + artifact_id -> Int4, + } +} + +table! { + job_output_artifacts (id) { + id -> Int4, + job_id -> Int4, + artifact_id -> Int4, + } +} + +table! { + jobs (id) { + id -> Int4, + submit_id -> Int4, + endpoint_id -> Int4, + package_id -> Int4, + image_id -> Int4, + container_hash -> Varchar, + script_text -> Text, + log_text -> Text, + uuid -> Uuid, + } +} + +table! { + packages (id) { + id -> Int4, + name -> Varchar, + version -> Varchar, + } +} + +table! { + submit_envs (id) { + id -> Int4, + submit_id -> Int4, + env_id -> Int4, + } +} + +table! { + submits (id) { + id -> Int4, + uuid -> Uuid, + submit_time -> Timestamptz, + requested_image_id -> Int4, + requested_package_id -> Int4, + repo_hash_id -> Int4, + tree -> Jsonb, + } +} + +joinable!(job_envs -> envvars (env_id)); +joinable!(job_envs -> jobs (job_id)); +joinable!(job_input_artifacts -> artifacts (artifact_id)); +joinable!(job_input_artifacts -> jobs (job_id)); +joinable!(job_output_artifacts -> artifacts (artifact_id)); +joinable!(job_output_artifacts -> jobs (job_id)); +joinable!(jobs -> endpoints (endpoint_id)); +joinable!(jobs -> images (image_id)); +joinable!(jobs -> packages (package_id)); +joinable!(jobs -> submits (submit_id)); +joinable!(submit_envs -> envvars (env_id)); +joinable!(submit_envs -> submits (submit_id)); +joinable!(submits -> githashes (repo_hash_id)); +joinable!(submits -> images (requested_image_id)); +joinable!(submits -> packages (requested_package_id)); + +allow_tables_to_appear_in_same_query!( + artifacts, + endpoints, + envvars, + githashes, + images, + job_envs, + job_input_artifacts, + job_output_artifacts, + jobs, + packages, + submit_envs, + submits, +); -- cgit v1.2.3