This is an archive of the discontinued LLVM Phabricator instance.

[libc++][ci] Detect not committed generated files.
ClosedPublic

Authored by Mordante on Jul 22 2021, 2:52 AM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Commits
rG1139fd4270c7: [libc++][ci] Detect not committed generated files.
Summary

The Generated output CI job only tests for modified files. This job
should also fail the generated output contains new files.

It would be possible to test modified and untracked files in one
execution of git ls-files. However the diff is stored as an artifact
so the execution of git diff would still be required.

Discussion: Would it be better to do git ls-files -om and remove the
excution of
! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false ?
(Obviously then the name generated_output.untracked should change to
something like generated_output.status)

Diff Detail

Event Timeline

Mordante created this revision.Jul 22 2021, 2:52 AM
Mordante requested review of this revision.Jul 22 2021, 2:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2021, 2:52 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Mordante updated this revision to Diff 361118.Jul 23 2021, 1:14 AM

Delete a generated file.
This should cause the build to fail.

Mordante updated this revision to Diff 361119.Jul 23 2021, 1:19 AM

The build passed unexpectedly.
Use the || false method used with grep.

Mordante updated this revision to Diff 361123.Jul 23 2021, 1:43 AM

The last build failed as expected.
Readded the missing file, but it contains manual changes.

Mordante updated this revision to Diff 361124.Jul 23 2021, 1:46 AM

Last build failed as expected.
Remove all manual modifications to the generated files.

Mordante updated this revision to Diff 361128.Jul 23 2021, 1:56 AM

The last build passed as expected.
Restore the removed CI pipelines.

Mordante retitled this revision from [libc++][ci] DO NOT REVIEW YET to [libc++][ci] Detect not committed generated files..Jul 23 2021, 1:59 AM
ldionne added inline comments.
libcxx/utils/ci/run-buildbot
171–181

Would something like this work:

if ! git ls-files -om; then
    echo "It looks like not all the generator scripts were run, did you forget to build the libcxx-generate-files target?"
    false
fi
Mordante planned changes to this revision.Jul 23 2021, 8:59 AM
Mordante added inline comments.
libcxx/utils/ci/run-buildbot
171–181

That doesn't work since the return value of git ls-files -om doesn't indicate a status, I earlier.
I'll rework the patch to generate ${BUILD_DIR}/generated_output.status,
then use if [ -s ${BUILD_DIR}/generated_output.status ]; then to issue a diagnostic.

Mordante updated this revision to Diff 361422.Jul 24 2021, 2:06 AM

Use an alternative approach as @ldionne suggested. This should result in better diagnostics.
Disable the unneeded CI steps for testing purposes.

Mordante updated this revision to Diff 361425.Jul 24 2021, 2:26 AM

Now enable the proper test instead of the inverted test.

Mordante updated this revision to Diff 361426.Jul 24 2021, 2:33 AM

The last build passed as expected.
Remove a generated file to make it fail.

Mordante updated this revision to Diff 361427.Jul 24 2021, 2:38 AM

The last build failed as expected.
Readd the file, but with manual modifications.

Mordante updated this revision to Diff 361428.Jul 24 2021, 2:42 AM

The last build failed as expected.
Undo the changes to the file and the build should pass again.

Mordante updated this revision to Diff 361429.Jul 24 2021, 2:46 AM

The last build passed as expected.
Restore the removed CI steps.

Mordante marked an inline comment as done.Jul 24 2021, 4:49 AM

@ldionne I addressed your comment and tested it. It's ready for review again.

ldionne accepted this revision.Jul 26 2021, 5:32 AM
This revision is now accepted and ready to land.Jul 26 2021, 5:32 AM
This revision was automatically updated to reflect the committed changes.