function aggregateStatus()

in src/GitHubStatusDisplay.js [593:636]


    function aggregateStatus(jobs) {
      // The logic here follows these rules (in order):
      // 1. If there are no jobs, return no status
      // 2. Failed if any job is failed
      // 3. Pending if any job is pending
      // 4. Success if all jobs are success, skipped, or aborted
      // 5. Otherwise pending

      jobs = jobs.filter((x) => x !== undefined);
      if (jobs.length === 0) {
        // No jobs in the group so don't show anything
        return null;
      }

      for (const job of jobs) {
        if (is_failure(job.status) || is_infra_failure(job.status)) {
          return "failure";
        }
      }

      for (const job of jobs) {
        if (is_pending(job.status)) {
          return "pending";
        }
      }

      let allOk = true;
      for (const job of jobs) {
        if (
          !(
            is_success(job.status) ||
            is_skipped(job.status) ||
            is_aborted(job.status)
          )
        ) {
          allOk = false;
        }
      }
      if (allOk) {
        return "success";
      }

      return "pending";
    }