           |> Repo.insert!()
           |> maybe_start_attempt(project)
         end
-      _attempt ->
+      [_attempt | _] ->
         # There is already a running attempt
         project
         |> get_repo_conn()

  def do_handle_cast({:cancel, patch_id}, project_id) do
    patch = Repo.get!(Patch, patch_id)
    ^project_id = patch.project_id
    case Repo.one(Attempt.all_for_patch(patch_id, :incomplete)) do
      nil ->
        :ok
      attempt ->
        attempt
        |> Attempt.changeset_state(%{state: :canceled})
        |> Repo.update!()

    patch = Repo.get!(Patch, patch_id)
    ^project_id = patch.project_id
    project = Repo.get!(Project, project_id)
    case Repo.all(Attempt.all_for_patch(patch_id, :incomplete)) do
      [] ->
        # There is no currently running attempt
        # Start one
        if Patch.ci_skip?(patch) do
