|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require "spec_helper" |
| 4 | +require "yaml" |
| 5 | + |
| 6 | +RSpec.describe "GitHub workflow definitions" do # rubocop:disable RSpec/DescribeClass |
| 7 | + describe "Delete Review App workflow" do |
| 8 | + let(:workflow) do |
| 9 | + YAML.safe_load_file( |
| 10 | + File.expand_path("../.github/workflows/cpflow-delete-review-app.yml", __dir__), |
| 11 | + aliases: true |
| 12 | + ) |
| 13 | + end |
| 14 | + |
| 15 | + let(:steps) { workflow.fetch("jobs").fetch("delete-review-app").fetch("steps") } |
| 16 | + |
| 17 | + def step_named(name) |
| 18 | + steps.find { |step| step["name"] == name } |
| 19 | + end |
| 20 | + |
| 21 | + it "runs cpflow delete from a downstream app checkout" do |
| 22 | + expect(step_named("Checkout repository")).to include( |
| 23 | + "uses" => "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd", |
| 24 | + "with" => include( |
| 25 | + "path" => "app", |
| 26 | + "persist-credentials" => false |
| 27 | + ) |
| 28 | + ) |
| 29 | + |
| 30 | + expect(step_named("Setup environment").fetch("with")).to include( |
| 31 | + "working_directory" => "app" |
| 32 | + ) |
| 33 | + expect(step_named("Delete review app").fetch("with")).to include( |
| 34 | + "working_directory" => "app" |
| 35 | + ) |
| 36 | + end |
| 37 | + end |
| 38 | + |
| 39 | + describe "Delete Control Plane App action" do |
| 40 | + let(:action) do |
| 41 | + YAML.safe_load_file( |
| 42 | + File.expand_path("../.github/actions/cpflow-delete-control-plane-app/action.yml", __dir__), |
| 43 | + aliases: true |
| 44 | + ) |
| 45 | + end |
| 46 | + |
| 47 | + it "allows callers to choose the project working directory" do |
| 48 | + expect(action.fetch("inputs")).to include( |
| 49 | + "working_directory" => include("default" => ".") |
| 50 | + ) |
| 51 | + |
| 52 | + delete_step = action.fetch("runs").fetch("steps").find { |step| step["name"] == "Delete application" } |
| 53 | + |
| 54 | + expect(delete_step).to include( |
| 55 | + "working-directory" => "${{ inputs.working_directory }}" |
| 56 | + ) |
| 57 | + end |
| 58 | + end |
| 59 | +end |
0 commit comments