Skip to content

chore: check if build is dirty and fail#26172

Merged
praveen-influx merged 1 commit intomainfrom
chore/add-dirty-check
Mar 20, 2025
Merged

chore: check if build is dirty and fail#26172
praveen-influx merged 1 commit intomainfrom
chore/add-dirty-check

Conversation

@praveen-influx
Copy link
Copy Markdown
Contributor

@praveen-influx praveen-influx commented Mar 20, 2025

This is to enable checking if build is dirty due to changes to git versioned file during the build process. This used to be reported in the influxdb3 --version which in turn was relying on git describe. Because,

  • we don't want the final revision string to contain -dirty and
  • git describe does more than just report the commit hash used to tag a release

it was switched to use git rev-parse in commit.

Now with this PR, instead of reporting it's been dirtied the pipeline itself checks and stops the job if it detects any changes.

Test

Tested locally and checked if the script works by manually sshing into circle ci instance and introducing changes.

root@instance:~/project# echo "FOO" >> README.md
root@instance:~/project# git diff --exit-code --quiet || exit 1
logout

Given this relies on changes introduced during build this is the best I could come up with for testing it.

Update:

As per @jdstrand idea, I introduced a write before the git diff check and you can see the build failure here,

https://app.circleci.com/pipelines/github/influxdata/influxdb/44879/workflows/e3c22709-dfde-4e94-91c8-08203000b6a9/jobs/425044

The actual update to circleci config,

      - run:
          name: add a change (temporary)
          command: |
            echo "FOO" >> README.md
      - run:
          # this runs diff twice, once to report the changes so that it's easier to see the changed file in circleci
          # if it is dirty build should fail with exit 1
          name: check build is dirty
          command: |
            git diff --exit-code
            git diff --exit-code --quiet || exit 1

@praveen-influx praveen-influx force-pushed the chore/add-dirty-check branch from bf154ac to 03abf0b Compare March 20, 2025 12:29
@praveen-influx praveen-influx requested review from a team and jdstrand March 20, 2025 14:47
Copy link
Copy Markdown
Contributor

@jdstrand jdstrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think your testing is fine but if desired, you could adjust the check build is dirty step in build-dev to cat something to the README.md right before running git diff and give the job failure CircleCI url as a comment to this PR, then revert that change.

@praveen-influx praveen-influx force-pushed the chore/add-dirty-check branch from 03abf0b to 476a209 Compare March 20, 2025 17:18
@praveen-influx
Copy link
Copy Markdown
Contributor Author

you could adjust the check build is dirty step in build-dev to cat something to the README.md right before running git diff and give the job failure CircleCI url as a comment to this PR, then revert that change.

That is a good idea - I can do that.

@praveen-influx praveen-influx force-pushed the chore/add-dirty-check branch from 476a209 to 28f0020 Compare March 20, 2025 17:29
Copy link
Copy Markdown
Contributor

@jdstrand jdstrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@praveen-influx praveen-influx merged commit 823e792 into main Mar 20, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants