Have ideas to improve npm?Join in the discussion! »

    screwdriver-workflow-parser

    3.1.3 • Public • Published

    Workflow Parser

    Version Downloads Build Status Open Issues License

    Parses and converts pipeline configuration into a workflow graph

    Usage

    npm install screwdriver-workflow-parser
    const { getWorkflow, getNextJobs, hasCycle } = require('screwdriver-workflow-parser');
    
    // Calculate the directed graph workflow from a pipeline config (and parse legacy workflows)
    const workflowGraph = getWorkflow(pipelineConfig, { useLegacy: true });
    
    /* 
    { 
        nodes: [{ name: '~pr'}, { name: '~commit'}, { name: 'main' }], 
        edges: [{ src: '~pr', dest: 'main'}, { src: '~commit', dest: 'main'}] 
    }
    */
    
    // Get a list of job names to start as a result of a commit event, e.g. [ 'a', 'b' ]
    const commitJobsToTrigger = getNextJobs(workflowGraph, { trigger: '~commit' });
    
    // Get a list of job names to start as a result of a pull-request event, e.g. [ 'PR-123:a' ]
    const prJobsToTrigger = getNextJobs(workflowGraph, { trigger: '~pr', prNum: 123 });
    
    // Check to see if a given workflow graph has a loop in it. A -> B -> A
    if (hasCycle(workflowGraph)) {
        console.error('Graph contains a loop.');
    }
    

    Testing

    npm test

    License

    Code licensed under the BSD 3-Clause license. See LICENSE file for terms.

    Install

    npm i screwdriver-workflow-parser

    DownloadsWeekly Downloads

    44

    Version

    3.1.3

    License

    BSD-3-Clause

    Unpacked Size

    22.3 kB

    Total Files

    12

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar