Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: refactor into libraries. add join flag. support multiple pr jobs #2

Merged
merged 1 commit into from
Oct 12, 2017

Conversation

petey
Copy link
Contributor

@petey petey commented Oct 11, 2017

Context:

Planning ahead to add workflow cycle detection, but wanted to get api changes out sooner.

Objective:

  • Mark edges that are part of a join with a flag in the edge node.
  • Add node objects for ~commit and ~pr events
  • BREAKING CHANGE: changed signature of the all methods to be more consistent.

/**
* Calculate the next jobs to execute, given a workflow and a trigger job
* @method getNextJobs
* @param {Object} workflow Directed graph representation of workflow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this variable to workflowGraph so we don't get it mixed up with the old concept of workflow?

workflow.edges.forEach((edge) => {
if (edge.src === obj.trigger) {
// Make PR jobs PR-$num:$cloneJob (not sure how to better handle multiple PR jobs)
jobs.add(obj.trigger === '~pr' ? `PR-${obj.prNum}:${edge.dest}` : edge.dest);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're going with PR-${obj.prNum}-${edge.dest}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use : cuz jobName can actually contains/start with -.

if (useLegacy && !hasRequiresConfig) {
// Work out whether there is a user defined workflow,
// or if we use the order of jobs defined in jobConfig
const workflow = Array.isArray(pipelineConfig.workflow) ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it goes through the config parser, if will add main to the workflow. And workflow saved in the pipeline will always have that main job in workflow.
https://api.screwdriver.cd/v4/pipelines

Can we have some check for pipelineConfig.workflow? If it has main then take it out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@petey petey changed the title feat: refactor into libraries. add join flag. support multiple pr jobs BREAKING CHANGE: refactor into libraries. add join flag. support multiple pr jobs Oct 12, 2017
README.md Outdated
const { getWorkflow, getNextJobs } = require('screwdriver-workflow-parser');

// Calculate the directed graph workflow from a pipeline config (and parse legacy workflows)
const workflowGraph = getWorkflow({ config: pipelineConfig, useLegacy: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update examples here

* @param {String} [obj.prNum] The PR number (required when ~pr trigger)
* @return {Array} List of job names
*/
const getNextJobs = (workflowGraph, obj) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want to use "config" to be consistent

/**
* Given a pipeline config, return a directed graph configuration that describes the workflow
* @method getWorkflow
* @param {Object} pipeline A Pipeline Config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update JSdocs to match new arg name (pipelineConfig)

BREAKING CHANGE: altered the signature for getWorkflow, getNextJobs
Copy link
Member

@tkyi tkyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@tkyi tkyi merged commit 5545b06 into master Oct 12, 2017
@tkyi tkyi deleted the refactor branch October 12, 2017 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants