Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Latest commit

 

History

History
107 lines (74 loc) · 3.38 KB

Tasks.md

File metadata and controls

107 lines (74 loc) · 3.38 KB

Task and Workflow

The core of Puma is Task. When you call run method, it actually uses Workflow, which is a group of tasks. Workflow is intended for cases where you need to run tasks for multiple projects.

run {
    Build()
    Test()
}

is the same as

let workflow = Workflow {
    Build()
    Test()
}

workflow.run()

Task protocol

At the core of Puma sits the Task protocol, every task has a name, isEnabled flag and an action.

public typealias TaskCompletion = (Result<(), Error>) -> Void

public protocol Task: AnyObject {
    var name: String { get }
    var isEnabled: Bool { get }
    func run(workflow: Workflow, completion: @escaping TaskCompletion)
}

The workflow parameter in run function acts as the context for all the tasks. When a task completes, you need to invoke completion so workflow know when to execute the next task in the pipeline.

Disable a task

Some times you want to temporarily disable a task, every task in Puma needs to conform to Task protocol, and there is a modifier enable(_:) where you can toggle on/off a task

Build()
    .enable(false)

Change name of a task

Every task has a default name, and this name is used when summarizing, to change the name of a task, assign a different name using the name(_:) modifier

Build()
    .name("Build my awesome app")

A bunch of tasks

Puma comes with a bunch of predefined tasks for popular actions, and they are sat in respective framework.

Puma

The facade, which exposes convenient run function, and includes other frameworks

PumaCore

Contains the core utilities, Task protocol and some core tasks

PumaiOS

Contains iOS related tasks.

  • Build: build workspace or project
  • Test: test workspace or project
  • Archive: archive to xcarchive
  • ExportArchive: export archive into .ipa
  • Screenshot: automate screenshot capturing, you can specify device, sdk, version, language and locale. It also supports test plan in Xcode 11
  • UploadApp: upload, notarize, validate app with AppStore
  • ShowDestinations: show all available destinations when building and testing
  • BootSimulator: boot simulator
  • UpdateSimulator: update statusbar of simulator. This is nifty before taking screenshots
  • DownloadMetadata: download metadata from AppStore Connect

PumaAndroid

Contains Android related tasks. TBD

PumaExtra

Contains extra tasks

  • AppStoreConnect: interact with AppStore Connect
  • AppDistribution: interact with Firebase AppDistribution
  • Crashlytics: interact with Firebase Crashlytics

A bunch of tasks