ferrous_actions/lib.rs
1#![warn(clippy::pedantic)]
2#![allow(
3 clippy::missing_errors_doc,
4 clippy::must_use_candidate,
5 clippy::uninlined_format_args,
6 clippy::missing_panics_doc
7)]
8#![forbid(unsafe_code)]
9
10//! This crate can be compiled so that only the node.js, and optionally also the
11//! GitHub Actions Toolkit bindings, are present. To do this, use the
12//! `default-features = false` option when depending on this crate and specify
13//! the `node_bindings` and / or `github_actions_bindings` features.
14//!
15//! This crate is versioned according to compatibility of the "Ferrous actions"
16//! action, not API compatibility. These bindings can and likely will change in
17//! breaking ways and are mainly exposed and documented to enable more insight
18//! into this crate's internals and for experimentation purposes.
19
20/// Bindings for [node.js](https://nodejs.org/docs/latest/api/)
21#[cfg(feature = "node_bindings")]
22pub mod node;
23
24/// Bindings for the [GitHub Actions Toolkit](https://github.com/actions/toolkit)
25#[cfg(feature = "github_actions_bindings")]
26pub mod actions;
27
28cfg_if::cfg_if! {
29if #[cfg(feature = "action")] {
30
31mod access_times;
32mod action_paths;
33mod agnostic_path;
34mod cache_cargo_home;
35mod cache_key_builder;
36mod cargo;
37mod cargo_hooks;
38mod cargo_lock_hashing;
39mod cross;
40mod delta;
41mod dir_tree;
42mod error;
43mod fingerprinting;
44mod hasher;
45mod input_manager;
46mod job;
47mod nonce;
48mod package_manifest;
49mod run;
50mod rustup;
51mod safe_encoding;
52mod system;
53mod toolchain;
54mod utils;
55
56use crate::cargo::Cargo;
57use crate::error::Error;
58
59/// Entry point for Ferrous Actions.
60///
61/// If you want to use the node.js or GitHub Actions Toolkit bindings, you must set
62/// `default-features = false` and enable only the bindings you want so this function
63/// is not included in the dependency.
64#[cfg(feature = "action")]
65#[wasm_bindgen::prelude::wasm_bindgen(start)]
66pub async fn start() -> Result<(), wasm_bindgen::JsValue> {
67 use crate::actions::core;
68
69 // Perhaps we need a hook that calls core::set_failed() on panic.
70 // This would make sure the action outputs an error command for
71 // the runner and returns exit code 1.
72 utils::set_panic_hook();
73
74 if let Err(e) = run::run().await {
75 core::set_failed(e.to_string());
76 }
77 Ok(())
78}
79
80}
81}