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/alls-green@release/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/[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/setup-python@v4
          with:
            python-version: '3.10'
    
        - name: Decide whether the needed jobs succeeded or failed
          uses: re-actors/[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
Exploring whether attention is necessary for vision transformers

Do You Even Need Attention? A Stack of Feed-Forward Layers Does Surprisingly Well on ImageNet Paper/Report TL;DR We replace the attention layer in a v

Luke Melas-Kyriazi 461 Jan 7, 2023
The first dataset of composite images with rationality score indicating whether the object placement in a composite image is reasonable.

Object-Placement-Assessment-Dataset-OPA Object-Placement-Assessment (OPA) is to verify whether a composite image is plausible in terms of the object p

BCMI 53 Nov 15, 2022
Face Mask Detection is a project to determine whether someone is wearing mask or not, using deep neural network.

face-mask-detection Face Mask Detection is a project to determine whether someone is wearing mask or not, using deep neural network. It contains 3 scr

amirsalar 13 Jan 18, 2022
This program was designed to detect whether someone is wearing a facemask through a live video stream.

This program was designed to detect whether someone is wearing a facemask through a live video stream. A custom lightweight CNN trained with TensorFlow on a public dataset provided by Kaggle is used to detect whether each face detected by the cv2 face detection dnn is wearing a mask

null 0 Apr 2, 2022
A system used to detect whether a person is wearing a medical mask or not.

Mask_Detection_System A system used to detect whether a person is wearing a medical mask or not. To open the program, please follow these steps: Make

Mohamed Emad 0 Nov 17, 2022
Diabet Feature Engineering - Predict whether people have diabetes when their characteristics are specified

Diabet Feature Engineering - Predict whether people have diabetes when their characteristics are specified

Şebnem 6 Jan 18, 2022
Özlem Taşkın 0 Feb 23, 2022
Official PyTorch implementation of Spatial Dependency Networks.

Spatial Dependency Networks: Neural Layers for Improved Generative Image Modeling Đorđe Miladinović   Aleksandar Stanić   Stefan Bauer   Jürgen Schmid

Djordje Miladinovic 34 Jan 19, 2022
The code release of paper 'Domain Generalization for Medical Imaging Classification with Linear-Dependency Regularization' NIPS 2020.

Domain Generalization for Medical Imaging Classification with Linear Dependency Regularization The code release of paper 'Domain Generalization for Me

Yufei Wang 56 Dec 28, 2022
codes for paper Combining Dynamic Local Context Focus and Dependency Cluster Attention for Aspect-level sentiment classification

DLCF-DCA codes for paper Combining Dynamic Local Context Focus and Dependency Cluster Attention for Aspect-level sentiment classification. submitted t

null 15 Aug 30, 2022
Pytorch implementation of “Recursive Non-Autoregressive Graph-to-Graph Transformer for Dependency Parsing with Iterative Refinement”

Graph-to-Graph Transformers Self-attention models, such as Transformer, have been hugely successful in a wide range of natural language processing (NL

Idiap Research Institute 40 Aug 14, 2022
Implementation of fast algorithms for Maximum Spanning Tree (MST) parsing that includes fast ArcMax+Reweighting+Tarjan algorithm for single-root dependency parsing.

Fast MST Algorithm Implementation of fast algorithms for (Maximum Spanning Tree) MST parsing that includes fast ArcMax+Reweighting+Tarjan algorithm fo

Miloš Stanojević 11 Oct 14, 2022
Code for the AAAI 2022 paper "Zero-Shot Cross-Lingual Machine Reading Comprehension via Inter-Sentence Dependency Graph".

multilingual-mrc-isdg Code for the AAAI 2022 paper "Zero-Shot Cross-Lingual Machine Reading Comprehension via Inter-Sentence Dependency Graph". This r

Liyan 5 Dec 7, 2022
This project uses reinforcement learning on stock market and agent tries to learn trading. The goal is to check if the agent can learn to read tape. The project is dedicated to hero in life great Jesse Livermore.

Reinforcement-trading This project uses Reinforcement learning on stock market and agent tries to learn trading. The goal is to check if the agent can

Deepender Singla 1.4k Dec 22, 2022
Industrial knn-based anomaly detection for images. Visit streamlit link to check out the demo.

Industrial KNN-based Anomaly Detection ⭐ Now has streamlit support! ⭐ Run $ streamlit run streamlit_app.py This repo aims to reproduce the results of

aventau 102 Dec 26, 2022
This repo is to be freely used by ML devs to check the GAN performances without coding from scratch.

GANs for Fun Created because I can! GOAL The goal of this repo is to be freely used by ML devs to check the GAN performances without coding from scrat

Sagnik Roy 13 Jan 26, 2022
Official code for Next Check-ins Prediction via History and Friendship on Location-Based Social Networks (MDM 2018)

MUC Next Check-ins Prediction via History and Friendship on Location-Based Social Networks (MDM 2018) Performance Details for Accuracy: | Dataset

Yijun Su 3 Oct 9, 2022