Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: smoke test automation #13162

Merged
merged 63 commits into from
Aug 30, 2023
Merged

ci: smoke test automation #13162

merged 63 commits into from
Aug 30, 2023

Conversation

sobolk
Copy link
Member

@sobolk sobolk commented Aug 28, 2023

Description of changes

This PR automates execution of Smoke Tests

  • Adds re-usable smoke test workflow
  • Adds a workflow that can be triggered manually by operator
  • Adds canary test that runs on schedule and runs smoke tests against latest CLI
  • Adds lightweight smoke tests for Windows that use shell and headless commands instead of e2e framework due to e2e framework not working well on small Windows machines.

Actions used in workflow that are not defined in this repository:

  • aws-actions/configure-aws-credentials@04b98b3f9e85f563fb061be8751a0352327246b0 # v3.0.1 - to obtain test account access
  • ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 - required for Xcode test
  • actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2 - uploads test report
  • actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

Out of scope
The goal of this PR is to :

  • establish automation (GH actions)
  • cover Xcode IOS use case in addition to existing smoke test

Remaining coverage (proper Windows tests and Amplify App) will be pursued in subsequent PRs.

Issue #, if available

Description of how you validated changes

Running workflow from push to smoke-tests-prototype branch.
See https://github.com/aws-amplify/amplify-cli/actions/workflows/smoke-tests-manual.yml

Other triggers like schedule and manual dispatch will be tested after merge (they require workflow to be present in dev branch).

image

E2E test run as well (since I touched these)

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Pull request labels are added

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sobolk sobolk marked this pull request as ready for review August 29, 2023 16:22
@sobolk sobolk requested review from a team as code owners August 29, 2023 16:22
@@ -0,0 +1,22 @@


#amplify-do-not-edit-begin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +202 to 207
describe('Smoke Tests', () => {
const createCommands = (amplify: Amplify, directory: string): Command[] => [
{
description: `Install @aws-amplify/cli@${cliVersion}`,
run: () => NPM.install(`@aws-amplify/cli@${cliVersion}`, true),
description: 'Amplify CLI version',
run: () => amplify.version(),
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved CLI installation to Actions logic, so that we can reuse same smoke test with many installation strategies.


$AMPLIFY_PATH status

ADD_AUTH_REQUEST=$(cat ../.github/actions/run-smoke-tests-windows/add_auth_request.json)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what path does this script expect to be run from? Could we pass in a base path as an arg to avoid confusion if we change the directory structure of these actions / scripts?


- name: Install Dependencies
shell: bash
run: yarn install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this include --frozen-lockfile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bcd0740fa72c:amplify-cli-nofork sobkamil$ yarn install --frozen-lockfile
➤ YN0050: The --frozen-lockfile option is deprecated; use --immutable and/or --immutable-cache instead

I'll add immutable.


- name: Upload Report
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2
if: always()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not the default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. By default step is skipped if previous step fails. This makes sure that report is uploaded regardless of test success.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env:
CLI_REGION: ${{ inputs.region }}
CI: true
CIRCLECI: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to trigger test profile configuration

.

@@ -0,0 +1,53 @@
name: Smoke Tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an action rather than a workflow? Seems like it is being dispatched from the canary and manual workflow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason this is "reusable workflow" (see https://docs.github.com/en/actions/using-workflows/reusing-workflows )
Is the matrix element that runs the same steps on cartesian product of versions and agents.
That's not available in actions.

I created "canary" and "manual" as "lightweight entry points"
Think about smoke-tests.yml as base class and canary/manual as lightweight implementation of base that encapsulate invocation and parameters.
In other words smoke-tests.yml contains workflow logic. canary/manual are just different entry points (like cli throw over programatic interface).

Another reason to have canary and manual entry points is that they'll appear as separate top level workflows in GH ui so that person who wants to look at canaries vs person who wants to smoke test RC won't have to reason about modality of parameters.

And yet other reason is that creating single workflow definition with multiple "triggers" would require workarounds to have matrix populated correctly in every case. (Depending on trigger we'd need different logic to populate matrix which is hard problem in declarative yaml).

edwardfoyle
edwardfoyle previously approved these changes Aug 29, 2023
Copy link
Member

@edwardfoyle edwardfoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be a huge win!

edwardfoyle
edwardfoyle previously approved these changes Aug 29, 2023
Comment on lines 19 to 20
push:
branches: [smoke-tests-prototype]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no.

uses: ./.github/workflows/smoke-tests.yml
secrets: inherit
with:
versions: '["latest"]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should add RC as well to catch any errors before going to production?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. I was thinking that RC will go through "oncall will click a button to trigger smoke tests", but having an active monitoring here won't hurt I guess.

@@ -0,0 +1,17 @@
name: Smoke Tests - Canaries
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the notification mechanism for this canary? I.e. how would the oncall find out if a run has failed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question.

Options to pursue:

I'd try that Slack integration first after merging this and explore cloudwatch if this is not working.

Amplifiyer
Amplifiyer previously approved these changes Aug 30, 2023
Comment on lines 21 to 24
call-smoke-tests:
if: github.event_name != 'workflow_dispatch'
uses: ./.github/workflows/smoke-tests.yml
secrets: inherit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this can be cleaned up as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, good catch

edwardfoyle
edwardfoyle previously approved these changes Aug 30, 2023
@sobolk sobolk dismissed stale reviews from edwardfoyle and Amplifiyer via feea838 August 30, 2023 16:05
Copy link
Contributor

@Amplifiyer Amplifiyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great win!

@sobolk sobolk merged commit 446a4f4 into dev Aug 30, 2023
5 checks passed
@sobolk sobolk deleted the smoke-tests-prototype branch August 30, 2023 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants