App-Actions

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

them.  Commands, environment variables and secrets are passed to Docker as
bytes (UTF-8 for text from the workflow).  What the containers print is
passed through to your terminal unchanged.  Messages from this module are
in English unless `ACTION_RUN_LANG` chooses French (`fr`), German
(`de`) or Chinese (`zh`); those are character strings, so the terminal
should use UTF-8.  Settings in configuration files and `App__Actions__*`
environment variables are used as [Config::Abstraction](https://metacpan.org/pod/Config%3A%3AAbstraction) reads them; keep
option values there in ASCII.

## See Also

- [Configure an Object at Runtime](https://metacpan.org/pod/Object%3A%3AConfigure), which ["new"](#new)
uses to read configuration files and environment variables
- [Config::Abstraction](https://metacpan.org/pod/Config%3A%3AAbstraction), which finds and reads those files
- [Test Dashboard](https://nigelhorne.github.io/App-Actions/coverage/)

## Author

Nigel Horne, `<njh at nigelhorne.com>`

## Formal Specification

This section describes each routine in the Z notation, a precise
mathematical language for describing programs.  You do not need to read it
to use the module: everything here is also said in plain words in the
sections above.  It is for readers who want to check exactly what a routine
promises.

How to read it: a box names a routine.  The lines above the middle rule
declare the values it works with.  A name ending in `?` is an input, and a
name ending in `!` is an output.  `ΞState` means the routine changes
nothing, and `ΔState` means it can change the state.  The lines below the
rule are the conditions that are always true when the routine returns.

### New

```
    ┌─ New ─────────────────────────────────────────────
    │ ΞFileSystem
    │ workflowFile? : optional PATH
    │ projectDir?   : optional PATH
    │ options?      : OPTION ⇸ VALUE
    │ actions!      : Actions
    ├───────────────────────────────────────────────────
    │ dom options? ⊆ RUNNER_OPTIONS
    │ let settings == (args? ⊕ fileConfig(App__Actions)) ⊕ envConfig(App__Actions__)
    │     where args? == options? ∪ {workflow_file ↦ workflowFile?, project_dir ↦ projectDir?}
    │     -- dom fileConfig and dom envConfig are not checked against RUNNER_OPTIONS
    │ workflowFile? = ⊥ ⇒ raises WorkflowFileRequired
    │ abs(workflowFile?) ∉ regularFiles ⇒ raises WorkflowFileMissing
    │ projectDir? = ⊥ ∧ abs(workflowFile?) ∉ (PATH ⁀ "/.github/workflows/" ⁀ NAME)
    │     ⇒ raises ProjectDirRequired
    │ let root == (projectDir? ≠ ⊥ ⇒ abs(projectDir?))
    │             ∧ (projectDir? = ⊥ ⇒ repository(abs(workflowFile?)))
    │ root ∉ directories ⇒ raises ProjectDirMissing
    │ actions!.workflow = Workflow.Load(abs(workflowFile?))
    │ actions!.project_dir = root
    │ actions!.options = settings
    │ let logged == (logger? ≠ ⊥ ⇒ logger?)
    │             ∧ (logger? = ⊥ ∧ logger ∈ dom configured ⇒ configured(logger))
    │             ∧ (logger? = ⊥ ∧ logger ∉ dom configured ⇒ stderrLogger)
    │     where configured == fileConfig(App__Actions) ⊕ envConfig(App__Actions__)
    │     -- fileConfig includes the UNIVERSAL section of universal.yaml
    │ actions!.logger ∈ LogAbstraction
    │ logged = NULL ⇒ actions!.logger = silentLogger
    │ logged ≠ NULL ⇒ actions!.logger = toLogger(logged)
    └───────────────────────────────────────────────────

    The workflowFile? and projectDir? above are the values in settings, so a
    configuration file or environment variable can replace them too.
```

### Workflow, Workflow\_File, Project\_Dir

```
    ┌─ Accessor ────────────────────────────────────────
    │ ΞActions
    │ field? : {workflow, workflow_file, project_dir}
    │ value! : VALUE
    ├───────────────────────────────────────────────────
    │ value! = θActions.field?
    └───────────────────────────────────────────────────
```

### Run

```
    ┌─ Run ─────────────────────────────────────────────
    │ ΞActions
    │ overrides? : OPTION ⇸ VALUE
    │ exit!      : {0, 1, 2}
    ├───────────────────────────────────────────────────
    │ dom overrides? ⊆ RUNNER_OPTIONS
    │ exit! = Runner.Run(options ⊕ overrides?)
    └───────────────────────────────────────────────────
```

### Preflight

```
    ┌─ Preflight ───────────────────────────────────────
    │ ΞActions
    │ overrides? : OPTION ⇸ VALUE
    │ json?      : optional BOOLEAN
    │ result!    : Result
    ├───────────────────────────────────────────────────
    │ dom overrides? ⊆ RUNNER_OPTIONS
    │ result! = Runner.Preflight(options ⊕ overrides?, json?)
    │ result!.exit ∈ {0, 2}
    │ json? ⇒ valid(result!.summary, PreflightSchema)
    └───────────────────────────────────────────────────
```

### Json\_Schema

```
    DOCUMENT ::= check | preflight | cache | logs

    ┌─ JsonSchema ──────────────────────────────────────
    │ name?   : optional STRING
    │ schema! : KEY ⇸ VALUE



( run in 0.607 second using v1.01-cache-2.11-cpan-60884a8df76 )