Canary #1283
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Canary | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
push: | |
branches: | |
- "canary*" | |
env: | |
tool_rust_version: 1.78.0 | |
rust_nightly_version: nightly-2024-03-15 | |
jobs: | |
generate-canary-matrix: | |
runs-on: ubuntu-latest | |
name: Generate Canary Matrix | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/checkout@v4 | |
with: | |
repository: awslabs/smithy-rs | |
path: smithy-rs | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.tool_rust_version }} | |
- name: Generate the matrix | |
id: generate-matrix | |
working-directory: smithy-rs/tools/ci-cdk/canary-runner | |
# Run the `canary-runner generate-matrix` subcommand to calculate a test matrix | |
# for the `canary` job. This script outputs JSON that GitHub Actions can consume | |
# as a matrix definition. Rust versions to test against are arguments to this script. | |
run: | | |
cargo build | |
# Rust versions should just be the MSRV and the latest stable compiler | |
echo "matrix=$(cargo run -- generate-matrix --sdk-versions 3 --rust-versions ${{ env.tool_rust_version }} stable)" >> "${GITHUB_OUTPUT}" | |
outputs: | |
matrix: ${{ steps.generate-matrix.outputs.matrix }} | |
canary: | |
needs: generate-canary-matrix | |
name: Canary | |
runs-on: ubuntu-latest | |
env: | |
AWS_DEFAULT_REGION: us-west-2 | |
CARGO_INCREMENTAL: "0" | |
RUST_VERSION: ${{ matrix.rust_version }} | |
SDK_RELEASE_TAG: ${{ matrix.sdk_release_tag }} | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: write | |
strategy: | |
fail-fast: false | |
# Use the matrix generated by the previous job | |
matrix: ${{ fromJson(needs.generate-canary-matrix.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: awslabs/smithy-rs | |
path: smithy-rs | |
# Fetch all history so that the runner can change to different commits | |
fetch-depth: 0 | |
# Each canary run uses a different Rust version, and the `rust-toolchain.toml` | |
# file interferes with that version selection. | |
- name: Delete `rust-toolchain.toml` | |
working-directory: smithy-rs | |
run: rm rust-toolchain.toml | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust_version }} | |
targets: x86_64-unknown-linux-musl | |
- name: Install dependencies | |
run: sudo apt-get update && sudo apt-get install -y awscli musl-dev musl-tools | |
- name: Install cargo component for wasm canary | |
env: | |
# Must be in sync with that specified in `smithy-rs` | |
CARGO_COMPONENT_VERSION: 0.13.2 | |
run: | | |
rustup toolchain install ${{ env.rust_nightly_version }} | |
rustup component add rustfmt | |
cargo +${{ env.rust_nightly_version }} install cargo-component --locked --version ${CARGO_COMPONENT_VERSION} | |
- name: Compile the canary runner | |
working-directory: smithy-rs/tools/ci-cdk/canary-runner | |
run: cargo build | |
- uses: aws-actions/configure-aws-credentials@v4 | |
name: Acquire credentials for running the canary | |
with: | |
role-to-assume: ${{ secrets.CANARY_WORKFLOW_GITHUB_ACTIONS_ROLE_ARN }} | |
aws-region: us-west-2 | |
- name: Run the canary | |
env: | |
CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME: ${{ secrets.CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME }} | |
run: | | |
# If `smithy-rs` lives under `aws-sdk-rust`, the following `cargo run` will run into a workspace problem: | |
# `cargo metadata` exited with an error: error: current package believes it's in a workspace when it's not: | |
# current: /home/runner/work/aws-sdk-rust/aws-sdk-rust/smithy-rs/tools/ci-cdk/canary-wasm/Cargo.toml | |
# workspace: /home/runner/work/aws-sdk-rust/aws-sdk-rust/Cargo.toml | |
# The checkout action does not allow us to clone a repo outside the github workspace, i.e. using `path: ../smithy-rs` | |
# (https://github.com/actions/checkout/issues/197). | |
# We work around it by manually moving `smithy-rs` outside of `aws-sdk-rust`. | |
mv smithy-rs ../ | |
cd ../smithy-rs/tools/ci-cdk/canary-runner | |
aws s3 cp s3://"${CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME}"/cdk-outputs.json . | |
cargo run -- \ | |
run --rust-version ${RUST_VERSION} \ | |
--sdk-release-tag ${SDK_RELEASE_TAG} \ | |
--cdk-output cdk-outputs.json \ | |
--musl |