Unverified Commit 3a8b9f05 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Split `ci.yml` to avoid max workflow depth error (#1316)

parent d16ee113
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.

# This workflow differs from PR CI in that it uploads a Docker build image to public ECR.
# This should be done only on push to main so that PRs from forks can successfully run CI
# since GitHub secrets cannot be shared with a PR from a fork.
@@ -9,7 +12,7 @@ on:

# Allow only one Docker build image build to run at a time for the entire smithy-rs repo
concurrency:
  group: ci-docker-build-yml
  group: ci-main-yml
  cancel-in-progress: true

env:
@@ -47,7 +50,7 @@ jobs:
        docker push "${{ env.ecr_repository }}:${IMAGE_TAG}"
        docker push "${{ env.ecr_repository }}:main"

  # Run normal CI, which should pick up the updated build image
  # Run the shared CI after a Docker build image has been uploaded to ECR
  ci:
    needs: rebuild-docker-build-image
    uses: ./.github/workflows/ci.yml
+51 −0
Original line number Diff line number Diff line
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.

# This workflow runs CI and the PR Bot on pull requests.

name: CI
on:
  pull_request:

# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed
concurrency:
  group: ci-yaml-${{ github.ref }}
  cancel-in-progress: true

jobs:
  # This job detects if the PR made changes to build tools. If it did, then it builds a new
  # build Docker image. Otherwise, it downloads a build image from Public ECR. In both cases,
  # it uploads the image as a build artifact for other jobs to download and use.
  acquire-base-image:
    name: Acquire Base Image
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        path: smithy-rs
        fetch-depth: 0
    - name: Acquire base image
      id: acquire
      run: ./smithy-rs/tools/ci-build/acquire-build-image
    - name: Upload base image
      uses: actions/upload-artifact@v3
      with:
        name: smithy-rs-base-image
        path: smithy-rs-base-image
        retention-days: 1

  # Run shared CI after the Docker build image has either been rebuilt or found in ECR
  ci:
    needs: acquire-base-image
    uses: ./.github/workflows/ci.yml

  # The PR bot requires a Docker build image, so make it depend on the `acquire-base-image` job.
  pr_bot:
    name: PR Bot
    needs: acquire-base-image
    # Only run this job on pull requests (not directly on main)
    if: ${{ github.head_ref }}
    uses: ./.github/workflows/pull-request-bot.yml
    secrets:
      SMITHY_RS_PULL_REQUEST_CDN_S3_BUCKET_NAME: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_S3_BUCKET_NAME }}
      SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN }}
+9 −50
Original line number Diff line number Diff line
on:
  workflow_call:
  workflow_dispatch:
  pull_request:
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.

name: CI
# This is the shared CI workflow that is run by both `ci-pr.yml` and `ci-main.yml` depending
# on if a pull request is being checked, or if the `main` branch is being checked after merge.

# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed
concurrency:
  group: ci-yaml-${{ github.ref }}
  cancel-in-progress: true
name: Test
on:
  workflow_call:

env:
  rust_version: 1.56.1
  rust_toolchain_components: clippy,rustfmt

jobs:
  # This job detects if the PR made changes to build tools. If it did, then it builds a new
  # build Docker image. Otherwise, it downloads a build image from Public ECR. In both cases,
  # it uploads the image as a build artifact for other jobs to download and use.
  acquire-base-image:
    name: Acquire Base Image
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        path: smithy-rs
        fetch-depth: 0
    - name: Acquire base image
      id: acquire
      run: ./smithy-rs/tools/ci-build/acquire-build-image
    - name: Upload base image
      uses: actions/upload-artifact@v3
      with:
        name: smithy-rs-base-image
        path: smithy-rs-base-image
        retention-days: 1

  # The PR bot requires a Docker build image, so make it depend on the `acquire-base-image` job.
  pr_bot:
    name: PR Bot
    needs: acquire-base-image
    # Only run this job on pull requests (not directly on main)
    if: ${{ github.head_ref }}
    uses: ./.github/workflows/pull-request-bot.yml
    secrets:
      SMITHY_RS_PULL_REQUEST_CDN_S3_BUCKET_NAME: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_S3_BUCKET_NAME }}
      SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN }}

  # The `generate` job runs scripts that produce artifacts that are required by the `test` job,
  # and also runs some checks/lints so that those are run sooner rather than later.
  generate:
    name: Generate
    needs: acquire-base-image
    runs-on: ubuntu-latest
    # To avoid repeating setup boilerplate, we have the actual commands
    # in a matrix strategy. These commands get run in the steps after all the setup.
@@ -80,8 +45,6 @@ jobs:
  # code to have already been generated in order to run.
  test-codegen:
    name: Test Codegen
    needs:
    - acquire-base-image
    runs-on: ubuntu-latest
    # To avoid repeating setup boilerplate, we have the actual test commands
    # in a matrix strategy. These commands get run in the steps after all the setup.
@@ -110,9 +73,7 @@ jobs:
  # to be checked since `aws-config` depends on the generated STS client.
  test-runtimes-tools-and-sdk:
    name: Test Rust Runtimes, Tools, and SDK
    needs:
    - acquire-base-image
    - generate
    needs: generate
    runs-on: ubuntu-latest
    # To avoid repeating setup boilerplate, we have the actual test commands
    # in a matrix strategy. These commands get run in the steps after all the setup.
@@ -168,9 +129,7 @@ jobs:
  # This job is split out from the rest since it is not required to pass for merge
  check-sdk-examples:
    name: Check SDK Examples
    needs:
    - acquire-base-image
    - generate
    needs: generate
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
+6 −2
Original line number Diff line number Diff line
#!/bin/bash
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
#

set -e

if [[ $# -lt 1 ]]; then
@@ -13,5 +18,4 @@ if [[ $# -lt 1 ]]; then
fi

cd ..
./smithy-rs/tools/ci-build/acquire-build-image
./smithy-rs/tools/ci-build/ci-action "$@"
make -f ./smithy-rs/ci.mk "$@"

ci.mk

0 → 100644
+88 −0
Original line number Diff line number Diff line
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
#

# This is a makefile executed by the `./ci` script that
# has a target for every single CI script in `tools/ci-build/scripts`,
# with dependencies between targets included so that it's not necessary
# to remember to generate a SDK for the targets that require one.

CI_BUILD=./smithy-rs/tools/ci-build
CI_ACTION=$(CI_BUILD)/ci-action

.PHONY: acquire-build-image
acquire-build-image:
	$(CI_BUILD)/acquire-build-image

.PHONY: check-aws-sdk-examples
check-aws-sdk-examples: generate-aws-sdk
	$(CI_ACTION) $@

.PHONY: check-aws-sdk-services
check-aws-sdk-services: generate-aws-sdk
	$(CI_ACTION) $@

.PHONY: check-aws-sdk-smoketest-additional-checks
check-aws-sdk-smoketest-additional-checks: generate-aws-sdk-smoketest
	$(CI_ACTION) $@

.PHONY: check-aws-sdk-smoketest-docs-clippy-udeps
check-aws-sdk-smoketest-docs-clippy-udeps: generate-aws-sdk-smoketest
	$(CI_ACTION) $@

.PHONY: check-aws-sdk-smoketest-unit-tests
check-aws-sdk-smoketest-unit-tests: generate-aws-sdk-smoketest
	$(CI_ACTION) $@

.PHONY: check-client-codegen-integration-tests
check-client-codegen-integration-tests:
	$(CI_ACTION) $@

.PHONY: check-client-codegen-unit-tests
check-client-codegen-unit-tests:
	$(CI_ACTION) $@

.PHONY: check-rust-runtimes-and-tools
check-rust-runtimes-and-tools: generate-aws-sdk-smoketest
	$(CI_ACTION) $@

.PHONY: check-sdk-codegen-unit-tests
check-sdk-codegen-unit-tests:
	$(CI_ACTION) $@

.PHONY: check-server-codegen-integration-tests
check-server-codegen-integration-tests:
	$(CI_ACTION) $@

.PHONY: check-server-codegen-unit-tests
check-server-codegen-unit-tests:
	$(CI_ACTION) $@

.PHONY: check-server-e2e-test
check-server-e2e-test:
	$(CI_ACTION) $@

.PHONY: check-style-and-lints
check-style-and-lints:
	$(CI_ACTION) $@

.PHONY: generate-aws-sdk-smoketest
generate-aws-sdk-smoketest:
	$(CI_ACTION) $@

.PHONY: generate-aws-sdk
generate-aws-sdk:
	$(CI_ACTION) $@

.PHONY: generate-codegen-diff
generate-codegen-diff:
	$(CI_ACTION) $@

.PHONY: generate-smithy-rs-runtime-bundle
generate-smithy-rs-runtime-bundle:
	$(CI_ACTION) $@

.PHONY: sanity-test
sanity-test:
	$(CI_ACTION) $@
Loading