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

chore: run basic examples as tests #2006

Merged
merged 7 commits into from
Aug 11, 2023
Merged

chore: run basic examples as tests #2006

merged 7 commits into from
Aug 11, 2023

Conversation

kettanaito
Copy link
Contributor

@kettanaito kettanaito commented Jul 25, 2023

The goal of this change is to repurpose a basic set of usage examples as E2E tests running on each change to Artillery. This makes sure that:

  • Examples we write for our users are actually tested and confirmed valid;
  • We don't accidentally break the happy path examples with incremental changes.

Changes

  • Adds a new Examples workflow that runs the following examples as tests using Artillery GitHub Action:
    • http-metrics-by-endpoint
    • multiple-scenarios-spec
    • using-data-from-csv

Although it's appealing to run as many examples as possible, let's not rush here. Quantity is not the point. We still have some job to do to improve the examples so this is a task we will iterate on over time. For now, what matters most is to have the most basic Artillery behaviors turned into tests to help us ship with more confidence.

Roadmap

  • Use the local version of Artillery to validate examples against the changes made.
  • Publish example runner if we decide to use it.

@kettanaito kettanaito force-pushed the test/example-as-test branch 4 times, most recently from 107e447 to e8b2016 Compare July 25, 2023 13:37
@kettanaito kettanaito requested a review from a team August 2, 2023 14:01
@kettanaito kettanaito requested a review from hassy August 2, 2023 14:30
@kettanaito
Copy link
Contributor Author

Hey, @hassy. Would you have a minute to look at this please? The test -> workflow usage should be straightforward but the main area I'd like to hear feedback on is the test runner itself. Thanks!

@kettanaito
Copy link
Contributor Author

While we were discussing this, I got an interesting idea. I was thinking how can we feature out GitHub Action in the examples to encourage best practices of CI setups while keeping the testing setup manageable on our end (each example controlling its own CI). I think if I invert the control here, and let each example define its own workflow and then the top-level one just reuse those, we can get the best of both worlds:

  • Each example has a precise control over the workflow it needs to be tested;
  • Each examples ships with a workflow that illustrates how to set it up in GitHub Actions for our users browsing the example.
  • We can reuse each individual example's workflow from the top-level job on our end to have example-driven automation.

The current setup is somewhat closer to what I found on GitHub docs:

  • A template job is defined to apply to all examples by path.
  • Root-level workflow does the matching of the template job + example, controlling what to run.

I think we should be able to move that "template" to examples themselves. Will prepare a commit that illustrates that.

@kettanaito kettanaito force-pushed the test/example-as-test branch 7 times, most recently from 976a74f to 4f3fc37 Compare August 3, 2023 09:57
@kettanaito
Copy link
Contributor Author

kettanaito commented Aug 3, 2023

Alas, that's not going to work. GitHub Actions require reusable workflows to be on the root level of ./.github/workflows (quote). So placing a workflow next to the example and then referencing from the root-level workflows errors.

I've tried an absolute reference to the nested workflow (through org/repo and branch/hash), which fails.

I've tried symlinks as well, but GitHub doesn't resolve them; it actually tries to read as symlink as a binary and fails.

GitHub also doesn't preview symlinks, which hurts discoverability one way or another.

@kettanaito kettanaito force-pushed the test/example-as-test branch 2 times, most recently from 88f8346 to 897e56e Compare August 4, 2023 10:15
@kettanaito
Copy link
Contributor Author

I've opened artilleryio/action-cli#9 to support running our example tests against the current build of Artillery. Once that's released, I can update the tests to point to the in-repo version of the CLI so tests help us catch regressions before they are merged.

@kettanaito kettanaito force-pushed the test/example-as-test branch 2 times, most recently from 8869bef to c24a840 Compare August 7, 2023 10:37
@kettanaito kettanaito marked this pull request as ready for review August 7, 2023 10:44
@kettanaito
Copy link
Contributor Author

With artilleryio/action-cli#9 merged, I've updated the test workflows to point to the local version of Artillery CLI. All the introduced examples are not passing against that version 🎉 This will help us catch any regressions faster.

There are no more changes necessary to merge this. Ready for review.

@hassy
Copy link
Member

hassy commented Aug 9, 2023

Looks good to go! :shipit: Could you update the commit log before merge to remove WIP commits.

chore: set job timeout to 60 minutes

chore: define workflow next to the example
chore: patch artillery binary

chore: remove install steps from tests

chore: set custom "working-directory" for tests
chore: use absolute artillery binary path

chore: add install step to use custom binary
@kettanaito
Copy link
Contributor Author

@hassy, I grouped the commits to reflect finite changes. Will wait for the CI and merge this.

Copy link
Member

@hassy hassy left a comment

Choose a reason for hiding this comment

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

:shipit:

@kettanaito kettanaito merged commit 230e1d8 into main Aug 11, 2023
6 checks passed
@kettanaito kettanaito deleted the test/example-as-test branch August 11, 2023 14:03
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.

3 participants