test #7 #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Diff-quality | |
on: | |
push: | |
branches: | |
- diff-quality | |
env: | |
DBT_DEFAULT_PROFILE_TARGET: stellar_dbt_public | |
DBT_PROFILES_DIR: ${{ github.workspace }} | |
DBT_MAX_BYTES_BILLED: 1000000000000 | |
DBT_JOB_TIMEOUT: 300 | |
DBT_THREADS: 1 | |
DBT_JOB_RETRIES: 1 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetch all history | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
dbt deps | |
- name: Authenticate to GCP | |
uses: 'google-github-actions/auth@v2' | |
with: | |
project_id: crypto-stellar | |
credentials_json: "${{ secrets.CREDS_PROD_HUBBLE }}" | |
- name: Get changed files | |
id: get_file_changes | |
uses: trilom/[email protected] | |
with: | |
output: " " | |
- name: Get new and changed .sql files in /models to lint | |
id: get_files_to_lint | |
shell: bash -l {0} | |
run: | | |
# Set the command in the $() brackets as an output to use in later steps | |
echo "::set-output name=lintees::$( | |
# Issue where grep regular expressions don't work as expected on the | |
# Github Actions shell, check dbt/models/ folder | |
echo \ | |
$(echo ${{ steps.get_file_changes.outputs.files_modified }} | | |
tr -s ' ' '\n' | | |
grep -E '^models.*[.]sql$' | | |
tr -s '\n' ' ') \ | |
$(echo ${{ steps.get_file_changes.outputs.files_added }} | | |
tr -s ' ' '\n' | | |
grep -E '^models.*[.]sql$' | | |
tr -s '\n' ' ') | |
)" | |
- name: Lint dbt models | |
id: sqlfluff_json | |
if: steps.get_files_to_lint.outputs.lintees != '' | |
shell: bash -l {0} | |
run: | | |
python -m pip install --upgrade pip | |
dbt deps | |
sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json | |
sed -i '/^\[/!d' annotations.json # see https://github.com/sqlfluff/sqlfluff/issues/2244 | |
- name: Checkout source branch and diff quality | |
run: | | |
git checkout ${{ github.ref_name }} | |
diff-quality --violations=sqlfluff --compare-branch=origin/master |