Skip to content

Commit 00df008

Browse files
committed
[FEAT packages] introduce build-infra package
1 parent 1794b06 commit 00df008

58 files changed

Lines changed: 457 additions & 531 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = {
4646
files: [
4747
'.eslintrc.js',
4848
'.prettierrc.js',
49+
'packages/-build-infra/src/**/*.js',
4950
'packages/*/ember-cli-build.js',
5051
'packages/*/index.js',
5152
'packages/*/testem.js',
@@ -76,7 +77,7 @@ module.exports = {
7677

7778
// node tests
7879
{
79-
files: ['packages/*/node-tests/**'],
80+
files: ['packages/*/node-tests/**', 'node-tests/**'],
8081

8182
env: {
8283
mocha: true,

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ stages:
3232
jobs:
3333
fail_fast: true
3434
allow_failures:
35-
- name: "emberaddons.com"
35+
- name: 'Ember Data Factory Guy'
3636

3737
include:
3838
# runs tests with current locked deps and linting
@@ -46,10 +46,11 @@ jobs:
4646
script: yarn test
4747

4848
- stage: additional tests
49-
name: 'Optional Features'
49+
50+
name: 'Enabled In-Progress Features'
5051
if: NOT (branch ~= /^(release|lts).*/)
5152
install: yarn install
52-
script: yarn test:optional-features
53+
script: yarn test:enabled-in-progress-features
5354

5455
- name: 'Floating Dependencies'
5556
install: yarn install --no-lockfile --non-interactive

CONTRIBUTING.md

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,65 @@ All commits should be tagged. Tags are denoted by square brackets (`[]`) and com
106106
In general almost all commits should fall into one of the above categories. In the cases where they don't please submit
107107
your PR untagged.
108108

109-
#### Developing a New Feature with Feature Flags
109+
#### Developing a New Feature with in-progress-feature Flags
110110

111-
Sometimes a new feature will require use of a feature flag.
111+
Sometimes a new feature can't be completed all at once, but portions
112+
of it can be landed to help parallelize the effort and make the review
113+
process simpler.
112114

113-
Feature flags allow new features to be tested in dev builds, but
114-
the features are stripped out of production builds automatically.
115+
`in-progress-feature` flags allow for code to be present on the `master`
116+
branch but stripped from any build that isn't.
115117

116-
1. Add your new feature flag to the [config/features.json](https://github.com/emberjs/data/blob/master/config/features.json) file.
118+
These flags have three states. Locally here means that a developer is
119+
working within the `addon` itself. Locally linking `ember-data` to
120+
another project or using a `master` build will not make code behind
121+
the flags available unless `isDevelopingAddon` in `index.js` is modified
122+
to return `true`.
123+
124+
- `false`: the feature is only available locally and the code behind the
125+
flag is stripped at all times and never included in test runs. To develop
126+
on this feature use `--enable-in-progress-flag="desired-flag-name,another-flag-name"`
127+
when running a command. This flag will never be active in `CI` jobs
128+
meaning that both tests and code wrapped in a check for this flag will
129+
not run.
130+
131+
- `null`: The same as `false` except the `Enabled In-Progress Features`
132+
job in `CI` will activate the flag to ensure it passes tests.
133+
Use this for features that are nearing delivery and need protection
134+
against regressions but are not quite polished off yet.
135+
136+
Other test runs and `CI` will still default the flag to `false` to ensure
137+
that what we would release (were we to release master) works as
138+
expected.
139+
140+
The `--enable-in-progress` flag and the Travis Job `Enabled In-Progress Features`
141+
will run the tests with any flags set to `null` enabled to prevent
142+
regressions.
143+
144+
- `true`: Indicates that this feature is "complete". Features set to
145+
`true` will be included in any `release` published while the flag
146+
is in that state, any build from `master` and all `CI` jobs.
147+
148+
This is a sign that the feature has entered a final testing phase
149+
and the in-progress flags for the feature should be removed
150+
before a stable release is published.
151+
152+
Sometimes a nearly releasable feature may encounter problems late
153+
in the release cycle. For such problems, the flag should be moved
154+
back to the `null` state prior to doing a release.
155+
156+
Versions published with a flag set to `true` will include that
157+
feature.
158+
159+
1. Add your new feature flag to the [config/in-progress-features.json](https://github.com/emberjs/data/blob/master/config/in-progress-features.json) file with the `ds-` prefix.
117160

118161
```js
119162
{
120-
"ds-boolean-transform-allow-null": null,
121-
"ds-mynew-feature": null
163+
"ds-mynew-feature": false
122164
}
123165
```
124166

125-
Give it a default of `null` so it will not be used in production builds.
167+
Give it a default of `false` so it will not be used in production builds.
126168

127169
2. Import `isEnabled` from `ember-data/-private`, wrapping any new
128170
code with your feature:
@@ -152,19 +194,12 @@ if (isEnabled('ds-mynew-feature')) {
152194

153195
This will ensure these feature tests are only run when then feature is included in the build for `ember-data`.
154196

155-
4. Running tests with all feature flags enabled is possible via
156-
`ember test --environment=test-optional-features` This is also possible while
157-
running tests in the browser via the `Enable Opt Feature` checkbox.
158-
159-
5. Add your feature to the [Features](https://github.com/emberjs/data/blob/master/FEATURES.md) file.
160-
Be sure to leave a description of the feature and possible example of how to
161-
use it (if necessary).
162-
163-
For more information about commit prefixes see [Commit Tagging](#commit-tagging).
197+
4. Commit your work. For more information about commit prefixes see [Commit Tagging](#commit-tagging).
164198

165-
6. Push to your fork and submit a pull request. Please provide us with some
199+
5. Push to your fork and submit a pull request. Please provide us with some
166200
explanation of why you made the changes you made. For new features make sure to
167-
explain a standard use case to us.
201+
explain a standard use case to us. Use the commit tagging guidelines for the PR
202+
title.
168203

169204
## Notes
170205

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ install:
1919
test_script:
2020
# Output useful info for debugging.
2121
- cmd: yarn test
22-
- cmd: yarn test:optional-features
22+
- cmd: yarn test:enabled-in-progress-features
2323
- cmd: yarn test:production
2424
- cmd: yarn test:node
2525

bin/lint-features

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,25 @@
22
const fs = require('fs');
33
const path = require('path');
44

5-
const PKG_ROOT = path.join(__dirname, '../packages');
6-
const PATH_TO_CONFIG = 'config/features.json';
7-
const packages = fs.readdirSync(PKG_ROOT);
5+
const configPath = path.join(
6+
__dirname,
7+
'../packages/-build-infra/config/in-progress-features.json'
8+
);
89
const beginsWithDS = /^ds-/;
910
const violations = [];
1011

11-
packages.forEach(function(package) {
12-
const configPath = path.join(PKG_ROOT, package, PATH_TO_CONFIG);
13-
if (fs.existsSync(configPath)) {
14-
const features = require(configPath);
15-
Object.keys(features).forEach(function(feature) {
16-
if (!beginsWithDS.exec(feature)) {
17-
violations.push('"' + feature + '" in @ember-data/' + package);
18-
}
19-
});
20-
}
21-
});
12+
if (fs.existsSync(configPath)) {
13+
const features = require(configPath);
14+
Object.keys(features).forEach(function(feature) {
15+
if (!beginsWithDS.exec(feature)) {
16+
violations.push(feature);
17+
}
18+
});
19+
}
2220

2321
if (violations.length) {
2422
console.log(
25-
'Features in features.json MUST begin with `ds-`! These features do not:\n\t',
23+
'Features in in-progress-features.json MUST begin with `ds-`! These features do not:\n\t',
2624
violations.join('\n\t')
2725
);
2826
process.exit(1);

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515
"test:node": "yarn workspace ember-data node node-tests/nodetest-runner.js",
1616
"test:production": "yarn workspace ember-data test:production",
1717
"test:try-one": "yarn workspace ember-data test:try-one",
18-
"test:optional-features": "yarn workspace ember-data test:optional-features",
19-
"test-external:ember-m3": "yarn workspace ember-data test-external:ember-m3",
20-
"test-external:ember-data-change-tracker": "yarn workspace ember-data test-external:ember-data-change-tracker",
21-
"test-external:emberaddons.com": "yarn workspace ember-data test-external:emberaddons.com",
22-
"test-external:model-fragments": "yarn workspace ember-data test-external:model-fragments",
23-
"test-external:ember-observer": "yarn workspace ember-data test-external:ember-observer",
24-
"test-external:travis-web": "yarn workspace ember-data test-external:travis-web",
25-
"test-external:storefront": "yarn workspace ember-data test-external:storefront",
26-
"test-external:factory-guy": "yarn workspace ember-data test-external:factory-guy",
27-
"test-external:ilios-frontend": "yarn workspace ember-data test-external:ilios-frontend",
28-
"test-external:ember-resource-metadata": "yarn workspace ember-data test-external:ember-resource-metadata",
29-
"test-external:ember-data-relationship-tracker": "yarn workspace ember-data test-external:ember-data-relationship-tracker"
18+
"test:enabled-in-progress-features": "yarn workspace ember-data test --enable-in-progress",
19+
"test-external:ember-m3": "test-external-partner ember-m3 https://github.com/hjdivad/ember-m3.git",
20+
"test-external:ember-data-change-tracker": "test-external-partner ember-data-change-tracker https://github.com/danielspaniel/ember-data-change-tracker.git",
21+
"test-external:emberaddons.com": "test-external-partner ember-cli-addon-search https://github.com/gcollazo/ember-cli-addon-search.git",
22+
"test-external:model-fragments": "test-external-partner ember-data-model-fragments https://github.com/lytics/ember-data-model-fragments.git",
23+
"test-external:ember-observer": "test-external-partner ember-observer https://github.com/emberobserver/client.git",
24+
"test-external:travis-web": "test-external-partner travis-web https://github.com/travis-ci/travis-web.git",
25+
"test-external:storefront": "test-external-partner storefront https://github.com/embermap/ember-data-storefront.git",
26+
"test-external:factory-guy": "test-external-partner factory-guy https://github.com/danielspaniel/ember-data-factory-guy.git",
27+
"test-external:ilios-frontend": "test-external-partner ilios-frontend https://github.com/ilios/frontend.git --skip-smoke-test",
28+
"test-external:ember-resource-metadata": "test-external-partner ember-resource-metadata https://github.com/ef4/ember-resource-metadata.git",
29+
"test-external:ember-data-relationship-tracker": "test-external-partner ember-data-relationship-tracker https://github.com/ef4/ember-data-relationship-tracker.git"
3030
},
3131
"devDependencies": {
32-
"lerna": "^3.13.2",
3332
"@babel/plugin-transform-typescript": "^7.2.0",
3433
"@ember-decorators/babel-transforms": "^5.2.0",
3534
"@ember-decorators/data": "^5.1.4",
@@ -61,6 +60,7 @@
6160
"ember-cli-pretender": "^3.1.1",
6261
"ember-cli-shims": "^1.2.0",
6362
"ember-cli-sri": "^2.1.1",
63+
"ember-cli-string-utils": "^1.1.0",
6464
"ember-cli-test-loader": "^2.2.0",
6565
"ember-cli-typescript-blueprints": "^2.0.0-beta.1",
6666
"ember-cli-uglify": "2.1.0",
@@ -84,6 +84,7 @@
8484
"github": "^1.1.1",
8585
"glob": "^7.1.3",
8686
"json-typescript": "^1.1.0",
87+
"lerna": "^3.13.2",
8788
"loader.js": "^4.7.0",
8889
"mocha": "^6.1.2",
8990
"mocha-only-detector": "1.0.0",

packages/-build-infra/.npmignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# compiled output
2+
/dist/
3+
/tmp/
4+
5+
# misc
6+
/.bowerrc
7+
/.editorconfig
8+
/.env*
9+
/.gitignore
10+
/.watchmanconfig
11+
/CONTRIBUTING.md
12+
/testem.js
13+
/tests/
14+
/yarn.lock
15+
.gitkeep
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ignore_dirs": ["tmp", "dist"]
3+
}

packages/-build-infra/LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/-build-infra/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# @ember-data/-build-infra
2+
3+
!! This is an internal package for use by `@ember-data` only. !!
4+
5+
This package provides utilities for configuring addon-build setup
6+
for `@ember-data/` packages. It is directly depended upon by those
7+
packages and should not be installed for use in an app directly.
8+
9+
## License
10+
11+
This project is licensed under the [MIT License](LICENSE.md).

0 commit comments

Comments
 (0)