A check for whether the dependency jobs are all green.

Overview

alls-green

A check for whether the dependency jobs are all green.

Why?

Do you have more than one job in your GitHub Actions CI/CD workflows setup? Do you use branch protection? Are you annoyed that you have to manually update the required checks in the repository settings hoping that you don't forget something on each improvement of the test matrix structure?

Yeah.. me too! But there's a solution β€” you can make a single check job listing all of the other jobs in its needs list. How about that? 🀯 Now you can add only that single job to your branch protection settings and you won't have to maintain that list manually anymore.

Right..? Wrong πŸ™ β€” apparently, in case when something fails, the check job's result is set to skipped and not failed as one would expect. This is problematic and requires extra work to get it right. Some of it is iteration over the needed jobs and checking that all their results are set to success but it's no fun to maintain this sort of thing in many different repositories. Also, it is mandatory to make the check job run always, not only when all of the needed jobs succeed.

This is why I decided to make this action to simplify the maintenance.

--@webknjaz

:wq

Usage

To use the action add a check job to your workflow file (e.g. .github/workflows/ci-cd.yml) following the example below:

---
on:
  pull_request:
  push:

jobs:
  build:
    ...

  docs:
    ...

  linters:
    ...

  package-linters:
    needs:
    - build
    ...

  tests:
    needs:
    - build
    ...

  check:
    if: always()

    needs:
    - docs
    - linters
    - package-linters
    - tests

    runs-on: Ubuntu-latest

    steps:
    - name: Decide whether the needed jobs succeeded or failed
      uses: re-actors/[email protected]/v1
      with:
        allowed-failures: docs, linters
        allowed-skips: non-voting-flaky-job
        jobs: ${{ toJSON(needs) }}
...

Options

There are three options β€” allowed-failures, allowed-skips and jobs. The first two are optional but jobs is mandatory. allowed-failures tells the action which jobs should not affect the outcome if they don't succeed, by default all the jobs will be "voting". Same goes for allowed-skips β€” it won't allow the listed jobs to affect the outcome if they are skipped but are still "voting" in case they run. jobs is an object representing the jobs that should affect the decision of whether the pipeline failed or not, it is important to pass a JSON-serialized needs context to this argument.

Important: For this to work properly, it is a must to have the job always run, otherwise GitHub will make it skipped when any of the dependencies fail. In some contexts, skipped is interpreted as success which may lead to undersired, unobvious and even dangerous (as in security breach "dangerous") side-effects.

Whose idea is this?

My inspiration came from Zuul β€” a project gating system that practices having one "check-gate" that depends on multiple individual checks. Later when I started implementing this practice across the projects that I maintain, I discovered that I was not the only one who got the same idea @graingert posted a similar solution on the GitHub Community Forum. At some point I noticed that GitHub's auto-merge merges Dependabot PRs that are broken despite having branch protection enabled in the aiohttp repository, it wasn't obvious why. I stumbled on the solution accidentally, it was implemented in the PyCA/cryptography repository β€” the credit for that goes to @reaperhulk. He listed all of the needed jobs manually in the check. With those findings I've spent some time on experimentation and composing a more generic solution β€” this is how this GitHub Action came to be.

License

The contents of this project is released under the BSD 3-clause license.

Comments
  • Cancelled jobs result in a failure being reported

    Cancelled jobs result in a failure being reported

    https://github.com/pypa/pip/actions/runs/3210435710

    This triggers a notification if the jobs were auto-cancelled, for example due to concurrency protections.

    question wontfix 
    opened by pradyunsg 8
  • [TODO] Implement `allow-skips`

    [TODO] Implement `allow-skips`

    This has been suggested by @pradyunsg.

    Use-case: workflows that run jobs conditionally, depending on the files changed in associated PRs, for example β€” https://github.com/pypa/pip/blob/bbc7021/.github/workflows/ci.yml#L29-L49, using a change detection action like dorny/paths-filter.

    enhancement good first issue 
    opened by webknjaz 5
  • Deprecation warnings due to set-output

    Deprecation warnings due to set-output

    GitHub has deprecated the set-output way, so I'm getting warnings in my workflows from alls-green.

    Since they provided zero guidance how to fix it, I've written it down myself: https://hynek.me/til/set-output-deprecation-github-actions/

    tldr: echo "::set-output name=KEY::VALUE" β†’ echo "KEY=VALUE" >>$GITHUB_OUTPUT

    enhancement 
    opened by hynek 4
  • matrix job use case not covered or exemplified

    matrix job use case not covered or exemplified

    Apparently the current implementation does not count for matrix usage, thus not allowing you to ignore failure of one of matrix jobs.

    Sadly GHA unfortunate naming makes it harder to even refer to individual job run as from the human point of view each entry inside checks is a job. But from GHA workflow definition that is not exactly the same thing as matrix job-definitions get expanded into multiple job-runs with potential different names.

    How can we mark one particular matrix dimension as allowed to fail while still ensuring the the summarizing final "check" job does not fail?

    Most projects will avoid using different definitions for each job-run and use matrix for them, as that prevents repeating a huge number of tasks. Thus we do need a practical solution for allowing one matrix-entry to fail.

    documentation good first issue question 
    opened by ssbarnea 3
  • SyntaxError in normalize_needed_jobs_status.py

    SyntaxError in normalize_needed_jobs_status.py

    Hi This is how I added your action to my workflow:

    check:
        if: always()
        runs-on: [self-hosted]
        needs:
        - dev_build_int_tests
    
        steps:
        - name: Decide whether the needed jobs succeeded or failed
          uses: re-actors/a[email protected]
          with:
            jobs: ${{ toJSON(needs) }}
    

    And I got this error:

    Traceback (most recent call last):
     File "/usr/lib/python2.7/runpy.py", line 163, in _run_module_as_main
       mod_name, _Error)
     File "/usr/lib/python2.7/runpy.py", line 119, in _get_module_details
       code = loader.get_code(mod_name)
     File "/usr/lib/python2.7/pkgutil.py", line 281, in get_code
       self.code = compile(source, self.filename, 'exec')
     File "/opt/actions-runner/_work/_actions/re-actors/alls-green/v1.2.2/src/normalize_needed_jobs_status.py", line 29
       write_lines_to_streams((f'{name}={value}',), (outputs_file,))
                                               ^
    SyntaxError: invalid syntax
    Error: Process completed with exit code 1.
    

    Could you help me to fix it, please.

    opened by BuddyGlas 2
  • Include

    Include "Cancelled" in Skipped Statuses

    Jobs can be cancelled externally, either manually or automatically with an action. Cancelled jobs fall into the "failure" state of this action, and since they are not explicit failures they should be considered as "skipped" in the same way that jobs which are automatically skipped are.

    opened by tubbo 2
  • The execution status still green

    The execution status still green

    Sorry, maybe I don't understand how this action should work, but I added the check to my workflow, but I didn't get the expected result. Why is the execution status (number 1 in the screenshot) still green?

      check:
        if: always()
        runs-on: [self-hosted]
        needs:
        - dev_build_int_tests
    
        steps:
        - name: Install python3
          uses: actions/[email protected]
          with:
            python-version: '3.10'
    
        - name: Decide whether the needed jobs succeeded or failed
          uses: re-actors/a[email protected]
          with:
            jobs: ${{ toJSON(needs) }}
    

    2022-11-29_14-57

    opened by BuddyGlas 1
  • Requiring all jobs pass? (with a wildcard or some equivalent)

    Requiring all jobs pass? (with a wildcard or some equivalent)

    First of all, love the idea of this action, thanks for maintaining it.

    I was thinking about adopting this for https://github.com/di/pip-api/blob/master/.github/workflows/test.yml which has a somewhat complex (and long) matrix workflow. But based on the example in the readme and discussion in #5, it looks like I need to explicitly list all the jobs by name with needs:, and since the list of jobs is autogenerated, very long and changes frequently, I don't want to do this. Is there any workaround?

    Thanks!

    question 
    opened by di 0
Releases(v1.2.2)
  • v1.2.2(Oct 14, 2022)

    What's Changed

    Only the internals of the action have been updated to produce job step outputs through environment files^1. No UX changes were made. Additionally, the README has been improved to show how to allow individual matrix-defined jobs to fail and the outputs the action produces have been documented.

    Full Diff: https://github.com/re-actors/alls-green/compare/v1.2.1...v1.2.2

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Sep 29, 2022)

    Bugfixes

    This release started processing trailing commas causing empty elements in allowed-failures and allowed-skips`.

    Full Diff: https://github.com/re-actors/alls-green/compare/v1.2.0...v1.2.1

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Sep 24, 2022)

    What's New

    This release implements posting check details as a summary on the workflow overview page.

    Full Diff: https://github.com/re-actors/alls-green/compare/v1.1.0...v1.2.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Dec 14, 2021)

  • v1.0.2(Dec 14, 2021)

    This is a patch release that includes bits of refactoring of the inline Python code block into its own module file and clarifications in the input descriptions.

    Source code(tar.gz)
    Source code(zip)
Owner
Re:actors
It's a home for GitHub Actions created by @webknjaz which react to the repository events. Research purposes, currently.
Re:actors
πŸ‘¨β€πŸ’» run nanosaur in simulation with Gazebo/Ingnition

πŸ¦• πŸ‘¨β€πŸ’» nanosaur_gazebo nanosaur The smallest NVIDIA Jetson dinosaur robot, open-source, fully 3D printable, based on ROS2 & Isaac ROS. Designed & ma

nanosaur 9 Jul 19, 2022
Empowering journalists and whistleblowers

Onymochat Empowering journalists and whistleblowers Onymochat is an end-to-end encrypted, decentralized, anonymous chat application. You can also host

Samrat Dutta 19 Sep 02, 2022
Official implementation of our neural-network-based fast diffuse room impulse response generator (FAST-RIR)

This is the official implementation of our neural-network-based fast diffuse room impulse response generator (FAST-RIR) for generating room impulse responses (RIRs) for a given acoustic environment.

12 Jan 13, 2022
This project uses ViT to perform image classification tasks on DATA set CIFAR10.

Vision-Transformer-Multiprocess-DistributedDataParallel-Apex Introduction This project uses ViT to perform image classification tasks on DATA set CIFA

Kaicheng Yang 3 Jun 03, 2022
NAVER BoostCamp Final Project

CV 14μ‘° final project Super Resolution and Deblur module Inference code & Pretrained weight Repo SwinIR Deblur μ‹€ν–‰ 방법 streamlit run WebServer/Server_SRD

JiSeong Kim 5 Sep 06, 2022
Official implementation of "Learning to Discover Cross-Domain Relations with Generative Adversarial Networks"

DiscoGAN Official PyTorch implementation of Learning to Discover Cross-Domain Relations with Generative Adversarial Networks. Prerequisites Python 2.7

SK T-Brain 754 Dec 29, 2022
Repository for XLM-T, a framework for evaluating multilingual language models on Twitter data

This is the XLM-T repository, which includes data, code and pre-trained multilingual language models for Twitter. XLM-T - A Multilingual Language Mode

Cardiff NLP 112 Dec 27, 2022
Stochastic gradient descent with model building

Stochastic Model Building (SMB) This repository includes a new fast and robust stochastic optimization algorithm for training deep learning models. Th

S. Ilker Birbil 22 Jan 19, 2022
A GridMixup augmentation, inspired by GridMask and CutMix

GridMixup A GridMixup augmentation, inspired by GridMask and CutMix Easy install pip install git+https://github.com/IlyaDobrynin/GridMixup.git Overvie

IlyaDo 42 Dec 28, 2022
An Unsupervised Detection Framework for Chinese Jargons in the Darknet

An Unsupervised Detection Framework for Chinese Jargons in the Darknet This repo is the Python 3 implementation of γ€ŠAn Unsupervised Detection Framewor

7 Nov 08, 2022
RADIal is available now! Check the download section

Latest news: RADIal is available now! Check the download section. However, because we are currently working on the data anonymization, we provide for

valeo.ai 55 Jan 03, 2023
Everything you want about DP-Based Federated Learning, including Papers and Code. (Mechanism: Laplace or Gaussian, Dataset: femnist, shakespeare, mnist, cifar-10 and fashion-mnist. )

Differential Privacy (DP) Based Federated Learning (FL) Everything about DP-based FL you need is here. οΌˆζ‰€ζœ‰δ½ ιœ€θ¦ηš„DP-based FLηš„δΏ‘ζ―ιƒ½εœ¨θΏ™ι‡ŒοΌ‰ Code Tip: the code o

wenzhu 83 Dec 24, 2022
Code for "ShineOn: Illuminating Design Choices for Practical Video-based Virtual Clothing Try-on", accepted at WACV 2021 Generation of Human Behavior Workshop.

ShineOn: Illuminating Design Choices for Practical Video-based Virtual Clothing Try-on [ Paper ] [ Project Page ] This repository contains the code fo

Andrew Jong 97 Dec 13, 2022
PyAF is an Open Source Python library for Automatic Time Series Forecasting built on top of popular pydata modules.

PyAF (Python Automatic Forecasting) PyAF is an Open Source Python library for Automatic Forecasting built on top of popular data science python module

CARME Antoine 405 Jan 02, 2023
MSG-Transformer: Exchanging Local Spatial Information by Manipulating Messenger Tokens

MSG-Transformer Official implementation of the paper MSG-Transformer: Exchanging Local Spatial Information by Manipulating Messenger Tokens, by Jiemin

Hust Visual Learning Team 68 Nov 16, 2022
Double pendulum simulator using a symplectic Euler's method and Hamiltonian mechanics

Symplectic Double Pendulum Simulator Double pendulum simulator using a symplectic Euler's method. The program calculates the momentum and position of

Scott Marino 1 Jan 12, 2022
Graph Representation Learning via Graphical Mutual Information Maximization

GMI (Graphical Mutual Information) Graph Representation Learning via Graphical Mutual Information Maximization (Peng Z, Huang W, Luo M, et al., WWW 20

93 Dec 29, 2022
Automatically align face images πŸ™ƒβ†’πŸ™‚. Can also do windowing and warping.

Automatic Face Alignment (AFA) Carl M. Gaspar & Oliver G.B. Garrod You have lots of photos of faces like this: But you want to line up all of the face

Carl Michael Gaspar 15 Dec 12, 2022
Springer Link Download Module for Python

β™ž pupalink A simple Python module to search and download books from SpringerLink. πŸ§ͺ This project is still in an early stage of development. Expect br

Pupa Corp. 18 Nov 21, 2022
PAIRED in PyTorch πŸ”₯

PAIRED This codebase provides a PyTorch implementation of Protagonist Antagonist Induced Regret Environment Design (PAIRED), which was first introduce

UCL DARK Lab 46 Dec 12, 2022