Looker Validator Implementation Guide
This guide walks you through setting up the Looker Validator tool for your CI/CD process.
Step 1: Set Up a Dedicated Looker User
First, create a dedicated Looker user and API key with the appropriate permissions:
-
Create a permission set:
- Go to Admin > Roles
- Create a new permission set named "Validator User"
- Include these permissions:
access_datasee_lookml_dashboardssee_lookssee_user_dashboardsdevelopsee_lookmlsee_sql
-
Create a role:
- Go to Admin > Roles
- Create a new role named "Validator User"
- Add the "Validator User" permission set
- Select the model set(s) you want to validate
-
Create the user:
- Go to Admin > Users
- Create a new user (e.g., "validator@yourcompany.com")
- Assign the "Validator User" role
-
Generate API credentials:
- Edit the user
- Go to API3 Keys
- Click "New API Key"
- Save the client ID and client secret
Step 2: Install Looker Validator
You can install the validator in your local environment or in your CI system:
pip install looker-validator
Step 3: Configure the Validator
Create a configuration file looker_validator_config.yaml:
# Looker API credentials
base_url: https://your-looker-instance.cloud.looker.com
client_id: YOUR_CLIENT_ID
client_secret: YOUR_CLIENT_SECRET
project: your_looker_project_name
# Optional global settings
log_dir: logs
# SQL validator settings
concurrency: 10
incremental: true
# Content validator settings
exclude_personal: true
incremental: true
# LookML validator settings
severity: warning
Step 4: Test the Connection
Verify that you can connect to your Looker instance:
looker-validator connect --config-file looker_validator_config.yaml
You should see a success message with your Looker version.
Step 5: Set Up GitHub Action
-
Add secrets to your GitHub repository:
- Go to your repository settings
- Click on Secrets > Actions
- Add the following secrets:
LOOKER_BASE_URL: Your Looker instance URLLOOKER_CLIENT_ID: The API client IDLOOKER_CLIENT_SECRET: The API client secret
-
Create workflow file:
Create a file at
.github/workflows/looker-validation.yml:name: Looker Validation on: pull_request: branches: [ main, master, dev ] paths: - '**.view.lkml' - '**.model.lkml' - '**.explore.lkml' - '**.dashboard.lookml' - '**manifest.lkml' jobs: validate: name: Validate Looker Project runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.9' - name: Install looker-validator run: | python -m pip install --upgrade pip pip install looker-validator - name: Test connection run: | looker-validator connect \ --base-url ${{ secrets.LOOKER_BASE_URL }} \ --client-id ${{ secrets.LOOKER_CLIENT_ID }} \ --client-secret ${{ secrets.LOOKER_CLIENT_SECRET }} \ --project ${{ github.event.repository.name }} - name: Run LookML validation run: | looker-validator lookml \ --base-url ${{ secrets.LOOKER_BASE_URL }} \ --client-id ${{ secrets.LOOKER_CLIENT_ID }} \ --client-secret ${{ secrets.LOOKER_CLIENT_SECRET }} \ --project ${{ github.event.repository.name }} \ --branch ${{ github.head_ref }} - name: Run SQL validation run: | looker-validator sql \ --base-url ${{ secrets.LOOKER_BASE_URL }} \ --client-id ${{ secrets.LOOKER_CLIENT_ID }} \ --client-secret ${{ secrets.LOOKER_CLIENT_SECRET }} \ --project ${{ github.event.repository.name }} \ --branch ${{ github.head_ref }} \ --incremental - name: Run Content validation run: | looker-validator content \ --base-url ${{ secrets.LOOKER_BASE_URL }} \ --client-id ${{ secrets.LOOKER_CLIENT_ID }} \ --client-secret ${{ secrets.LOOKER_CLIENT_SECRET }} \ --project ${{ github.event.repository.name }} \ --branch ${{ github.head_ref }} \ --incremental \ --exclude-personal - name: Run Assert validation run: | looker-validator assert \ --base-url ${{ secrets.LOOKER_BASE_URL }} \ --client-id ${{ secrets.LOOKER_CLIENT_ID }} \ --client-secret ${{ secrets.LOOKER_CLIENT_SECRET }} \ --project ${{ github.event.repository.name }} \ --branch ${{ github.head_ref }} - name: Upload logs if: always() uses: actions/upload-artifact@v3 with: name: validation-logs path: logs/
Step 6: Customize Your Validation Process
Depending on your needs, you may want to customize your validation:
For Large Projects
If you have a large Looker project, consider:
-
Selecting specific models/explores:
looker-validator sql --explores model_a/* model_b/explore_c
-
Increasing concurrency:
looker-validator sql --concurrency 20
-
Running validators in sequence to avoid branch conflicts
For Faster Validations
To speed up validation:
-
Use incremental mode:
looker-validator sql --incremental
-
Use fail-fast for SQL validation:
looker-validator sql --fail-fast
-
Exclude specific explores/folders:
looker-validator content --explores -model_a/explore_b --folders -33
Step 7: Handling Errors
When validation fails, the GitHub Action will fail with a non-zero exit code. The logs will contain detailed information about the failures.
You can view the logs in two ways:
-
GitHub Actions logs: View the output directly in the GitHub Actions interface
-
Downloaded artifacts: Download the logs artifact for detailed error information
Best Practices
-
Ignore dimensions that validly fail:
dimension: complex_calculation { sql: ${TABLE}.value ;; tags: ["spectacles: ignore"] } -
Use incremental validation to only show new errors
-
Run all validators for comprehensive testing
-
Consider test concurrency in CI environments
-
Set up branch protection rules to prevent merging PRs with validation failures
Troubleshooting
Common Issues
-
Authentication Failures:
- Verify API credentials
- Check API user permissions
-
Branch Conflicts:
- Use separate API users for concurrent validations
- Add concurrency limits to your GitHub workflow
-
SQL Errors:
- Check the SQL logs for specific error details
- Ignore dimensions that validly fail
-
Content Errors:
- Use
--exclude-personalto focus on shared content - Check for missing fields referenced by dashboards
- Use
Getting Help
If you encounter issues:
- Run validators with
--verbosefor detailed logs - Check log files in the
logsdirectory - Review the GitHub Action output
Metadata
Release files for looker-validator 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| looker_validator-0.7.0.tar.gz | 65.4 kB | Without provenance | Details for looker_validator-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| looker_validator-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for looker_validator-0.7.0-py3-none-any.whl |
Total release size: 133.3 kB
Release files / looker_validator-0.7.0.tar.gz
| Download URL | looker_validator-0.7.0.tar.gz |
|---|---|
| Size | 65.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc51e4acfce5dae5e2fbb24ab057095043cb50276dbb2cc5cb61890abb24be14
|
|
BLAKE2b-256 checksum How to use checksums |
fd48897f7ab428361b65051848ec43d1e38c57fe5501ca95782e65ae2671724a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|
Release files / looker_validator-0.7.0-py3-none-any.whl
| Download URL | looker_validator-0.7.0-py3-none-any.whl |
|---|---|
| Size | 67.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48df7de84a55ba22b63ff69e66dd96ce12ce79c0db5db590835c4818ce5ba256
|
|
BLAKE2b-256 checksum How to use checksums |
1f1979c1735cb33d5e29a0b3fdcbe07de79147f725a0b9c82cd7f64cf2fee2b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|
Security for looker-validator 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.