Skip to content

[AUTOWORK-206] Convert automation actions to an STI table like conditions - #25159

Open
oliverguenther wants to merge 3 commits into
feat/automations-namespacefrom
feat/automations-sti-table
Open

oliverguenther wants to merge 3 commits into
feat/automations-namespacefrom
feat/automations-sti-table

Conversation

@oliverguenther

@oliverguenther oliverguenther commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

Replaces actions which were inline YAML references with an STI table to match functionality of conditions, and add stronger type checking, allowing more flexibility for future automations work

https://community.openproject.org/work_packages/AUTOWORK-206

@oliverguenther
oliverguenther changed the base branch from dev to feat/automations-namespace September 7, 2026 11:29
@oliverguenther oliverguenther changed the title Rename CustomAction to Automation and add trigger functionality Convert automation actions to an STI table like conditions Sep 7, 2026
@oliverguenther oliverguenther changed the title Convert automation actions to an STI table like conditions [AUTOWORK-206] Convert automation actions to an STI table like conditions Sep 7, 2026
@oliverguenther
oliverguenther force-pushed the feat/automations-sti-table branch from b3103fc to af72a75 Compare September 7, 2026 12:30
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/gantt/spec/features/timeline/timeline_dates_spec.rb[1:2:1]
  • rspec ./spec/features/activities/work_package/activities_spec.rb[1:12:4:1:1]
  • rspec ./spec/features/roles/report_spec.rb[1:1]
  • rspec ./spec/features/roles/report_spec.rb[1:2]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #25159, linked for reference only):

- `rspec ./modules/gantt/spec/features/timeline/timeline_dates_spec.rb[1:2:1]`
- `rspec ./spec/features/activities/work_package/activities_spec.rb[1:12:4:1:1]`
- `rspec ./spec/features/roles/report_spec.rb[1:1]`
- `rspec ./spec/features/roles/report_spec.rb[1:2]`

Treat this as a standalone task, unrelated to PR #25159. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #25159 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @oliverguenther to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @oliverguenther, and request a review from @oliverguenther.
On every commit, set @oliverguenther as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@oliverguenther
oliverguenther force-pushed the feat/automations-sti-table branch 2 times, most recently from 375f43b to 93c2087 Compare September 8, 2026 09:18
@opf opf deleted a comment from github-actions Bot Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
1 Warning
⚠️ Attention developer & reviewer: migration looks up an index by hardcoded name:

  • db/migrate/20260907113318_convert_custom_actions_to_automations.rb

remove_index ..., name: and rename_index MAY fail when the live name differs from
the canonical one (for example, old databases pgloader prefixes MySQL indexes with idx_<oid>_; pre-squash
databases may still use the original migration name).

Please use Migration::Utils instead:

require Rails.root.join("db/migrate/migration_utils/utils")

class SomeMigration < ActiveRecord::Migration[8.0]
  include Migration::Utils

  def up
    remove_index_on :workflows, "wkfs_role_type_old_status", %w[role_id type_id old_status_id]
    rename_index_on :workflows, "wkfs_role_type_old_status", "wkfs_role_type_variant_old_status",
                    %w[role_id type_id old_status_id]
  end
end

Those helpers match the given name, or the name with pgloader prefix, then fall back to columns.

Generated by 🚫 Danger

@oliverguenther
oliverguenther force-pushed the feat/automations-sti-table branch from 93c2087 to d303be4 Compare September 8, 2026 09:20
@oliverguenther
oliverguenther marked this pull request as ready for review September 8, 2026 09:21
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Caution

The provided work package version does not match the core version

Details:

Please make sure that:

  • The work package version OR your pull request target branch is correct

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/meeting/spec/features/meeting_notifications_spec.rb[1:2:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #25159, linked for reference only):

- `rspec ./modules/meeting/spec/features/meeting_notifications_spec.rb[1:2:1]`

Treat this as a standalone task, unrelated to PR #25159. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #25159 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @oliverguenther to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @oliverguenther, and request a review from @oliverguenther.
On every commit, set @oliverguenther as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/overviews/spec/features/managing_dashboard_page_spec.rb[1:1:1]
  • rspec ./spec/features/projects/creation_wizard/wizard_from_template_flow_spec.rb[1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #25159, linked for reference only):

- `rspec ./modules/overviews/spec/features/managing_dashboard_page_spec.rb[1:1:1]`
- `rspec ./spec/features/projects/creation_wizard/wizard_from_template_flow_spec.rb[1:1]`

Treat this as a standalone task, unrelated to PR #25159. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #25159 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @oliverguenther to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @oliverguenther, and request a review from @oliverguenther.
On every commit, set @oliverguenther as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@oliverguenther
oliverguenther force-pushed the feat/automations-sti-table branch from 217c5ee to c961300 Compare September 9, 2026 13:20
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/work_packages/details/inplace_editor/version_editor_spec.rb[1:1:2]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #25159, linked for reference only):

- `rspec ./spec/features/work_packages/details/inplace_editor/version_editor_spec.rb[1:1:2]`

Treat this as a standalone task, unrelated to PR #25159. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #25159 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @oliverguenther to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @oliverguenther, and request a review from @oliverguenther.
On every commit, set @oliverguenther as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@dfriquet dfriquet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm still working through this PR (quite dense, honestly), but here are my first UI findings.

errors.add(:actions, :empty) if model.actions.empty?
model.actions.each { |action| action.validate(errors) }
live_actions = model.actions.reject(&:marked_for_destruction?)
errors.add(:actions, :empty) if live_actions.empty?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

 I18n::MissingTranslationData in Automations#update

Showing /home/dev/openproject/app/views/automations/edit.html.erb where line #45 raised:

Translation missing. Options considered were:
- en.activerecord.attributes.automation.actions
- en.attributes.actions
- en.activerecord.models.actions

Comment on lines +47 to 49
def write_raw_values(new_values)
self.options = options.is_a?(Hash) ? options.merge("values" => Array(new_values)) : { "values" => Array(new_values) }
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I’ve got mixed feelings about this method.

In the first place, it could make good use of store_attribute:

Suggested change
def write_raw_values(new_values)
self.options = options.is_a?(Hash) ? options.merge("values" => Array(new_values)) : { "values" => Array(new_values) }
end
def write_raw_values(new_values)
write_store_attribute(:options, :values, Array(new_values))
end

As it is only expected to be called by subclasses, it should be protected. I even wonder if the subclasses should be allowed to call write_store_attribute themselves, and remove this method altogether.

automation.actions.reject! { |a| a.key == key }
new_action = template.dup
new_action.values = values
automation.actions << new_action

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When an automation is edited, a rejected update still persists newly added actions.

automation.actions << new_action inserts immediately on a persisted parent, but contract.validate runs afterwards with no transaction. So the new action is written to the DB whereas the the update is not successful because of a too long name for example.

@@ -28,7 +28,7 @@ See COPYRIGHT and LICENSE files for more details.
++#%>

<% active_section_keys = @automation.actions.map(&:key) %>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

actions does not exclude those marked for deletion, so on re-render after a validation error they come back as active 🧟

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This index breaks when an automation configures an action on a custom field and that same custom field is deleted afterwards.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants