-
Notifications
You must be signed in to change notification settings - Fork 105
125 lines (107 loc) · 4.46 KB
/
Copy pathpush.yml
File metadata and controls
125 lines (107 loc) · 4.46 KB
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
name: build
on:
pull_request:
types: [opened, synchronize]
merge_group:
types: [checks_requested]
push:
# Always run on push to main. The build cache can only be reused
# if it was saved by a run from the repository's default branch.
# The run result will be identical to that from the merge queue
# because the commit is identical, yet we need to perform it to
# seed the build cache.
branches:
- main
permissions:
contents: read
jobs:
ci:
runs-on:
group: databrickslabs-protected-runner-group
labels: linux-ubuntu-latest
permissions:
# Authenticate with JFrog for package resolution.
id-token: write
strategy:
fail-fast: false
matrix:
pyVersion: [ '3.10', '3.11', '3.12', '3.13' ]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup uv
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
with:
version: "0.11.2"
checksum: "7ac2ca0449c8d68dae9b99e635cd3bc9b22a4cb1de64b7c43716398447d42981"
- name: Setup for JFrog
uses: ./.github/actions/jfrog-auth
- name: Run unit tests
run: make test
env:
UV_PYTHON: ${{ matrix.pyVersion }}
- name: Publish test coverage
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
fmt:
runs-on:
group: databrickslabs-protected-runner-group
labels: linux-ubuntu-latest
permissions:
# Authenticate with JFrog for package resolution.
id-token: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup uv
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
with:
version: "0.11.2"
checksum: "7ac2ca0449c8d68dae9b99e635cd3bc9b22a4cb1de64b7c43716398447d42981"
- name: Setup for JFrog
uses: ./.github/actions/jfrog-auth
- name: Reformat code
run: make fmt
- name: Install Databricks CLI
uses: databricks/setup-cli@8db12393ac48926ab0074f3928f36c7abc441f90 # v0.292.0
# `databricks labs install lsql` fetches the release list and source zipball from
# api.github.com *anonymously* (the CLI never reads GITHUB_TOKEN), so it routinely
# hits GitHub's 60 req/hr unauthenticated rate limit on shared runner IPs and fails
# with "403 Forbidden". To avoid that, pre-fetch everything with authenticated `gh`
# (5000 req/hr), seed the CLI's local cache + lib dir, then install with --offline so
# the CLI makes no GitHub API calls at all.
- name: Install LSQL
env:
DATABRICKS_HOST: any
DATABRICKS_TOKEN: any
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
labs_dir="$HOME/.databricks/labs/lsql"
mkdir -p "$labs_dir/cache" "$labs_dir/lib"
# Seed the version cache the CLI reads, so `install --offline` resolves "latest"
# without calling api.github.com. The cache format is {refreshed_at, data:[releases]}.
releases="$(gh api repos/databrickslabs/lsql/releases)"
latest_tag="$(printf '%s' "$releases" | jq -r '.[0].tag_name')"
printf '%s' "$releases" \
| jq '{refreshed_at: (now | todate), data: .}' \
> "$labs_dir/cache/databrickslabs-lsql-releases.json"
# Download and unpack the release source into the lib dir (what the CLI would
# otherwise pull from the GitHub zipball endpoint). Strip the single top-level dir.
tmp="$(mktemp -d)"
gh release download "$latest_tag" --repo databrickslabs/lsql --archive=zip --output "$tmp/lsql.zip"
unzip -q "$tmp/lsql.zip" -d "$tmp/unpacked"
cp -R "$(find "$tmp/unpacked" -mindepth 1 -maxdepth 1 -type d)"/. "$labs_dir/lib/"
databricks labs install lsql --offline --log-level=trace
databricks labs installed
- name: Reformat SQL queries
run: databricks labs lsql fmt --normalize-case false --exclude tests/unit/source_code/samples/
- name: Fail on differences
run: |
# Exit with status code 1 if there are differences (i.e. unformatted files)
git diff --exit-code