Struct zinoma::config::yaml::schema::Project

source ·
pub struct Project {
    pub targets: HashMap<String, Target>,
    pub name: Option<String>,
    pub imports: HashMap<String, String>,
}
Expand description

Schema of the build flow configuration file zinoma.yml.

In order to use Žinoma with your project, you need to create a file named zinoma.yml. We recommend putting this file in the root directory of your project.

This struct describes the schema expected for this file. It assumes prior knowledge of the Yaml format.

Example

zinoma.yml:

targets:
  download_dependencies:
    input:
      - paths: [package.json, package-lock.json]
    output:
      - paths: [node_modules]
    build: npm install

  test:
    input:
      - download_dependencies.output
      - paths: [package.json, src, test]
    build: npm test

  lint:
    input:
      - download_dependencies.output
      - paths: [package.json, src, test]
    build: npm run lint

  check:
    dependencies: [test, lint]

  start:
    input:
      - download_dependencies.output
      - paths: [package.json, src]
    service: exec npm run start

  build:
    dependencies: [check]
    input:
      - paths:
        - Dockerfile
        - package.json
        - package-lock.json
        - src
    output:
      - paths: [lambda.zip]
    build: |
      docker build -t build-my-project:latest .
      docker create -ti --name build-my-project build-my-project:latest bash
      docker cp build-my-project:/var/task/lambda.zip ./
      docker rm -f build-my-project

In this example:

  • zinoma check will ensure the code complies to the test suites and the coding standards.
  • zinoma start --watch will run the application and restart it whenever the sources are updated.
  • zinoma --clean build will generate a clean artifact, ready to be deployed.

A fully functional and more advanced example project is available in fbecart/zinoma-node-example.

Fields§

§targets: HashMap<String, Target>

Targets (aka tasks) of this project.

Targets represent commands and scripts to execute in your build flow.

Targets run in parallel by default. To force targets to run sequentially, you can define dependencies on other targets.

Each target must have a unique name inside the project. The target name must be a string. It should start with an alphanumeric character or _ and contain only alphanumeric characters, -, or _.

Example

targets:
  speak_cow:
    build: echo 'Moo'
  speak_dog:
    build: echo 'Woof!'

In this example:

  • zinoma speak_cow will print Moo
  • zinoma speak_dog will print Woof!
  • zinoma speak_cow speak_dog will print both Moo and Woof! (not necessarily in this order)
§name: Option<String>

Name of the project.

A project name must be a string. It should start with an alphanumeric character or _ and contain only alphanumeric characters, -, or _.

Project names should be unique. Two projects cannot have the same name.

Example

name: my_project
§imports: HashMap<String, String>

Import definitions from other Žinoma projects.

imports should be an object, the keys being the project names and the values their respective paths.

Before importing a project, you should make sure this project has its name defined. You should use the same name as key in the imports object.

Once a project is imported, targets from that project can be referenced by specifying their fully qualified name: imported_project_name::target_name.

Example

packages/api/zinoma.yml:

name: api

targets:
  test:
    build: cargo test

packages/webapp/zinoma.yml:

name: webapp

targets:
  test:
    build: cargo test

./zinoma.yml:

imports:
  api: packages/api
  webapp: packages/webapp

targets:
  test_all:
    dependencies: [api::test, webapp::test]

In this example, the target test_all depend from targets defined in different projects.

Trait Implementations§

source§

impl Debug for Project

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Project

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl JsonSchema for Project

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

impl Serialize for Project

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,