-
Notifications
You must be signed in to change notification settings - Fork 5
Fix review app delete project checkout #307
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||||
| # frozen_string_literal: true | ||||||||
|
|
||||||||
| require "spec_helper" | ||||||||
| require "yaml" | ||||||||
|
|
||||||||
| RSpec.describe "GitHub workflow definitions" do # rubocop:disable RSpec/DescribeClass | ||||||||
| describe "Delete Review App workflow" do | ||||||||
| let(:workflow) do | ||||||||
| YAML.safe_load_file( | ||||||||
| File.expand_path("../.github/workflows/cpflow-delete-review-app.yml", __dir__), | ||||||||
| aliases: true | ||||||||
| ) | ||||||||
| end | ||||||||
|
|
||||||||
| let(:steps) { workflow.fetch("jobs").fetch("delete-review-app").fetch("steps") } | ||||||||
|
|
||||||||
| def step_named(name) | ||||||||
| steps.find { |step| step["name"] == name } | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a step name is not found,
Suggested change
|
||||||||
| end | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a step is renamed or removed,
Suggested change
|
||||||||
|
|
||||||||
| it "runs cpflow delete from a downstream app checkout" do | ||||||||
| expect(step_named("Checkout repository")).to include( | ||||||||
| "uses" => "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd", | ||||||||
| "with" => include( | ||||||||
| "path" => "app", | ||||||||
| "persist-credentials" => false | ||||||||
| ) | ||||||||
| ) | ||||||||
|
|
||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spec does not assert the expect(step_named("Checkout repository")).to include(
"if" => "steps.config.outputs.ready == 'true'"
) |
||||||||
| expect(step_named("Setup environment").fetch("with")).to include( | ||||||||
| "working_directory" => "app" | ||||||||
| ) | ||||||||
| expect(step_named("Delete review app").fetch("with")).to include( | ||||||||
| "working_directory" => "app" | ||||||||
| ) | ||||||||
| end | ||||||||
|
Comment on lines
+21
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The "Checkout repository" step carries Consider asserting
Comment on lines
+21
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test validates the checkout step's expect(step_named("Checkout repository")).to include(
"if" => "steps.config.outputs.ready == 'true'"
) |
||||||||
| end | ||||||||
|
|
||||||||
| describe "Delete Control Plane App action" do | ||||||||
| let(:action) do | ||||||||
| YAML.safe_load_file( | ||||||||
| File.expand_path("../.github/actions/cpflow-delete-control-plane-app/action.yml", __dir__), | ||||||||
| aliases: true | ||||||||
| ) | ||||||||
| end | ||||||||
|
|
||||||||
| it "allows callers to choose the project working directory" do | ||||||||
| expect(action.fetch("inputs")).to include( | ||||||||
| "working_directory" => include("default" => ".") | ||||||||
| ) | ||||||||
|
|
||||||||
| delete_step = action.fetch("runs").fetch("steps").find { |step| step["name"] == "Delete application" } | ||||||||
|
|
||||||||
| expect(delete_step).to include( | ||||||||
| "working-directory" => "${{ inputs.working_directory }}" | ||||||||
| ) | ||||||||
| end | ||||||||
| end | ||||||||
| end | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
working_directorywas previously.cpflow(the cpflow repo checkout). Changing it toapp(the downstream caller repo) means Ruby version detection now reads the downstream project's.ruby-version/.tool-versions/Gemfile— which is the correct behaviour since cpflow needs to run in the app's Ruby environment. A short comment here would make this non-obvious choice self-documenting for future maintainers.