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: standard build #1201

Merged
merged 11 commits into from
Nov 7, 2021
Merged

feat: standard build #1201

merged 11 commits into from
Nov 7, 2021

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Nov 3, 2021

Define a common build process for all projects which includes a set of standard phases that can be used for extensibility. The idea is that components and project types will have a solid foundation for build extensions instead of ad-hoc set of tasks for each project.

The build task now spawns a set of standard build phase tasks:

  • default (synthesize project - executes your projenrc).
  • pre-compile
  • compile
  • post-compile
  • test
  • package

The Project base class now has a set of properties that can be used to access these tasks. For example, project.postcompileTask will return the Task that’s executed after compilation.

The method task.lock() can now be used to lock a task for mutations. The build task is now locked, which means that any modifications to it will throw an exception.

This change also includes some logging improvements and cleanups.

This is an attempt to create generic build model for all project types. We shall see if this holds water.

BREAKING CHANGE: It is now impossible to modify the build task. Instead, extend one of the specific build phases (precompile, compile, post compile, test and package). To access these tasks use project.xxxTask.

  • The compileBeforeTest option in TypeScriptProject is not supported any more. Tests are always executed after compilation.
  • projenDuringBuild is no longer supported. Let us know if you have a use case for it that we are not aware of.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Define a common build process for all projects which includes a set of standard phases that can be used for extensibility. The idea is that components and project types will have a solid foundation for build extensions instead of ad-hoc set of tasks for each project.

The `build` task now spawns a set of standard build phase tasks:
- `default` (synthesize project runs - executes your projenrc).
- `precompile`
- `compile`
- `postcompile`
- `test`
- `package`

The `Project` base class now has a set of properties that can be used to access these tasks. For example, `project.postcompileTask` will return the `Task` that’s executed after compilation.

The method `task.lock()` can now be used to lock a task for mutations. The `build` task is now locked, which means that any modifications to it will throw an exception.

This change also includes some logging improvements and cleanups.

This is an attempt to create generic build model for all project types. We shall see if this holds water.

BREAKING CHANGE: It is now impossible to modify the `build` task. Instead, extend one of the specific build phases (`precompile`, `compile`, `post compile`, `test` and `package`). To access these tasks use `project.xxxTask`.
* The `compileBeforeTest` option in `TypeScriptProject` is not supported any more. Tests are always executed _after_ compilation.
@mergify mergify bot added the contribution/core ⚙️ used by automation label Nov 3, 2021
@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2021

Codecov Report

Merging #1201 (3f26529) into main (377966e) will increase coverage by 8.98%.
The diff coverage is 89.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1201      +/-   ##
==========================================
+ Coverage   78.46%   87.45%   +8.98%     
==========================================
  Files          88      126      +38     
  Lines        3181     4773    +1592     
  Branches      809     1247     +438     
==========================================
+ Hits         2496     4174    +1678     
+ Misses        683      561     -122     
- Partials        2       38      +36     
Impacted Files Coverage Δ
src/clobber.ts 100.00% <ø> (ø)
src/github/index.ts 100.00% <ø> (ø)
src/java/pom.ts 93.84% <ø> (ø)
src/object-file.ts 100.00% <ø> (+2.38%) ⬆️
src/typescript-typedoc.ts 20.00% <0.00%> (-13.34%) ⬇️
src/typescript.ts 94.73% <ø> (-0.82%) ⬇️
src/typescript/index.ts 100.00% <ø> (ø)
src/typescript/projenrc.ts 61.53% <ø> (ø)
src/upgrade-dependencies.ts 100.00% <ø> (ø)
src/util.ts 92.37% <ø> (+5.70%) ⬆️
... and 123 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1378684...3f26529. Read the comment docs.

docs/project.md Outdated Show resolved Hide resolved
@iliapolo iliapolo self-requested a review November 3, 2021 22:57
Copy link
Contributor

@Chriscbr Chriscbr left a comment

Choose a reason for hiding this comment

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

Cool stuff! I'm curious to see if this holds water as well.



Thinking about the task system more broadly, I think our current model still leaves us open for adding features like parallel tasks, or task arguments, etc. down the line, which is good.



While reviewing this I also had an idea about whether we might want to specify tasks/commands within the build steps that should only run when in a CI environment like GitHub actions. Requires some more thought...

docs/project.md Outdated Show resolved Hide resolved
src/javascript/projenrc.ts Show resolved Hide resolved
src/logging.ts Show resolved Hide resolved
src/project.ts Outdated Show resolved Hide resolved
src/project.ts Outdated Show resolved Hide resolved
cdklabs-automation and others added 6 commits November 7, 2021 09:05
Upgrades project dependencies. See details in [workflow run].

[Workflow Run]: https://github.com/projen/projen/actions/runs/1419236426

------

*Automatically created by projen via the "upgrade-main" workflow*
Upgrades project dependencies. See details in [workflow run].

[Workflow Run]: https://github.com/projen/projen/actions/runs/1423753266

------

*Automatically created by projen via the "upgrade-main" workflow*
Adds `mergifyOptions` as a field for `GitHub` so it can now be configured like so:

```ts
const project = new TypeScriptProject({
  // ...
  githubOptions: {
    mergifyOptions: {
      // rules: ...
    },
  },
});
```

Moves the (deprecated) `mergifyOptions` from `NodeProject` to `GitHubProject`.

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Upgrades project dependencies. See details in [workflow run].

[Workflow Run]: https://github.com/projen/projen/actions/runs/1427850443

------

*Automatically created by projen via the "upgrade-main" workflow*
Upgrades project dependencies. See details in [workflow run].

[Workflow Run]: https://github.com/projen/projen/actions/runs/1430259554

------

*Automatically created by projen via the "upgrade-main" workflow*
But still expose properties at the Project level for discoverability and easy access.
@eladb eladb requested a review from Chriscbr November 7, 2021 12:32
@mergify mergify bot merged commit 2b38918 into main Nov 7, 2021
@mergify mergify bot deleted the eladb/standard-tasks branch November 7, 2021 21:44
njlynch added a commit to cdklabs/construct-hub-webapp that referenced this pull request Nov 8, 2021
A recent feature to projen (projen/projen#1201) changed
the way that build tasks work. This breaks the upgrade workflow for this (and
several other projects).
mergify bot pushed a commit to cdklabs/construct-hub-webapp that referenced this pull request Nov 8, 2021
A recent feature to projen (projen/projen#1201) changed
the way that build tasks work. This breaks the upgrade workflow for this (and
several other projects).
njlynch added a commit to cdklabs/publib that referenced this pull request Nov 8, 2021
A recent feature to projen (projen/projen#1201) changed
the way that build tasks work. This breaks the upgrade workflow for this (and
several other projects).
mergify bot pushed a commit to cdklabs/publib that referenced this pull request Nov 8, 2021
A recent feature to projen (projen/projen#1201) changed
the way that build tasks work. This breaks the upgrade workflow for this (and
several other projects).
@alexforsyth
Copy link
Contributor

@eladb im having an issue after removing no projenDuringBuild. Basically I have a bunch of projen projects inside a yarn2 workspace, and I can't be running yarn install --check-files. I need to be able to skip the projen during build part.

Is there a way to re-enable this?

@alexforsyth
Copy link
Contributor

I suppose I can still use PROJEN_DISABLE_POST=1, but that seems not ideal

@Chriscbr
Copy link
Contributor

Chriscbr commented Nov 9, 2021

@alexforsyth Can you try project.default.reset() ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core ⚙️ used by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants