Skip to content

Commit cc01fab

Browse files
committed
feat: generate pixi.toml in workflow generator
Closes #32.
1 parent aa41c0f commit cc01fab

File tree

8 files changed

+145
-39
lines changed

8 files changed

+145
-39
lines changed

.rat-apache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# limitations under the License.
1414

1515
.github/workflows/dev_issues.yaml
16+
adbc_drivers_dev/templates/dev_issues.yaml
1617
adbc_drivers_dev/title_check.py

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
include adbc_drivers_dev/.env
1616
include adbc_drivers_dev/compose.yaml
1717
recursive-include adbc_drivers_dev/compose/ Dockerfile *.ld *.sh
18-
recursive-include adbc_drivers_dev/templates/ *.yaml
18+
recursive-include adbc_drivers_dev/templates/ *.toml *.yaml

adbc_drivers_dev/make.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def to_bool(value: str | bool) -> bool:
5959

6060

6161
def is_verbose() -> bool:
62-
return to_bool(doit.get_var("VERBOSE", False))
62+
return to_bool(get_var("VERBOSE", "False"))
6363

6464

6565
def append_flags(env: dict[str, str], var: str, flags: str) -> None:
@@ -198,6 +198,14 @@ def detect_version(
198198
return version
199199

200200

201+
def get_var(name: str, default: str) -> str:
202+
value = os.environ.get(name)
203+
if value is not None:
204+
return value
205+
value = doit.get_var(name, default)
206+
return value
207+
208+
201209
def build(
202210
repo_root: Path,
203211
driver_root: Path,
@@ -220,10 +228,10 @@ def build(
220228
)
221229

222230
tags = ["driverlib"]
223-
if to_bool(doit.get_var("DEBUG", False)):
231+
if to_bool(get_var("DEBUG", "False")):
224232
tags.append("assert")
225233

226-
extra_tags = doit.get_var("BUILD_TAGS", "")
234+
extra_tags = get_var("BUILD_TAGS", "")
227235
if extra_tags:
228236
extra_tags = extra_tags.split(",")
229237
extra_tags = [tag.strip() for tag in extra_tags]
@@ -370,11 +378,11 @@ def check(binary: Path) -> None:
370378

371379

372380
def task_build():
373-
driver = doit.get_var("DRIVER", "")
381+
driver = get_var("DRIVER", "")
374382
if not driver:
375383
raise ValueError("Must specify DRIVER=driver")
376384

377-
ci = doit.get_var("CI", False)
385+
ci = get_var("CI", False)
378386

379387
repo_root = Path(".").resolve()
380388
driver_root = Path(driver)
@@ -407,7 +415,7 @@ def task_build():
407415

408416

409417
def task_check():
410-
driver = doit.get_var("DRIVER", "")
418+
driver = get_var("DRIVER", "")
411419
if not driver:
412420
raise ValueError("Must specify DRIVER=driver")
413421

adbc_drivers_dev/templates/dev_issues.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@
77
# This file has been modified from its original version, which is
88
# under the Apache License:
99
#
10-
# Licensed under the Apache License, Version 2.0 (the "License");
11-
# you may not use this file except in compliance with the License.
12-
# You may obtain a copy of the License at
10+
# Licensed to the Apache Software Foundation (ASF) under one
11+
# or more contributor license agreements. See the NOTICE file
12+
# distributed with this work for additional information
13+
# regarding copyright ownership. The ASF licenses this file
14+
# to you under the Apache License, Version 2.0 (the
15+
# "License"); you may not use this file except in compliance
16+
# with the License. You may obtain a copy of the License at
1317
#
14-
# http://www.apache.org/licenses/LICENSE-2.0
18+
# http://www.apache.org/licenses/LICENSE-2.0
1519
#
16-
# Unless required by applicable law or agreed to in writing, software
17-
# distributed under the License is distributed on an "AS IS" BASIS,
18-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19-
# See the License for the specific language governing permissions and
20-
# limitations under the License.
20+
# Unless required by applicable law or agreed to in writing,
21+
# software distributed under the License is distributed on an
22+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23+
# KIND, either express or implied. See the License for the
24+
# specific language governing permissions and limitations
25+
# under the License.
2126

2227
name: Issues Bot
2328

adbc_drivers_dev/templates/dev_pr.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
pr_standard:
4646
name: "Check PR"
4747
runs-on: ubuntu-latest
48-
if: github.event_name == 'pull_request'
4948

5049
steps:
5150
<% if driver == "dev" %>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<% if private %>
2+
# Copyright (c) 2025 Columnar Technologies Inc. All rights reserved.
3+
<% else %>
4+
# Copyright (c) 2025 ADBC Drivers Contributors
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
<% endif %>
18+
19+
# !!!! AUTO-GENERATED FILE. DO NOT EDIT. !!!!
20+
# USE adbc-gen-workflow (see adbc-drivers/dev) TO UPDATE THIS FILE.
21+
22+
[workspace]
23+
<% if private %>
24+
authors = ["Columnar Technologies"]
25+
<% else %>
26+
authors = ["ADBC Drivers Contributors"]
27+
<% endif %>
28+
channels = ["conda-forge"]
29+
name = "build"
30+
platforms = ["linux-64", "osx-arm64", "win-64", "linux-aarch64"]
31+
version = "0.1.0"
32+
33+
[tasks]
34+
make = "adbc-make run build DRIVER=<{driver}> VERBOSE=true"
35+
test = "go test -tags assert -v ./..."
36+
release = "adbc-release"
37+
validate = "pytest -vvs --junit-xml=validation-report.xml -rfEsxX validation/tests/"
38+
gendocs = "python -m validation.tests.generate_documentation"
39+
40+
[dependencies]
41+
python = ">=3.13.5,<3.14"
42+
43+
[pypi-dependencies]
44+
adbc-drivers-dev = { git = "https://github.com/adbc-drivers/dev" }
45+
adbc-drivers-validation = { git = "https://github.com/adbc-drivers/validation" }

adbc_drivers_dev/templates/test.yaml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ defaults:
6868

6969
jobs:
7070
test:
71-
name: "Test/${{ matrix.os }} ${{ matrix.arch }}"
71+
name: "Test/${{ matrix.platform }}_${{ matrix.arch }}"
7272
runs-on: ${{ matrix.runner }}
7373
strategy:
7474
fail-fast: true
7575
matrix:
7676
include:
77-
- { os: Linux, platform: linux, arch: amd64, runner: ubuntu-latest }
78-
- { os: macOS, platform: macos, arch: arm64, runner: macos-latest }
79-
- { os: Windows, platform: win, arch: amd64, runner: windows-latest }
77+
- { platform: linux, arch: amd64, runner: ubuntu-latest }
78+
- { platform: macos, arch: arm64, runner: macos-latest }
79+
- { platform: win, arch: amd64, runner: windows-latest }
8080
<% if environment %>
8181
environment: <{environment}>
8282
<% endif %>
@@ -89,7 +89,7 @@ jobs:
8989
- name: free up disk space
9090
if: runner.os != 'Windows'
9191
run: |
92-
# Rust uses a lot of disk space, free up some space
92+
# Preinstalled tools use a lot of disk space, free up some space
9393
# https://github.com/actions/runner-images/issues/2840
9494
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
9595
@@ -187,14 +187,14 @@ jobs:
187187
go test -tags assert -v ./...
188188
189189
validate:
190-
name: "Validate/${{ matrix.os }} ${{ matrix.arch }}"
190+
name: "Validate/${{ matrix.platform }}_${{ matrix.arch }}"
191191
runs-on: ${{ matrix.runner }}
192192
strategy:
193193
fail-fast: true
194194
matrix:
195195
include:
196196
# I think we only need to test one platform, but we can change that later
197-
- { os: Linux, platform: linux, arch: amd64, runner: ubuntu-latest }
197+
- { platform: linux, arch: amd64, runner: ubuntu-latest }
198198
<% if environment %>
199199
environment: <{environment}>
200200
<% endif %>
@@ -207,7 +207,7 @@ jobs:
207207
- name: free up disk space
208208
if: runner.os != 'Windows'
209209
run: |
210-
# Rust uses a lot of disk space, free up some space
210+
# Preinstalled tools use a lot of disk space, free up some space
211211
# https://github.com/actions/runner-images/issues/2840
212212
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
213213
@@ -246,6 +246,14 @@ jobs:
246246
- name: Build Library
247247
working-directory: go
248248
run: |
249+
if [[ -f ci/scripts/pre-build.sh ]]; then
250+
./ci/scripts/pre-build.sh test ${{ matrix.platform }} ${{ matrix.arch }}
251+
fi
252+
set -a
253+
if [[ -f .env.release ]]; then
254+
source .env.test
255+
fi
256+
set +a
249257
pixi run adbc-make build DEBUG=true VERBOSE=true DRIVER=<{driver}>
250258
251259
- name: Start Test Dependencies
@@ -305,21 +313,21 @@ jobs:
305313
retention-days: 2
306314

307315
build:
308-
name: "Build <{driver}>/${{ matrix.os }} ${{ matrix.arch }}"
316+
name: "Build <{driver}>/${{ matrix.platform }}_${{ matrix.arch }}"
309317
needs: test
310318
runs-on: ${{ matrix.runner }}
311319
strategy:
312320
fail-fast: true
313321
matrix:
314322
include:
315-
- { os: Linux, platform: linux, arch: amd64, runner: ubuntu-latest }
323+
- { platform: linux, arch: amd64, runner: ubuntu-latest }
316324
<% if private %>
317-
- { os: Linux, platform: linux, arch: arm64, runner: private-ubuntu-24.04-arm }
325+
- { platform: linux, arch: arm64, runner: private-ubuntu-24.04-arm }
318326
<% else %>
319-
- { os: Linux, platform: linux, arch: arm64, runner: ubuntu-24.04-arm }
327+
- { platform: linux, arch: arm64, runner: ubuntu-24.04-arm }
320328
<% endif %>
321-
- { os: macOS, platform: macos, arch: arm64, runner: macos-latest }
322-
- { os: Windows, platform: windows, arch: amd64, runner: windows-latest }
329+
- { platform: macos, arch: arm64, runner: macos-latest }
330+
- { platform: windows, arch: amd64, runner: windows-latest }
323331
permissions:
324332
contents: read
325333
packages: read
@@ -353,7 +361,21 @@ jobs:
353361
354362
- name: Build Library
355363
working-directory: go
364+
<% if secrets and "build" in secrets %>
365+
env:
366+
<% for name, val in secrets["build"].items() %>
367+
<{name}>: ${{ secrets.<{val}> }}
368+
<% endfor %>
369+
<% endif %>
356370
run: |
371+
if [[ -f ci/scripts/pre-build.sh ]]; then
372+
./ci/scripts/pre-build.sh release ${{ matrix.platform }} ${{ matrix.arch }}
373+
fi
374+
set -a
375+
if [[ -f .env.release ]]; then
376+
source .env.release
377+
fi
378+
set +a
357379
pixi run adbc-make check CI=true VERBOSE=true DRIVER=<{driver}>
358380
359381
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0

adbc_drivers_dev/workflow.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@
4040
# TOML does not support nulls
4141
MORE_DEFAULTS = {
4242
"environment": None,
43+
"secrets": {},
4344
}
4445

4546

4647
def write_workflow(
4748
root: Path, template, filename: str, params: dict[str, typing.Any]
4849
) -> None:
4950
rendered = template.render(**params)
50-
sink = root / ".github/workflows" / filename
51+
sink = root / filename
5152
with sink.open("w") as f:
5253
f.write(rendered)
5354
if not rendered.endswith("\n"):
@@ -88,9 +89,11 @@ def generate_workflows(args) -> int:
8889
if params["aws"] or params["gcloud"]:
8990
params["permissions"]["id_token"] = True
9091

92+
workflows = args.repository / ".github/workflows"
93+
9194
template = env.get_template("test.yaml")
9295
write_workflow(
93-
args.repository,
96+
workflows,
9497
template,
9598
"go_test.yaml",
9699
{
@@ -101,7 +104,7 @@ def generate_workflows(args) -> int:
101104
},
102105
)
103106
write_workflow(
104-
args.repository,
107+
workflows,
105108
template,
106109
"go_release.yaml",
107110
{
@@ -115,15 +118,35 @@ def generate_workflows(args) -> int:
115118
for dev in ["dev.yaml", "dev_issues.yaml", "dev_pr.yaml"]:
116119
template = env.get_template(dev)
117120
write_workflow(
118-
args.repository,
121+
workflows,
119122
template,
120123
dev,
121124
{
122125
**params,
123126
},
124127
)
125128

126-
return 0
129+
template = env.get_template("pixi.toml")
130+
131+
retcode = 0
132+
for lang, enabled in params["lang"].items():
133+
if not enabled:
134+
continue
135+
write_workflow(
136+
args.repository / lang,
137+
template,
138+
"pixi.toml",
139+
{
140+
**params,
141+
},
142+
)
143+
144+
license_template = args.repository / lang / "license.tpl"
145+
if not license_template.is_file():
146+
print(f"Missing {license_template}", file=sys.stderr)
147+
retcode = 1
148+
149+
return retcode
127150

128151

129152
@functools.cache
@@ -173,9 +196,12 @@ def update_actions() -> None:
173196
def replace_action(match: re.Match[str]) -> str:
174197
latest = latest_action_version(match.group(1))
175198

176-
print(
177-
f" Updating {match.group(1)} from {match.group(2)} to {latest[2]} ({latest[1]})"
178-
)
199+
if match.group(2) == latest[2]:
200+
print(f" {match.group(1)} already at {latest[2]} ({latest[1]})")
201+
else:
202+
print(
203+
f" {match.group(1)} updated from {match.group(2)} to {latest[2]} ({latest[1]})"
204+
)
179205
return f"uses: {match.group(1)}@{latest[2]} # {latest[1]}"
180206

181207
new_content = action_re.sub(replace_action, content)

0 commit comments

Comments
 (0)