Skip to content

Commit

Permalink
LookML Dashboard support
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-looker committed Jul 31, 2024
1 parent 616fd71 commit d0e2524
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
npm ci
- name: Lint
run: npm run lint
- name: Install js-yaml (optional dependency)
run: npm install --no-save js-yaml
- name: Run tests
run: npm test
env:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ If your LookML project doesn't have a manifest.lkml file, you may want to consid
- **rule: rule_name** - Recommended. Used to opt-in to built-in rules and to specify custom rules. See [customizing LAMS](https://looker-open-source.github.io/look-at-me-sideways/customizing-lams)
- **rule_exemptions** - Optional. Originally used in 1 & v2 to opt-out of rules globally. A global opt-out can still be useful for opting-out of certain "sub rules" that a rule may return without opting-out of the entire rule. See [customizing LAMS](https://looker-open-source.github.io/look-at-me-sideways/customizing-lams)

### Optional Dependencies

- `js-yaml` is not automatically installed with LAMS, but you may explicitly install it if you want to write custom rules that lint against the contents of a LookML Dashboard, which is a YAML-based file. In this case, also make sure to pass a `source` argument, as the default `source` does not includes `.dashboard.lookml` files.

## About

### Release Notes
Expand Down
51 changes: 51 additions & 0 deletions __tests__/dummy-projects/28-lookml-dashboards/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const lams = require('../../../index.js')
const mocks = require('../../../lib/mocks.js')
const path= require('path')
const options = {
reporting:"no",
cwd:__dirname,
source:"{manifest.lkml,*.model.lkml,*.dashboard.lookml}"
};
require('../../../lib/expect-to-contain-message');
const log = x=>console.log(x)
const testProjectName = __dirname.split(path.sep).slice(-1)[0];

describe('Projects', () => {
describe(testProjectName + " (needs js-yaml optional dependency)", () => {
let {spies, process, console} = mocks()
let messages
beforeAll( async () => {
messages = await lams(options,{process, console})
})
it("should not error out", ()=> {
expect(console.error).not.toHaveBeenCalled()
});
it("it should not contain any unexpected parser (P0) errors", ()=> {
expect({messages}).not.toContainMessage({
rule: "P0",
level: "error"
});
});
it("it should not contain any parser syntax (P1) errors", ()=> {
expect({messages}).not.toContainMessage({
rule: "P1",
level: "error"
});
});

it("it should match DASH_1 (3 match, 0 exempt, 1 error)", ()=> {
expect({messages}).toContainMessage({
rule: "DASH_1",
level: "info",
description: "Rule DASH_1 summary: 3 matches, 0 matches exempt, and 1 errors"
});
});

it("it should error on DASH_1", ()=> {
expect({messages}).toContainMessage({
rule: "DASH_1",
level: "error"
});
});
});
});
8 changes: 8 additions & 0 deletions __tests__/dummy-projects/28-lookml-dashboards/manifest.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#LAMS
#rule: DASH_1 {
# description: "`model` attribute should not be set (allow inheritance based on model inclusion)"
# match: "$.model.*.dashboard.*[0].elements.*"
# expr_rule:
# (=== ::match:model undefined)
# ;;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
- dashboard: user_segments
title: User segments
layout: newspaper
embed_style:
background_color: "#ff4141"
show_title: false
title_color: "#3a4245"
show_filters_bar: true
tile_text_color: "#3a4245"
text_tile_text_color: "#caff37"
elements:
- name: User segments
title: User segments
model: thelook
explore: users
type: looker_pie
fields:
- users.gender
- users.count
filters:
users.state: ''
sorts:
- users.count desc
limit: 500
column_limit: 50
query_timezone: America/Los_Angeles
value_labels: legend
label_type: labPer
stacking: ''
show_value_labels: false
label_density: 25
legend_position: center
x_axis_gridlines: false
y_axis_gridlines: true
show_view_names: true
limit_displayed_rows: false
y_axis_combined: true
show_y_axis_labels: true
show_y_axis_ticks: true
y_axis_tick_density: default
y_axis_tick_density_custom: 5
show_x_axis_label: true
show_x_axis_ticks: true
x_axis_scale: auto
y_axis_scale_mode: linear
ordering: none
show_null_labels: false
show_totals_labels: false
show_silhouette: false
totals_color: "#808080"
series_types: {}
listen:
State: users.state
row: 0
col: 0
width: 12
height: 8
- name: Markdown
type: text
title_text: Markdown
body_text: "Inline-style: \n![alt text](https://wwwstatic-a.lookercdn.com/homepage/new_home/looker.svg)\n\
\nReference-style: \n![alt text][logo]\n\n[logo]: https://wwwstatic-a.lookercdn.com/homepage/new_home/looker.svg"
row: 0
col: 12
width: 12
height: 6
- name: Md
type: text
title_text: Md
body_text: "Inline-style: \n![alt text](https://wwwstatic-a.lookercdn.com/homepage/new_home/looker.svg)\n\
\nReference-style: \n![alt text][logo]\n\n[logo]: https://wwwstatic-a.lookercdn.com/homepage/new_home/looker.svg"
row: 8
col: 0
width: 24
height: 8
filters:
- name: State
title: State
type: field_filter
default_value:
model: thelook
explore: orderss
field: users.state
listens_to_filters: []
allow_multiple_values: true
required: false
- name: City
title: City
type: field_filter
default_value: ''
model: thelook
explore: orders
field: users.city
listens_to_filters:
- State
allow_multiple_values: true
required: false
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: "*.dashboard"
70 changes: 39 additions & 31 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"fromentries": "^1.3.2",
"jsonpath-plus": "^7.2.0",
"liyad": "^0.2.4",
"lookml-parser": "^6.8.2",
"lookml-parser": "^6.9.1",
"minimist": "^1.2.6",
"require-from-string": "^2.0.2"
},
Expand Down

0 comments on commit d0e2524

Please sign in to comment.