6

GitHub Actions: Parallel Jobs – Example

 2 years ago
source link: https://www.shellhacks.com/github-actions-parallel-jobs-example/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

GitHub Actions: Parallel Jobs – Example

A workflow in a GitHub Actions can be optimized by splitting it into several jobs, which run in parallel by default.

Parallel jobs is a great way to improve build times and provide a faster feedback to your development & QA teams.

This note shows how to run jobs in parallel in the Github Actions.

Parallel Jobs in GitHub Actions

This is an example of a common sequential workflow:

name: Sequential App Build Workflow
on: [push]
jobs:
  sequential-build:
    runs-on: self-hosted
    steps:
      - run: |
          echo "Build Application"
          # [...]
      - run: |
          echo "Integration Testing"
          # [...]
      - run: |
          echo "Functional Testing"
          # [...]
      - run: |
          echo "Deploy Application"
          # [...]

In the GitHub Actions it will be visualized as follows:

xsequential_app_build_workflow.png.pagespeed.ic.Dp4vdenR7C.png

To optimize and speed up this workflow we can splitting it into several jobs, for example:

name: Parallel App Build Workflow
on: [push]
jobs:
  build:
    runs-on: self-hosted
    steps:
      - run: |
          echo "Build Application"
          # [...]
  integration-testing:
    needs: build
    runs-on: self-hosted
    steps:
      - run: |
          echo "Integration Testing"
          # [...]
  functional-testing:
    needs: build
    runs-on: self-hosted
    steps:
      - run: |
          echo "Functional Testing"
          # [...]
  deploy:
    needs: [integration-testing, functional-testing]
    runs-on: self-hosted
    steps:
      - run: |
          echo "Deploy Application"
          # [...]

ℹ Dependent Jobs: Use the needs keyword to define dependencies and control which jobs to run sequentially and which in parallel.

In the GitHub Actions the workflow above with the parallel jobs will be visualized as follows:

xparallel_app_build_workflow.png.pagespeed.ic.X1VC4lms0w.png

Parallel jobs execution in the GitHub Actions helps to run your jobs independently that saves a lot of time and increases productivity.

</div


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK