Skip to content

Commit

Permalink
Drop Workflow Id From Snapshot When Pulling With CLI (#2467)
Browse files Browse the repository at this point in the history
  • Loading branch information
elias-ba authored Sep 5, 2024
1 parent 4ba12e9 commit 183fa0c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ and this project adheres to

### Fixed

- Fix `workflow_id` presence in state.json during Github sync
[#2445](https://github.com/OpenFn/lightning/issues/2445)

## [v2.8.2] - 2024-09-04

### Added
Expand Down
3 changes: 3 additions & 0 deletions lib/lightning_web/controllers/api/provisioning_json.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ defmodule LightningWeb.API.ProvisioningJSON do

workflow_or_snapshot
|> Ecto.embedded_dump(:json)
|> Map.take(
~w(id name inserted_at updated_at deleted_at lock_version concurrency)a
)
|> Map.put(:id, workflow_id)
|> Map.put(
:jobs,
Expand Down
12 changes: 11 additions & 1 deletion test/integration/cli_deploy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,17 @@ defmodule Lightning.CliDeployTest do
end

defp expected_workflow_state(workflow) do
state = Map.take(workflow, Lightning.Workflows.Workflow.__schema__(:fields))
state =
workflow
|> Map.take([
:id,
:name,
:inserted_at,
:updated_at,
:deleted_at,
:lock_version,
:concurrency
])

jobs =
Map.new(workflow.jobs, fn job ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,16 @@ defmodule LightningWeb.API.ProvisioningControllerTest do

assert project.name == "test-project"

assert workflows |> Enum.all?(&match?(%{"project_id" => ^project_id}, &1)),
workflow_ids = Enum.map(workflows, fn w -> w["id"] end)

parent_project_ids =
from(w in Workflow,
where: w.id in ^workflow_ids
)
|> Repo.all()
|> Enum.map(fn w -> w.project_id end)

assert parent_project_ids |> Enum.all?(&match?(^project_id, &1)),
"All workflows should belong to the same project"

workflow =
Expand Down

0 comments on commit 183fa0c

Please sign in to comment.