function main_branch()

in aws/hhvm1/state-machine/generate.hack [458:563]


function main_branch(): StateMachine {
  return linear_state_machine(
    null,
    dict[
      S::ForEach.S::Version => dict[
        F::Type => T::Map,
        F::ItemsPath => path(P::BuildInput, 'versions'),
        F::Parameters => map_params(keyset[P::BuildInput], P::Version),
        F::Iterator => linear_state_machine(
          S::Version.S::NormalizeResults,
          Dict\merge(
            states_for_activity(
              keyset[P::Version],
              A::MakeSourceTarball,
              S::BuildAndPublishLinux.S::And.A::BuildAndPublishMacOS,
              S::Version.S::NormalizeResults,
            ),
            dict[
              S::BuildAndPublishLinux.S::And.A::BuildAndPublishMacOS => dict[
                F::Type => T::Parallel,
                F::Parameters => params(P::BuildInput, P::Version),
                F::Branches => vec[linux_branch(), macos_branch()],
              ],
              S::Version.S::NormalizeResults => dict[
                F::Type => T::Task,
                F::Resource => Config::ARN[S::NormalizeResults],
                F::Parameters => params(P::Version, P::Results),
                F::ResultPath => path('results'),
                F::Catch => vec[],
                F::End => true,
              ],
            ],
          ),
        ),
      ],

      S::CheckIfReposChanged => dict[
        F::Type => T::Task,
        F::ResultPath => path('reposChanged'),
      ],

      S::Should.S::UpdateIndices.S::And.S::InvalidateCloudFront => dict[
        F::Type => T::Choice,
        F::Choices => vec[
          dict[
            'Variable' => path('reposChanged'),
            'BooleanEquals' => false,
            'Next' => S::NormalizeResults,
          ],
        ],
        F::Default => S::UpdateIndices.S::And.S::InvalidateCloudFront,
      ],

      S::UpdateIndices.S::And.S::InvalidateCloudFront => dict[
        F::Type => T::Parallel,
        F::Parameters => params(P::BuildInput),
        F::Branches => vec[
          nested_state_machine(
            S::UpdateIndices,
            null,
            dict[
              S::UpdateIndices => dict[
                F::Type => T::Task,
                F::Parameters => dict[
                  'bucket' => 'hhvm-downloads',
                  'cloudfront' => 'E35YBTV6QCR5BA',
                ],
              ],
            ],
          ),
          nested_state_machine(
            S::InvalidateCloudFront,
            null,
            dict[
              S::InvalidateCloudFront => dict[
                F::Type => T::Task,
              ],
            ],
          ),
        ],
      ],

      S::NormalizeResults => dict[
        F::Type => T::Task,
        F::ResultPath => '$',
      ],

      S::CheckForFailures => dict[
        F::Type => T::Task,
        F::ResultPath => '$',
        // only retry on lambda service exceptions
        F::Retry => vec[
          dict[
            'ErrorEquals' => vec[
              'Lambda.ServiceException',
              'Lambda.AWSLambdaException',
              'Lambda.SdkClientException',
            ],
            'IntervalSeconds' => 5,
            'MaxAttempts' => 5,
          ],
        ],
      ],
    ],
  );
}