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
[CVPRW 2021] Code for Region-Adaptive Deformable Network for Image Quality Assessment

RADN [CVPRW 2021] Code for Region-Adaptive Deformable Network for Image Quality Assessment [Paper on arXiv] Overview Update [2021/5/7] add codes for W

IIGROUP 53 Dec 28, 2022
Model search is a framework that implements AutoML algorithms for model architecture search at scale

Model search (MS) is a framework that implements AutoML algorithms for model architecture search at scale. It aims to help researchers speed up their exploration process for finding the right model a

Google 3.2k Dec 31, 2022
Unsupervised Domain Adaptation for Nighttime Aerial Tracking (CVPR2022)

Unsupervised Domain Adaptation for Nighttime Aerial Tracking (CVPR2022) Junjie Ye, Changhong Fu, Guangze Zheng, Danda Pani Paudel, and Guang Chen. Uns

Intelligent Vision for Robotics in Complex Environment 91 Dec 30, 2022
YOLOPのPythonでのONNX推論サンプル

YOLOP-ONNX-Video-Inference-Sample YOLOPのPythonでのONNX推論サンプルです。 ONNXモデルは、hustvl/YOLOP/weights を使用しています。 Requirement OpenCV 3.4.2 or later onnxruntime 1.

KazuhitoTakahashi 8 Sep 05, 2022
Learning Time-Critical Responses for Interactive Character Control

Learning Time-Critical Responses for Interactive Character Control Abstract This code implements the paper Learning Time-Critical Responses for Intera

Movement Research Lab 227 Dec 31, 2022
Implementation of accepted AAAI 2021 paper: Deep Unsupervised Image Hashing by Maximizing Bit Entropy

Deep Unsupervised Image Hashing by Maximizing Bit Entropy This is the PyTorch implementation of accepted AAAI 2021 paper: Deep Unsupervised Image Hash

62 Dec 30, 2022
[AAAI 2022] Separate Contrastive Learning for Organs-at-Risk and Gross-Tumor-Volume Segmentation with Limited Annotation

A paper Introduction This is an official release of the paper Separate Contrastive Learning for Organs-at-Risk and Gross-Tumor-Volume Segmentation wit

Jiacheng Wang 14 Dec 08, 2022
OoD Minimum Anomaly Score GAN - Code for the Paper 'OMASGAN: Out-of-Distribution Minimum Anomaly Score GAN for Sample Generation on the Boundary'

OMASGAN: Out-of-Distribution Minimum Anomaly Score GAN for Sample Generation on the Boundary Out-of-Distribution Minimum Anomaly Score GAN (OMASGAN) C

- 8 Sep 27, 2022
ByteTrack超详细教程!训练自己的数据集&&摄像头实时检测跟踪

ByteTrack超详细教程!训练自己的数据集&&摄像头实时检测跟踪

Double-zh 45 Dec 19, 2022
A transformer-based method for Healthcare Image Captioning in Vietnamese

vieCap4H Challenge 2021: A transformer-based method for Healthcare Image Captioning in Vietnamese This repo GitHub contains our solution for vieCap4H

Doanh B C 4 May 05, 2022
Lowest memory consumption and second shortest runtime in NTIRE 2022 challenge on Efficient Super-Resolution

FMEN Lowest memory consumption and second shortest runtime in NTIRE 2022 on Efficient Super-Resolution. Our paper: Fast and Memory-Efficient Network T

33 Dec 01, 2022
Parametric Contrastive Learning (ICCV2021)

Parametric-Contrastive-Learning This repository contains the implementation code for ICCV2021 paper: Parametric Contrastive Learning (https://arxiv.or

DV Lab 156 Dec 21, 2022
a delightful machine learning tool that allows you to train, test and use models without writing code

igel A delightful machine learning tool that allows you to train/fit, test and use models without writing code Note I'm also working on a GUI desktop

Nidhal Baccouri 3k Jan 05, 2023
A PyTorch Implementation of Single Shot Scale-invariant Face Detector.

S³FD: Single Shot Scale-invariant Face Detector A PyTorch Implementation of Single Shot Scale-invariant Face Detector. Eval python wider_eval_pytorch.

carwin 235 Jan 07, 2023
BigbrotherBENL - Face recognition on the Big Brother episodes in Belgium and the Netherlands.

BigbrotherBENL - Face recognition on the Big Brother episodes in Belgium and the Netherlands. Keeping statistics of whom are most visible and recognisable in the series and wether or not it has an im

Frederik 2 Jan 04, 2022
Code for paper "Which Training Methods for GANs do actually Converge? (ICML 2018)"

GAN stability This repository contains the experiments in the supplementary material for the paper Which Training Methods for GANs do actually Converg

Lars Mescheder 885 Jan 01, 2023
Answer a series of contextually-dependent questions like they may occur in natural human-to-human conversations.

SCAI-QReCC-21 [leaderboards] [registration] [forum] [contact] [SCAI] Answer a series of contextually-dependent questions like they may occur in natura

19 Sep 28, 2022
Range Image-based LiDAR Localization for Autonomous Vehicles Using Mesh Maps

Range Image-based 3D LiDAR Localization This repo contains the code for our ICRA2021 paper: Range Image-based LiDAR Localization for Autonomous Vehicl

Photogrammetry & Robotics Bonn 208 Dec 15, 2022
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022