From b82b6a650aa45b88acb1bdc9adb1da4d25051b7f Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Wed, 9 Nov 2022 12:46:43 -0800 Subject: [PATCH] Upgrade actions in GitHub Actions workflows (#1959) * Stop using actions-rs since it's not maintained (see https://github.com/actions-rs/toolchain/issues/216) * Upgrade `aws-actions/configure-aws-credentials` to `v1-node16` * Replace `::set-output` with environment files --- .github/actions/docker-build/action.yml | 11 ++-- .github/workflows/ci-main.yml | 4 +- .github/workflows/ci.yml | 64 ++++++++----------- .github/workflows/github-pages.yml | 6 +- .github/workflows/manual-pull-request-bot.yml | 2 +- .github/workflows/pull-request-bot.yml | 23 +++---- .github/workflows/release.yml | 3 +- .github/workflows/update-sdk-next.yml | 8 +-- 8 files changed, 56 insertions(+), 65 deletions(-) diff --git a/.github/actions/docker-build/action.yml b/.github/actions/docker-build/action.yml index 11bb239d640..837bb3fbc1e 100644 --- a/.github/actions/docker-build/action.yml +++ b/.github/actions/docker-build/action.yml @@ -15,7 +15,7 @@ inputs: runs: using: composite steps: - - uses: actions/cache@v2 + - uses: actions/cache@v3 name: Gradle Cache with: path: | @@ -24,11 +24,12 @@ runs: key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/caches/**/*', 'gradle/wrapper/**/*') }} restore-keys: | ${{ runner.os }}-gradle- - # Pinned to the commit hash of v1.3.0 - - uses: Swatinem/rust-cache@842ef286fff290e445b90b4002cc9807c3669641 + # Pinned to the commit hash of v2.1.0 + - uses: Swatinem/rust-cache@b894d59a8d236e2979b247b80dac8d053ab340dd with: - sharedKey: ${{ runner.os }}-${{ github.job }} - target-dir: ./smithy-rs-target + shared-key: ${{ runner.os }}-${{ github.job }} + workspaces: | + . smithy-rs-target - name: Download all artifacts uses: ./smithy-rs/.github/actions/download-all-artifacts - name: Prepare build image diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index bb54bb66b7d..d385e5367db 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -28,7 +28,7 @@ jobs: contents: read steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build image run: | IMAGE_TAG="$(./tools/ci-build/tools-hash)" @@ -38,7 +38,7 @@ jobs: -t "${{ env.ecr_repository }}:main" \ . - name: Acquire credentials - uses: aws-actions/configure-aws-credentials@v1 + uses: aws-actions/configure-aws-credentials@v1-node16 with: role-to-assume: ${{ secrets.SMITHY_RS_PUBLIC_ECR_PUSH_ROLE_ARN }} role-session-name: GitHubActions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 453a301b715..2404ca30d26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,16 +121,17 @@ jobs: RUSTFLAGS: -D warnings steps: - uses: actions/checkout@v3 - # Pinned to the commit hash of v1.3.0 - - uses: Swatinem/rust-cache@842ef286fff290e445b90b4002cc9807c3669641 + # Pinned to the commit hash of v2.1.0 + - uses: Swatinem/rust-cache@b894d59a8d236e2979b247b80dac8d053ab340dd with: - sharedKey: ${{ runner.os }}-${{ env.rust_version }}-${{ github.job }} - target-dir: ./target - - uses: actions-rs/toolchain@v1 + shared-key: ${{ runner.os }}-${{ env.rust_version }}-${{ github.job }} + workspaces: | + . + tools + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.rust_version }} components: ${{ env.rust_toolchain_components }} - default: true - name: Run tests shell: bash run: | @@ -181,19 +182,19 @@ jobs: CROSS_CONFIG: Cross.toml steps: - name: Checkout - uses: actions/checkout@v1 - # Pinned to the commit hash of v1.3.0 - - uses: Swatinem/rust-cache@842ef286fff290e445b90b4002cc9807c3669641 + uses: actions/checkout@v3 + # Pinned to the commit hash of v2.1.0 + - uses: Swatinem/rust-cache@b894d59a8d236e2979b247b80dac8d053ab340dd with: - sharedKey: ${{ runner.os }}-${{ env.rust_version }}-${{ github.job }}-${{ matrix.target }} - target-dir: ./target - - uses: actions-rs/toolchain@v1 + shared-key: ${{ runner.os }}-${{ env.rust_version }}-${{ github.job }}-${{ matrix.target }} + workspaces: | + . + tools + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.rust_version }} components: ${{ env.rust_toolchain_components }} - profile: minimal - override: true - target: ${{ matrix.target }} + targets: ${{ matrix.target }} - name: Sets OpenSSL env vars on i686 run: | echo "OPENSSL_LIB_DIR=/usr/lib/i386-linux-gnu" >> $GITHUB_ENV @@ -208,6 +209,8 @@ jobs: # configure and cross compile openssl locally on ppc and ppc64 to be able to run aws-smithy-client tests. # since cross dropped support for openssl, we use the build script from version 0.16. run: | + cargo install cross --locked --version 0.2.4 + cat > Cross.toml << EOF [target.i686-unknown-linux-gnu] pre-build = ["dpkg --add-architecture i386", "apt-get update && apt-get install --assume-yes pkg-config:i386 libssl-dev:i386"] @@ -226,29 +229,17 @@ jobs: passthrough = ["OPENSSL_DIR"] EOF - name: Build Smithy-rs rust-runtime crates - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: -vv --target ${{ matrix.target }} --manifest-path "rust-runtime/Cargo.toml" ${{ matrix.build_smithy_rs_exclude }} --workspace ${{ matrix.build_smithy_rs_features }} + shell: bash + run: cross build -vv --target ${{ matrix.target }} --manifest-path "rust-runtime/Cargo.toml" ${{ matrix.build_smithy_rs_exclude }} --workspace ${{ matrix.build_smithy_rs_features }} - name: Build AWS rust-runtime crates - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: -vv --target ${{ matrix.target }} --manifest-path "aws/rust-runtime/Cargo.toml" ${{ matrix.build_aws_exclude }} --workspace + shell: bash + run: cross build -vv --target ${{ matrix.target }} --manifest-path "aws/rust-runtime/Cargo.toml" ${{ matrix.build_aws_exclude }} --workspace - name: Test Smithy-rs rust-runtime crates - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: test - args: --target ${{ matrix.target }} --manifest-path "rust-runtime/Cargo.toml" ${{ matrix.test_smithy_rs_exclude }} --workspace ${{ matrix.test_smithy_rs_features }} + shell: bash + run: cross test --target ${{ matrix.target }} --manifest-path "rust-runtime/Cargo.toml" ${{ matrix.test_smithy_rs_exclude }} --workspace ${{ matrix.test_smithy_rs_features }} - name: Test AWS rust-runtime crates - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: test - args: --target ${{ matrix.target }} --manifest-path "aws/rust-runtime/Cargo.toml" ${{ matrix.test_aws_exclude }} --workspace + shell: bash + run: cross test --target ${{ matrix.target }} --manifest-path "aws/rust-runtime/Cargo.toml" ${{ matrix.test_aws_exclude }} --workspace # This job is split out from the rest since it is not required to pass for merge check-sdk-examples: @@ -280,6 +271,7 @@ jobs: name: Matrix Success steps: - name: Verify jobs succeeded - uses: re-actors/alls-green@3a2de129f0713010a71314c74e33c0e3ef90e696 + # Pinned to commit hash of v1.2.2 + uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe with: jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 81db1dad34b..83926c09acd 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -17,12 +17,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: persist-credentials: false - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + - uses: dtolnay/rust-toolchain@stable - name: Generate docs env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/manual-pull-request-bot.yml b/.github/workflows/manual-pull-request-bot.yml index 0b0764104f0..89e1852ce85 100644 --- a/.github/workflows/manual-pull-request-bot.yml +++ b/.github/workflows/manual-pull-request-bot.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Get PR info id: get-pr-info - uses: actions/github-script@v5 + uses: actions/github-script@v6 with: script: | const response = await github.rest.pulls.get({ diff --git a/.github/workflows/pull-request-bot.yml b/.github/workflows/pull-request-bot.yml index fe17e9eab83..98440e04ae6 100644 --- a/.github/workflows/pull-request-bot.yml +++ b/.github/workflows/pull-request-bot.yml @@ -46,7 +46,7 @@ jobs: outputs: bot-message: ${{ steps.generate-diff.outputs.bot-message }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: path: smithy-rs - name: Generate diff @@ -54,7 +54,7 @@ jobs: with: action: generate-codegen-diff action-arguments: ${{ inputs.base_revision }} - - uses: aws-actions/configure-aws-credentials@v1 + - uses: aws-actions/configure-aws-credentials@v1-node16 name: Acquire credentials for uploading to S3 with: role-to-assume: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN }} @@ -80,8 +80,8 @@ jobs: outputs: bot-message: ${{ steps.generate-preview.outputs.bot-message }} steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - uses: actions/cache@v3 name: Gradle Cache with: path: | @@ -92,13 +92,14 @@ jobs: ${{ runner.os }}-gradle- # JDK is needed to generate code - name: Set up JDK - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: + distribution: corretto + java-package: jdk java-version: ${{ env.java_version }} - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.rust_version }} - default: true - name: Generate doc preview id: generate-preview # Only generate three of the smallest services since the doc build can be very large. STS and SSO must be @@ -122,8 +123,8 @@ jobs: popd ./tools/generate-doc-preview-index.sh ${{ inputs.base_revision }} - echo '::set-output name=bot-message::A [new doc preview](https://d2luzm2xt3nokh.cloudfront.net/docs/'${{ inputs.head_revision }}'/index.html) is ready to view.' - - uses: aws-actions/configure-aws-credentials@v1 + echo 'bot-message=A [new doc preview](https://d2luzm2xt3nokh.cloudfront.net/docs/'${{ inputs.head_revision }}'/index.html) is ready to view.' >> "${GITHUB_OUTPUT}" + - uses: aws-actions/configure-aws-credentials@v1-node16 name: Acquire credentials for uploading to S3 with: role-to-assume: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN }} @@ -153,9 +154,9 @@ jobs: id: bot-messages run: | set -eux - echo ::set-output name=codegen-diff::"$(cat ./bot-message-codegen-diff)" + echo "codegen-diff=$(cat ./bot-message-codegen-diff)" >> "${GITHUB_OUTPUT}" - name: Post bot comment - uses: actions/github-script@v5 + uses: actions/github-script@v6 with: script: | await github.rest.issues.createComment({ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a09745921ed..abeed0601c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,10 +73,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.rust_version }} - default: true - name: Checkout smithy-rs uses: actions/checkout@v3 with: diff --git a/.github/workflows/update-sdk-next.yml b/.github/workflows/update-sdk-next.yml index e21b6433fd4..65571bc870c 100644 --- a/.github/workflows/update-sdk-next.yml +++ b/.github/workflows/update-sdk-next.yml @@ -23,14 +23,14 @@ jobs: path: aws-sdk-rust token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} - name: Set up JDK - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: + distribution: corretto + java-package: jdk java-version: 11 # Rust is only used to `rustfmt` the generated code; doesn't need to match MSRV - name: Set up Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + uses: dtolnay/rust-toolchain@stable - name: Delete old SDK run: | - name: Generate a fresh SDK