Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: INFENG-885: add lock-api-state.sh pre-commit check #10030

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
92a6fad
* Add pre-commit step to replace lock-api-state.sh, which ensures that
davidfluck-hpe Oct 8, 2024
6162a90
* Add files key for lock-api-state pre-commit entry.
davidfluck-hpe Oct 8, 2024
4a0066b
* Tweak files key for lock-api-state pre-commit hook.
davidfluck-hpe Oct 8, 2024
a50e7e9
* Set pass_filenames: false on lock-api-state pre-commit hook, because
davidfluck-hpe Oct 8, 2024
1fbfbc4
* Add commit stage specifier to lock-api-state pre-commit hook.
davidfluck-hpe Oct 8, 2024
ffa433c
Test change
davidfluck-hpe Oct 8, 2024
fba7db9
Remove commit stage from lock-api-state hook.
davidfluck-hpe Oct 8, 2024
45592da
Test
davidfluck-hpe Oct 8, 2024
1e72803
Update pre-commit/lock-api-state.sh to install protobuf deps.
davidfluck-hpe Oct 8, 2024
63569ca
Add verbose: true to debug lock-api-state hook.
davidfluck-hpe Oct 8, 2024
a157f95
* Add actions/setup-go@v5 to the pre-commit GitHub Action. This is
davidfluck-hpe Oct 8, 2024
d22a667
lock-api-state precommit hook, verbose: false
davidfluck-hpe Oct 8, 2024
9be6717
Put protobuf back.
davidfluck-hpe Oct 8, 2024
ed7aa78
Tweak lock-api-state hook description.
davidfluck-hpe Oct 8, 2024
26901b8
Debug lock-api-state.sh
davidfluck-hpe Oct 8, 2024
e0c0b0c
Debug
davidfluck-hpe Oct 9, 2024
9ae8f2f
Remove debug statements, remove pass_filenames.
davidfluck-hpe Oct 9, 2024
5f7a473
Set extra_args to "" for the pre-commit hook, otherwise it runs on all
davidfluck-hpe Oct 9, 2024
3ce6bea
Test proto/ change.
davidfluck-hpe Oct 9, 2024
2fb5c9d
Output arguments
davidfluck-hpe Oct 9, 2024
91253f8
shfmt
davidfluck-hpe Oct 9, 2024
622b124
Test
davidfluck-hpe Oct 9, 2024
c18ede8
verbose: true
davidfluck-hpe Oct 9, 2024
88658da
Tweak regex
davidfluck-hpe Oct 9, 2024
cc0ed5b
Test
davidfluck-hpe Oct 9, 2024
092e55e
Tweak regex
davidfluck-hpe Oct 9, 2024
305d378
Test
davidfluck-hpe Oct 9, 2024
8f45751
Tweak regex. Again.
davidfluck-hpe Oct 9, 2024
322a440
Test
davidfluck-hpe Oct 9, 2024
e3892bf
Degenerate regex.
davidfluck-hpe Oct 9, 2024
0308f9c
Test
davidfluck-hpe Oct 9, 2024
d40f99f
OG regex and remove extra_args.
davidfluck-hpe Oct 9, 2024
8fba3ee
Fix regex.
davidfluck-hpe Oct 9, 2024
b6f0d5a
Fix key and terrible quoting typo.
davidfluck-hpe Oct 9, 2024
b821b0f
Remove debug statement.
davidfluck-hpe Oct 9, 2024
5112d1b
Remove test lines.
davidfluck-hpe Oct 9, 2024
464de79
Add regenerated buf.image.bin.
davidfluck-hpe Oct 9, 2024
e52f7cf
Move protobuf dependency installation to GitHub Action.
davidfluck-hpe Oct 9, 2024
154aca5
Add lock-published-urls pre-commit step, along with the requisite
davidfluck-hpe Oct 9, 2024
be87464
Test something
davidfluck-hpe Oct 10, 2024
d020ad3
Test
davidfluck-hpe Oct 10, 2024
e4d3c49
Test.
davidfluck-hpe Oct 10, 2024
68fd4ba
verbose: true
davidfluck-hpe Oct 10, 2024
94260b2
verbose: true
davidfluck-hpe Oct 10, 2024
c64d6e6
Restore proto deps installation.
davidfluck-hpe Oct 11, 2024
fffdae5
Test
davidfluck-hpe Oct 11, 2024
61ae691
Test
davidfluck-hpe Oct 11, 2024
928c977
Test
davidfluck-hpe Oct 11, 2024
5f3cfb4
Test
davidfluck-hpe Oct 11, 2024
b99f167
Remove verbose.
davidfluck-hpe Oct 11, 2024
4c2add1
Fix pre-commit.yml spacing to clean up diff.
davidfluck-hpe Oct 14, 2024
3bd33b0
Delete lock-api-state.sh and lock-published-urls.sh from
davidfluck-hpe Oct 14, 2024
ef8f679
Add lock-published-urls make target for docs. This cleans up the
davidfluck-hpe Oct 14, 2024
be4ad8f
Remove lock-api-state.sh section from tools/scripts/README.md.
davidfluck-hpe Oct 14, 2024
a033120
Remove unhelpful comment.
davidfluck-hpe Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
with:
python-version: '3.9'
cache: 'pip'
- uses: actions/setup-go@v5
with:
go-version: '1.22.0'
- name: "Install protobuf dependencies."
run: "make get-deps-proto"
# this action is not getting new features, but isn't deprecated yet
# switch to just running pre-commit locally when/if that happens that's
# why this one specifies a full version; presumably there will be a
Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ repos:
description: "Runs `golangci-lint`, install https://github.com/golangci/golangci-lint"
exclude: ^(proto/pkg|hpc-ard-launcher-go/launcher/)
require_serial: true
- id: lock-api-state
name: "Generate buf image (lock-api-state.sh)"
entry: ./pre-commit/lock-api-state.sh
language: "script"
description: "Fails if the existing protobuf definitions would generate a new buf.image.bin."
files: '^proto/'
pass_filenames: false
- id: lock-published-urls
name: "Generate all_published_urls_ever.json (lock-published-urls.sh)"
entry: ./pre-commit/lock-published-urls.sh
language: "script"
description: "Ensure all redirect URLs are generated at commit time."
files: '^docs/'
pass_filenames: false

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
Expand Down
4 changes: 4 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ check: attributions.rst
git ls-files -z '*.rst' | xargs -0 rstfmt -w $(RSTFMT_WIDTH) --check
python3 redirects.py check

.PHONY: lock-published-urls
lock-published-urls: attributions.rst
python3 redirects.py publish

.PHONY: get-deps
get-deps:
pip install -r requirements.txt
10 changes: 10 additions & 0 deletions pre-commit/lock-api-state.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Regenerate proto/buf.image.bin
make -C proto gen-buf-image

# If proto/buf.image.bin has been modified locally, then we have changes to
# commit, and the status check returns a 1 and fails. Otherwise, it returns a 0
# and succeeds.
git diff --exit-code -- proto/buf.image.bin
exit $?
8 changes: 8 additions & 0 deletions pre-commit/lock-published-urls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

make -C docs lock-published-urls

# If docs/.redirects/all_published_urls_ever.json has been modified locally,
# then `redirects.py publish` has made modifications that we need to commit.
git diff --exit-code -- docs/.redirects/all_published_urls_ever.json
exit $?
Binary file modified proto/buf.image.bin
Binary file not shown.
7 changes: 0 additions & 7 deletions tools/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,3 @@ The relevant metadata are:
* `Webui`: boolean indicating if this is a dependency of the WebUI

For instructions on how to use `gen-attributions.py`, just run it with no arguments.

## `lock-api-state.sh`: Lock-in current API state

We use [buf.build](https://docs.buf.build/) to provide backward compatibility check
for API changes in Determined. By running this script on each release, we store a
snapshot of the API state and on each following change `buf` compares the new state
with the old to ensure that backward compatibility is preserved.
19 changes: 0 additions & 19 deletions tools/scripts/lock-api-state.sh

This file was deleted.

22 changes: 0 additions & 22 deletions tools/scripts/lock-published-urls.sh

This file was deleted.

Loading