-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
224 lines (219 loc) · 7.67 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: 'Looker Janitor: LookML View Cleaner'
description: Tidy up Looker LookML view files by grouping, sorting and warning about inconsistencies.
author: 'Alhan Keser'
inputs:
files:
required: false
type: string
description: 'List of files to clean. If omitted, then any changed view files will be cleaned.'
default: ''
type_order:
required: false
type: string
description: 'Order of field types.'
default: |
filter
parameter
dimension
dimension_group
measure
set
param_order:
required: false
type: string
description: 'Order of field parameters.'
default: |
hidden
type
view_label
group_label
group_item_label
label
description
sql
sql_start
sql_end
filters
value_format_name
value_format
drill_fields
primary_key_first:
required: false
type: boolean
description: 'Should primary key be ordered first.'
default: true
order_types:
required: false
type: boolean
description: 'Should fields be ordered by their type.'
default: true
order_fields:
required: false
type: boolean
description: 'Should fields be ordered.'
default: true
order_field_parameters:
required: false
type: boolean
description: 'Should field parameters be ordered.'
default: true
order_fields_by_label:
required: false
type: boolean
description: 'Should fields be ordered by their labels.'
default: true
localization_file_path:
required: false
type: string
description: 'Localization file path to use for label sorting'
default: 'None'
check_required_params:
required: false
type: boolean
description: 'Should required parameters be checked.'
default: false
required_filter:
required: false
type: string
description: 'List of required filter parameters.'
default: |
type
required_parameter:
required: false
type: string
description: 'List of required parameter parameters.'
default: |
type
required_dimension:
required: false
type: string
description: 'List of required dimension parameters.'
default: |
type
required_dimension_group:
required: false
type: string
description: 'List of required dimension_group parameters.'
default: |
type
required_measure:
required: false
type: string
description: 'List of required measure parameters.'
default: |
type
required_set:
required: false
type: string
description: 'List of required filter parameters.'
default: |
fields
runs:
using: 'composite'
steps:
- name: Checkout Branch
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Configure Git user
run : |
git config user.name github-actions
git config user.email [email protected]
shell: bash
- name: Checkout Looker Janitor
uses: actions/checkout@v2
with:
repository: alhankeser/looker-janitor
path: looker-janitor
ref: v0
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.12
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r looker-janitor/requirements.txt
shell: bash
- name: Get Changed Files
if: ${{ inputs.files == '' }}
id: changed_files
uses: tj-actions/changed-files@v44
with:
files: |
**.view.lkml
**.view.lookml
- name: Get Looker Janitor Arguments
id: janitor_args
run: |
if [ "${{ inputs.files }}" != "" ]; then
files="${{ inputs.files }}"
else
files="${{ steps.changed_files.outputs.all_changed_files }}"
fi
echo "files=${files//$'\n'/ }" >> $GITHUB_OUTPUT
type_order="${{ inputs.type_order }}"
param_order="${{ inputs.param_order }}"
primary_key_first="${{ inputs.primary_key_first }}"
order_types="${{ inputs.order_types }}"
order_fields="${{ inputs.order_fields }}"
order_field_parameters="${{ inputs.order_field_parameters }}"
order_fields_by_label="${{ inputs.order_fields_by_label }}"
localization_file_path="${{ inputs.localization_file_path }}"
check_required_params="${{ inputs.check_required_params }}"
required_filter="${{ inputs.required_filter }}"
required_parameter="${{ inputs.required_parameter }}"
required_dimension="${{ inputs.required_dimension }}"
required_dimension_group="${{ inputs.required_dimension_group }}"
required_measure="${{ inputs.required_measure }}"
required_set="${{ inputs.required_set }}"
echo "type_order=${type_order//$'\n'/ }" >> $GITHUB_OUTPUT
echo "param_order=${param_order//$'\n'/ }" >> $GITHUB_OUTPUT
echo "primary_key_first=${primary_key_first}" >> $GITHUB_OUTPUT
echo "order_types=${order_types}" >> $GITHUB_OUTPUT
echo "order_fields=${order_fields}" >> $GITHUB_OUTPUT
echo "order_field_parameters=${order_field_parameters}" >> $GITHUB_OUTPUT
echo "order_fields_by_label=${order_fields_by_label}" >> $GITHUB_OUTPUT
echo "localization_file_path=${localization_file_path}" >> $GITHUB_OUTPUT
echo "check_required_params=${check_required_params}" >> $GITHUB_OUTPUT
echo "required_filter=${required_filter//$'\n'/ }" >> $GITHUB_OUTPUT
echo "required_parameter=${required_parameter//$'\n'/ }" >> $GITHUB_OUTPUT
echo "required_dimension=${required_dimension//$'\n'/ }" >> $GITHUB_OUTPUT
echo "required_dimension_group=${required_dimension_group//$'\n'/ }" >> $GITHUB_OUTPUT
echo "required_measure=${required_measure//$'\n'/ }" >> $GITHUB_OUTPUT
echo "required_set=${required_set//$'\n'/ }" >> $GITHUB_OUTPUT
shell: bash
- name: Check Files
id: has_files_check
shell: bash
run: |
if [ "${{ steps.janitor_args.outputs.files }}" == "" ]; then
echo "has_files=false" >> $GITHUB_OUTPUT
else
echo "has_files=true" >> $GITHUB_OUTPUT
fi
- name: Run Looker Janitor
id: looker_janitor
if: ${{ steps.has_files_check.outputs.has_files == 'true' }}
run: |
python looker-janitor/main.py \
--files ${{ steps.janitor_args.outputs.files }} \
--type_order ${{ steps.janitor_args.outputs.type_order }} \
--param_order ${{ steps.janitor_args.outputs.param_order }} \
--primary_key_first ${{ steps.janitor_args.outputs.primary_key_first }} \
--order_types ${{ steps.janitor_args.outputs.order_types }} \
--order_fields ${{ steps.janitor_args.outputs.order_fields }} \
--order_field_parameters ${{ steps.janitor_args.outputs.order_field_parameters }} \
--order_fields_by_label ${{ steps.janitor_args.outputs.order_fields_by_label }} \
--localization_file_path ${{ steps.janitor_args.outputs.localization_file_path }} \
--check_required_params ${{ steps.janitor_args.outputs.check_required_params }} \
--required_filter ${{ steps.janitor_args.outputs.required_filter }} \
--required_parameter ${{ steps.janitor_args.outputs.required_parameter }} \
--required_dimension ${{ steps.janitor_args.outputs.required_dimension }} \
--required_dimension_group ${{ steps.janitor_args.outputs.required_dimension_group }} \
--required_measure ${{ steps.janitor_args.outputs.required_measure }} \
--required_set ${{ steps.janitor_args.outputs.required_set }} >> looker-janitor/output.txt
shell: bash
branding:
icon: check-circle
color: purple