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

feat: adapt build plugin implementation to new API #319

Merged
merged 10 commits into from
Nov 6, 2023
Merged

Conversation

swaldmann
Copy link
Contributor

@swaldmann swaldmann commented Oct 23, 2023

requires @sap/cds-dk 7.3.2

postgres/CHANGELOG.md Outdated Show resolved Hide resolved
@swaldmann swaldmann changed the title Adapt build plugin implementation to new API feat: adapt build plugin implementation to new API Oct 23, 2023
@swaldmann swaldmann marked this pull request as draft October 23, 2023 15:09
@swaldmann
Copy link
Contributor Author

Holding off for cds-dk 7.3.2

const { fs, path, rimraf } = cds.utils

module.exports = class PostgresBuildPlugin extends BuildPlugin {
static hasTask() { // REVISIT: should be unnecessary -> plugin mechanism knows what to pull
Copy link
Contributor

@LotharBender LotharBender Oct 23, 2023

Choose a reason for hiding this comment

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

The hasTask impl has ensured that a postgres build task is only executed if a postgres database is used according to the effective cds configuration. E.g. a sqlite database might have been configured for the development profile.
Of course, this might be an edge case, but on the other hand the check is simple and ensures that users don't get surprised if cds build is executed with development profile ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, unfortunately I also don't see another way to make it work properly w/ the profile technique where you switch between HANA/Postgres based on config profiles. I re-added the hasTask again.

Copy link
Contributor

Choose a reason for hiding this comment

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

...unfortunately? - I think this is a perfect solution :)

Copy link
Contributor Author

@swaldmann swaldmann Oct 27, 2023

Choose a reason for hiding this comment

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

I think it's close to perfect, but ideally the plugin doesn't handle what the plugin orchestrator in cap/cds should do, deciding which plugins to pull.

I'd rather have an opt-out mechanism like this instead, which is then also combinable with profiles:

"cds": {
  "requires": {
      "plugins": {
        "[pg]":  {
          "@sap/cds-hana": false
        },
        "[hana]": {
          "@cap-js/postgres": false
        }
     }
  }
}

Opting out in non-centralized places like the build plugin introduces inconsistent behavior, e.g. the plugin will still show up as loaded with DEBUG=plugins.

Also, it reduces the number of functions you have to implement from 2 to 1, which is huge imo.

@danjoa What's your take on this?

Copy link
Contributor

@LotharBender LotharBender Oct 30, 2023

Choose a reason for hiding this comment

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

But isn't this more a question of different lifecycles for cds plugin versus cds build task. Loading the cds plugin does not necessarily mean that a corresponding build task respectively its BuildPlugin counterpart will get executed.

I think the cds add plugin would behave similar. A cds plugin will be loaded, but the concrete cds facet implementation might not, as this is determined using the concrete cds add command line parameters or some other facet dependencies.

postgres/cds-plugin.js Outdated Show resolved Hide resolved
postgres/cds-plugin.js Outdated Show resolved Hide resolved
@LotharBender LotharBender marked this pull request as ready for review November 3, 2023 13:57
@LotharBender
Copy link
Contributor

Would be great if we could ship this version soon as the current postgres plugin version does not support @sap/cds-dk 7.3.2. See https://github.tools.sap/cap/issues/issues/14748

@swaldmann swaldmann enabled auto-merge (squash) November 3, 2023 15:15
@swaldmann
Copy link
Contributor Author

Open points re simplifications to be discussed in follow-up.

@swaldmann
Copy link
Contributor Author

@patricebender @johannes-vogel Can we ignore HANA tests for changes in cds-dbs/postgres in GHA? Or rather an opt-in and just run HANA integration tests for changes in db-service, test, and hana?

@swaldmann swaldmann merged commit aec9966 into main Nov 6, 2023
6 checks passed
@swaldmann swaldmann deleted the new-build-api branch November 6, 2023 08:00
@cap-bots cap-bots mentioned this pull request Nov 6, 2023
@cap-bots cap-bots mentioned this pull request Jul 25, 2024
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.

4 participants