Skip to content

Instantly share code, notes, and snippets.

@jkukul
Created November 8, 2022 16:53
Show Gist options
  • Save jkukul/0bc840a891cb3a3a03e4a001ed6167ad to your computer and use it in GitHub Desktop.
Save jkukul/0bc840a891cb3a3a03e4a001ed6167ad to your computer and use it in GitHub Desktop.
Example GitHub Actions workflow to validate Looker's LookML syntax and content
name: Validate Looker's LookML and Content
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
BASE_URL: # Pass your organisation's Looker base URL, e.g. https://yourorg.cloud.looker.com
LOOKER_CLIENT_ID: # Pass the API client id of a Looker user
# Password should be stored in GitHub's repository secret under the LOOKER_CLIENT_SECRET key
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install Spectacles
run: pip install spectacles
- name: Create Spectacles Config File
run: |
echo "base_url: ${BASE_URL}" > .spectacles-config.yaml
echo "client_id: ${LOOKER_CLIENT_ID}" >> .spectacles-config.yaml
echo "client_secret: ${{ secrets.LOOKER_CLIENT_SECRET }}" >> .spectacles-config.yaml
- name: Check LookML syntax using spectacles library
run: |
spectacles lookml \
--config-file .spectacles-config.yaml \
--project curbfood \
--remote-reset \
${GITHUB_HEAD_REF:+ --branch ${GITHUB_HEAD_REF}} # Only pass --branch argument if on non-main branch (only for PRs)
- name: Run content validation using spectacles library
run: |
spectacles content \
--config-file .spectacles-config.yaml \
--project curbfood \
--remote-reset \
${GITHUB_HEAD_REF:+ --branch ${GITHUB_HEAD_REF}} # Only pass --branch argument if on non-main branch (only for PRs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment