Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Add nitpicking CI integration #10937

Merged
merged 6 commits into from
Jan 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ xcuserdata
test/fixtures/api/assets.zip
test/fixtures/storage/assets.zip
/.circle-week

# Generated list files from code generation
/scripts/generate-cmake-files.list
/scripts/generate-shaders.list
/scripts/generate-style-code.list
48 changes: 48 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ workflows:
version: 2
default:
jobs:
- nitpick
- clang-tidy:
filters:
branches:
Expand Down Expand Up @@ -217,6 +218,47 @@ step-library:
destination: render-tests

jobs:
nitpick:
docker:
- image: mbgl/7d2403f42e:base
working_directory: /src
environment:
LIBSYSCONFCPUS: 4
JOBS: 4
BUILDTYPE: Debug
steps:
- checkout
- *generate-cache-key
- *restore-cache
- run:
name: Initialize submodule
command: git submodule update --init mapbox-gl-js
- run:
name: npm install
command: npm install --ignore-scripts
- *save-cache
- run:
name: Verify submodule pin
command: scripts/nitpick/submodule-pin.js
when: always
- run:
name: CMake file list generation
command: scripts/nitpick/generated-code.js cmake
when: always
- run:
name: Shader code generation
command: scripts/nitpick/generated-code.js shader
when: always
- run:
name: Style code generation
command: scripts/nitpick/generated-code.js style
when: always
- run:
name: Android code generation
command: scripts/nitpick/generated-code.js android
when: always


# ------------------------------------------------------------------------------
clang-tidy:
docker:
Expand Down Expand Up @@ -685,6 +727,9 @@ jobs:
- run:
name: Lint plist files
command: make ios-lint
- run:
name: Nitpick Darwin code generation
command: scripts/nitpick/generated-code.js darwin
- *show-ccache-stats
- *save-cache

Expand Down Expand Up @@ -744,6 +789,9 @@ jobs:
- run:
name: Lint plist files
command: make macos-lint
- run:
name: Nitpick Darwin code generation
command: scripts/nitpick/generated-code.js darwin
- *show-ccache-stats
- *save-cache
- store_artifacts:
Expand Down
19 changes: 8 additions & 11 deletions cmake/benchmark-files.cmake
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
# Do not edit. Regenerate this with ./scripts/generate-benchmark-files.sh
# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js

set(MBGL_BENCHMARK_FILES
# api
benchmark/api/query.benchmark.cpp
benchmark/api/render.benchmark.cpp

# benchmark
benchmark/include/mbgl/benchmark.hpp
benchmark/src/main.cpp
benchmark/src/mbgl/benchmark/benchmark.cpp
benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp

# function
benchmark/function/camera_function.benchmark.cpp
benchmark/function/composite_function.benchmark.cpp
benchmark/function/source_function.benchmark.cpp

# include/mbgl
benchmark/include/mbgl/benchmark.hpp

# parse
benchmark/parse/filter.benchmark.cpp
benchmark/parse/tile_mask.benchmark.cpp
benchmark/parse/vector_tile.benchmark.cpp

# src
benchmark/src/main.cpp

# src/mbgl/benchmark
benchmark/src/mbgl/benchmark/benchmark.cpp
benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp

# util
benchmark/util/dtoa.benchmark.cpp

)
3 changes: 2 additions & 1 deletion cmake/core-files.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Do not edit. Regenerate this with ./scripts/generate-core-files.sh
# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js

set(MBGL_CORE_FILES
# actor
Expand Down Expand Up @@ -740,4 +740,5 @@ set(MBGL_CORE_FILES
src/mbgl/util/version.cpp
src/mbgl/util/version.hpp
src/mbgl/util/work_request.cpp

)
13 changes: 13 additions & 0 deletions cmake/files.cmake.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%
const name = locals.name;
const groups = locals.groups;
-%>
# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js

set(MBGL_<%- snakeCaseUpper(name) %>_FILES
<% for (const key of Object.keys(groups).sort()) { -%>
# <%- key %>
<%- groups[key].sort().join('\n ') %>

<% } -%>
)
59 changes: 28 additions & 31 deletions cmake/test-files.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Do not edit. Regenerate this with ./scripts/generate-test-files.sh
# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js

set(MBGL_TEST_FILES
# actor
Expand Down Expand Up @@ -29,9 +29,6 @@ set(MBGL_TEST_FILES
test/gl/context.test.cpp
test/gl/object.test.cpp

# include/mbgl
test/include/mbgl/test.hpp

# map
test/map/map.test.cpp
test/map/prefetch.test.cpp
Expand All @@ -55,23 +52,6 @@ set(MBGL_TEST_FILES
test/sprite/sprite_loader.test.cpp
test/sprite/sprite_parser.test.cpp

# src/mbgl/test
test/src/mbgl/test/fake_file_source.hpp
test/src/mbgl/test/fixture_log_observer.cpp
test/src/mbgl/test/fixture_log_observer.hpp
test/src/mbgl/test/getrss.cpp
test/src/mbgl/test/getrss.hpp
test/src/mbgl/test/stub_file_source.cpp
test/src/mbgl/test/stub_file_source.hpp
test/src/mbgl/test/stub_geometry_tile_feature.hpp
test/src/mbgl/test/stub_layer_observer.hpp
test/src/mbgl/test/stub_render_source_observer.hpp
test/src/mbgl/test/stub_style_observer.hpp
test/src/mbgl/test/stub_tile_observer.hpp
test/src/mbgl/test/test.cpp
test/src/mbgl/test/util.cpp
test/src/mbgl/test/util.hpp

# storage
test/storage/asset_file_source.test.cpp
test/storage/default_file_source.test.cpp
Expand All @@ -85,6 +65,15 @@ set(MBGL_TEST_FILES
test/storage/resource.test.cpp
test/storage/sqlite.test.cpp

# style
test/style/filter.test.cpp
test/style/properties.test.cpp
test/style/source.test.cpp
test/style/style.test.cpp
test/style/style_image.test.cpp
test/style/style_layer.test.cpp
test/style/style_parser.test.cpp

# style/conversion
test/style/conversion/function.test.cpp
test/style/conversion/geojson_options.test.cpp
Expand All @@ -97,23 +86,30 @@ set(MBGL_TEST_FILES
test/style/expression/expression.test.cpp
test/style/expression/util.test.cpp

# style
test/style/filter.test.cpp

# style/function
test/style/function/camera_function.test.cpp
test/style/function/composite_function.test.cpp
test/style/function/exponential_stops.test.cpp
test/style/function/interval_stops.test.cpp
test/style/function/source_function.test.cpp

# style
test/style/properties.test.cpp
test/style/source.test.cpp
test/style/style.test.cpp
test/style/style_image.test.cpp
test/style/style_layer.test.cpp
test/style/style_parser.test.cpp
# test
test/include/mbgl/test.hpp
test/src/mbgl/test/fake_file_source.hpp
test/src/mbgl/test/fixture_log_observer.cpp
test/src/mbgl/test/fixture_log_observer.hpp
test/src/mbgl/test/getrss.cpp
test/src/mbgl/test/getrss.hpp
test/src/mbgl/test/stub_file_source.cpp
test/src/mbgl/test/stub_file_source.hpp
test/src/mbgl/test/stub_geometry_tile_feature.hpp
test/src/mbgl/test/stub_layer_observer.hpp
test/src/mbgl/test/stub_render_source_observer.hpp
test/src/mbgl/test/stub_style_observer.hpp
test/src/mbgl/test/stub_tile_observer.hpp
test/src/mbgl/test/test.cpp
test/src/mbgl/test/util.cpp
test/src/mbgl/test/util.hpp

# text
test/text/cross_tile_symbol_index.test.cpp
Expand Down Expand Up @@ -156,4 +152,5 @@ set(MBGL_TEST_FILES
test/util/token.test.cpp
test/util/unique_any.test.cpp
test/util/url.test.cpp

)
2 changes: 2 additions & 0 deletions platform/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ captures/
# Generated test cases
MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen/

# Generated list files from code generation
/scripts/generate-style-code.list
Original file line number Diff line number Diff line change
Expand Up @@ -3592,6 +3592,7 @@ public static PropertyValue<Expression> textOptional(Expression value) {
return new LayoutPropertyValue<>("text-optional", value);
}


Copy link
Contributor

Choose a reason for hiding this comment

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

What introduced this extra newline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unsure, but that's what the code generator produces. Might be some change in the template, or someone forgot to commit this newline from the generator, e.g. in 757cc0f

/**
* If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.
*
Expand Down
3 changes: 2 additions & 1 deletion platform/android/scripts/generate-style-code.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env node
'use strict';

const fs = require('fs');
const ejs = require('ejs');
const spec = require('../../../mapbox-gl-js/src/style-spec/reference/v8');
const spec = require('../../../scripts/style-spec');
const _ = require('lodash');

require('../../../scripts/style-code');
Expand Down
3 changes: 3 additions & 0 deletions platform/darwin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Generated list files from code generation
/scripts/generate-style-code.list
/scripts/update-examples.list
27 changes: 14 additions & 13 deletions platform/darwin/scripts/generate-style-code.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
'use strict';

const fs = require('fs');
Expand All @@ -11,7 +12,7 @@ const cocoaConventions = require('./style-spec-cocoa-conventions-v8.json');
const prefix = 'MGL';
const suffix = 'StyleLayer';

let spec = _.merge(require('../../../mapbox-gl-js/src/style-spec/reference/v8'), require('./style-spec-overrides-v8.json'));
let spec = _.merge(require('../../../scripts/style-spec'), require('./style-spec-overrides-v8.json'));

// Rename properties and keep `original` for use with setters and getters
_.forOwn(cocoaConventions, function (properties, kind) {
Expand Down Expand Up @@ -577,9 +578,9 @@ const templatesMD = ejs.compile(fs.readFileSync('platform/darwin/docs/guides/Til
const lightH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLLight.h.ejs', 'utf8'), {strict: true});
const lightM = ejs.compile(fs.readFileSync('platform/darwin/src/MGLLight.mm.ejs', 'utf8'), {strict: true});
const testLight = ejs.compile(fs.readFileSync('platform/darwin/test/MGLLightTest.mm.ejs', 'utf8'), { strict: true});
fs.writeFileSync(`platform/darwin/src/MGLLight.h`, duplicatePlatformDecls(lightH({ properties: lightProperties, doc: lightDoc, type: lightType })));
fs.writeFileSync(`platform/darwin/src/MGLLight.mm`, lightM({ properties: lightProperties, doc: lightDoc, type: lightType }));
fs.writeFileSync(`platform/darwin/test/MGLLightTest.mm`, testLight({ properties: lightProperties, doc: lightDoc, type: lightType }));
writeIfModified(`platform/darwin/src/MGLLight.h`, duplicatePlatformDecls(lightH({ properties: lightProperties, doc: lightDoc, type: lightType })));
writeIfModified(`platform/darwin/src/MGLLight.mm`, lightM({ properties: lightProperties, doc: lightDoc, type: lightType }));
writeIfModified(`platform/darwin/test/MGLLightTest.mm`, testLight({ properties: lightProperties, doc: lightDoc, type: lightType }));


const layers = _(spec.layer.type.values).map((value, layerType) => {
Expand Down Expand Up @@ -652,9 +653,9 @@ for (var layer of layers) {
renamedPropertiesByLayerType[layer.type] = renamedProperties;
}

fs.writeFileSync(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.h`, duplicatePlatformDecls(layerH(layer)));
fs.writeFileSync(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.mm`, layerM(layer));
fs.writeFileSync(`platform/darwin/test/${prefix}${camelize(layer.type)}${suffix}Tests.mm`, testLayers(layer));
writeIfModified(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.h`, duplicatePlatformDecls(layerH(layer)));
writeIfModified(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.mm`, layerM(layer));
writeIfModified(`platform/darwin/test/${prefix}${camelize(layer.type)}${suffix}Tests.mm`, testLayers(layer));
}

// Extract examples for guides from unit tests.
Expand Down Expand Up @@ -692,25 +693,25 @@ global.guideExample = function (guide, exampleId, os) {
return '```swift\n' + example + '\n```';
};

fs.writeFileSync(`platform/ios/docs/guides/For Style Authors.md`, forStyleAuthorsMD({
writeIfModified(`platform/ios/docs/guides/For Style Authors.md`, forStyleAuthorsMD({
os: 'iOS',
renamedProperties: renamedPropertiesByLayerType,
layers: layers,
}));
fs.writeFileSync(`platform/macos/docs/guides/For Style Authors.md`, forStyleAuthorsMD({
writeIfModified(`platform/macos/docs/guides/For Style Authors.md`, forStyleAuthorsMD({
os: 'macOS',
renamedProperties: renamedPropertiesByLayerType,
layers: layers,
}));
fs.writeFileSync(`platform/ios/docs/guides/Using Style Functions at Runtime.md`, ddsGuideMD({
writeIfModified(`platform/ios/docs/guides/Using Style Functions at Runtime.md`, ddsGuideMD({
os: 'iOS',
}));
fs.writeFileSync(`platform/macos/docs/guides/Using Style Functions at Runtime.md`, ddsGuideMD({
writeIfModified(`platform/macos/docs/guides/Using Style Functions at Runtime.md`, ddsGuideMD({
os: 'macOS',
}));
fs.writeFileSync(`platform/ios/docs/guides/Tile URL Templates.md`, templatesMD({
writeIfModified(`platform/ios/docs/guides/Tile URL Templates.md`, templatesMD({
os: 'iOS',
}));
fs.writeFileSync(`platform/macos/docs/guides/Tile URL Templates.md`, templatesMD({
writeIfModified(`platform/macos/docs/guides/Tile URL Templates.md`, templatesMD({
os: 'macOS',
}));
12 changes: 4 additions & 8 deletions platform/darwin/scripts/update-examples.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/usr/bin/env node
'use strict';

const fs = require('fs');
const execFileSync = require('child_process').execFileSync;
const _ = require('lodash');

require('../../../scripts/style-code');

const examplesSrc = fs.readFileSync('platform/darwin/test/MGLDocumentationExampleTests.swift', 'utf8');

// Regex extracts the following block
Expand Down Expand Up @@ -124,14 +127,7 @@ function completeExamples(os) {
}

// Write out the modified file contents.
if (src === newSrc) {
console.log('Skipping', path);
} else {
console.log('Updating', path);
if (['0', 'false'].indexOf(process.env.DRY_RUN || '0') !== -1) {
fs.writeFileSync(path, newSrc);
}
}
writeIfModified(path, newSrc)
});
});
}
Expand Down
Loading