-
Notifications
You must be signed in to change notification settings - Fork 2
CI: repo hygiene checks #601
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
Changes from all commits
cea395b
81c33ae
8680559
1f194a9
fe51e90
a1a124c
9ee3e0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: Repo Hygiene Checks | ||
|
|
||
| on: | ||
| merge_group: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| hygiene-checks: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v6 # v6 | ||
| with: | ||
| cache: true | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Install just | ||
| uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d # v2.0.0 | ||
|
|
||
| - name: Install go-tools | ||
| run: just install-go-tools | ||
|
|
||
| - name: Run repo hygiene checks | ||
| run: tools/bin/check_repo_clean.sh tidy mock generate shellcheck | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New CI command. Runs the provided just targets and ensures they don't modify the repo or return an error. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,16 +37,14 @@ jobs: | |
|
|
||
| - name: Install Just | ||
| uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3 | ||
| with: | ||
| just-version: '1.40.0' | ||
|
Comment on lines
-40
to
-41
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only concern w/ this unpinning is if there's a new major version that somehow breaks things - is that a realistic concern?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had the same thought but removed it anyway because: we don't pin the version for developers, we don't pin it consistently in other actions, and the just project would be foolish to break things in that way. |
||
|
|
||
| - name: Authenticate to AWS ECR | ||
| uses: ./.github/actions/aws-ecr-auth | ||
| with: | ||
| role-to-assume: ${{ secrets.CCV_IAM_ROLE }} | ||
| aws-region: us-east-1 | ||
| registry-type: public | ||
|
|
||
| - name: Authenticate to AWS ECR (JD) | ||
| uses: ./.github/actions/aws-ecr-auth | ||
| with: | ||
|
|
@@ -86,4 +84,4 @@ jobs: | |
| env: | ||
| LOKI_URL: http://localhost:3030/loki/api/v1/push | ||
| run: | | ||
| go test -v -run ${{ matrix.test.name }} -timeout 1h | ||
| go test -v -run ${{ matrix.test.name }} -timeout 1h | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 7.20.0-SNAPSHOT | ||
| 7.19.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| docker run --rm \ | ||
| -v "${PWD}:/local" \ | ||
| openapitools/openapi-generator-cli generate \ | ||
| openapitools/openapi-generator-cli:v7.19.0 generate \ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin version so that the |
||
| -i /local/indexer_opanapi_v1.yaml \ | ||
| -g markdown \ | ||
| -o /local/docs | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Script to run repository hygiene commands and fail if they modify the repo. | ||
| # Exits non-zero and prints modified files if any step fails or changes the working tree. | ||
|
|
||
| # Default list of just targets to run for checks (fallback). | ||
| just_targets_to_run=(tidy mock generate shellcheck) | ||
|
|
||
| # If the script is invoked with positional arguments, use those as the targets | ||
| # instead of the default list. Example: | ||
| # ./tools/bin/check_repo_clean.sh tidy mock generate | ||
| if [ "$#" -gt 0 ]; then | ||
| just_targets_to_run=("$@") | ||
| fi | ||
|
|
||
| # Ensure we are inside a git repository | ||
| if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then | ||
| echo "ERROR: not inside a git repository" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| # Ensure `just` is available | ||
| if ! command -v just >/dev/null 2>&1; then | ||
| echo "ERROR: 'just' not found in PATH" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| run_and_check() { | ||
| local before | ||
| local after | ||
|
|
||
| echo "--- Running: just $* ---" | ||
| before=$(git status --porcelain) | ||
|
|
||
| if ! just "$@"; then | ||
| echo "ERROR: 'just $*' failed" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| after=$(git status --porcelain) | ||
|
|
||
| if [ "${before}" != "${after}" ]; then | ||
| echo "" | ||
| echo "ERROR: Repository changed after 'just $*'." >&2 | ||
| echo "Changed files (git status --porcelain):" >&2 | ||
| git --no-pager status --porcelain >&2 | ||
| echo "" | ||
| echo "You should inspect and commit or revert these changes." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "OK: no repo changes after 'just $*'." | ||
| echo "" | ||
| } | ||
|
|
||
| for c in "${just_targets_to_run[@]}"; do | ||
| run_and_check "$c" | ||
| done | ||
|
|
||
| # Print a multiline bulleted list showing which just targets ran | ||
| echo "All checks passed:" | ||
| for t in "${just_targets_to_run[@]}"; do | ||
| echo " * just $t" | ||
| done | ||
|
|
||
| exit 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ os=$(uname) | |
| arch=$(uname -m) | ||
|
|
||
| install_dir=/usr/local | ||
| $install_dir/bin/protoc --version | grep $VERSION | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. misc shellcheck fixes |
||
| $install_dir/bin/protoc --version | grep "$VERSION" | ||
| rc=$? | ||
| if [ $rc -eq 0 ]; then | ||
| # we have the current VERSION | ||
|
|
@@ -38,12 +38,12 @@ else | |
| fi | ||
|
|
||
| workdir=$(mktemp -d) | ||
| pushd $workdir | ||
| pushd "$workdir" || exit 1 | ||
| pb_url="https://github.com/protocolbuffers/protobuf/releases" | ||
| artifact=protoc-$VERSION-$os-$arch.zip | ||
| curl -LO $pb_url/download/v${VERSION}/$artifact | ||
| unzip -o $artifact -d $install_dir | ||
| rm $artifact | ||
| curl -LO "$pb_url/download/v${VERSION}/$artifact" | ||
| unzip -o "$artifact" -d "$install_dir" | ||
| rm "$artifact" | ||
|
|
||
| echo "protoc $VERSION installed in $install_dir" | ||
| popd | ||
| popd || exit 1 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misc cleanup in yaml files