Skip to content

Improvements to the configuration logic - #744

Merged
pombredanne merged 6 commits into
aboutcode-org:developfrom
heremaps:git-reconfigure
Sep 19, 2017
Merged

Improvements to the configuration logic#744
pombredanne merged 6 commits into
aboutcode-org:developfrom
heremaps:git-reconfigure

Conversation

@sschuberth

Copy link
Copy Markdown
Collaborator

Most notably, automatically re-configure if ScanCode is run from a Git working tree and new commits are present. This is useful for running on CI which incrementally fetches ScanCode's code from Git (without applying any local changes).

Note that the new SCANCODE_GIT_MODE is orthogonal to the existing SCANCODE_DEV_MODE: In development mode the license cache is always checked for consistency, which is not needed when running from a clean Git working tree without any local changes.

This fixes issues like the one I've been running into as described at #735.

@sschuberth
sschuberth requested a review from pombredanne August 30, 2017 09:37
Make this in line with output from the start scripts.
As there is a subtle difference when running ./configure directly (dev
config is being used) and ./configure being run by the scancode script
(dev config not being used), print the config being usd in any case.
This is usuall is just two lines and does not really clutter the output.
This way the explanation is also visible without looking at the source
code.

@pombredanne pombredanne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Do you think this is worth having for Windows too? (IMHO not) ... And what could be the automated test we could setup for this?

Comment thread scancode

SCANCODE_CONFIG_DIR="etc/conf"

GIT_STATUS=$(git -C "$SCANCODE_ROOT_DIR" status --porcelain 2> /dev/null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this also implicitly checks for Git being available locally? Just curious what the different with a plain git status?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Exactly. It implicitly checks for $SCANCODE_ROOT_DIR to be a Git working tree (git status returns code 128 otherwise), and also for the git executable to be present (in this case it's Bash that returns code 127).

Comment thread scancode
GIT_COMMIT_HEAD=$(git -C "$SCANCODE_ROOT_DIR" rev-parse HEAD)
if [ "$GIT_COMMIT_CONFIGURED" != "$GIT_COMMIT_HEAD" ]; then
echo "* (Re-)Configuring ScanCode because Git commits have changed..."
CONFIGURE_QUIET=1 $SCANCODE_ROOT_DIR/configure $SCANCODE_CONFIG_DIR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMHO to be really safe, you should first issue a configure --clean but let see first if this is enough.
There could be cases where files have been removed and there could be dangling .pyc files left over in some rare cases

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

FWIW, I tried to avoid a full clean by doing e.g. 773bffa.

@sschuberth

Copy link
Copy Markdown
Collaborator Author

Do you think this is worth having for Windows too?

I forgot to mention that I wanted to do this for Linux first to align on the logic, and they (maybe) later do it for Windows, too. But as CI is mostly running on Linux, I don't have any immediate plans to implement this for Windows.

@codecov

codecov Bot commented Aug 30, 2017

Copy link
Copy Markdown

Codecov Report

Merging #744 into develop will decrease coverage by 5.04%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #744      +/-   ##
===========================================
- Coverage    77.72%   72.68%   -5.05%     
===========================================
  Files           91       91              
  Lines        11009    12328    +1319     
===========================================
+ Hits          8557     8960     +403     
- Misses        2452     3368     +916
Impacted Files Coverage Δ
src/scancode/utils.py 57.85% <0%> (-33.55%) ⬇️
src/commoncode/version.py 66.66% <0%> (-33.34%) ⬇️
src/commoncode/paths.py 63.52% <0%> (-31.85%) ⬇️
src/extractcode/archive.py 57.06% <0%> (-29.66%) ⬇️
src/extractcode/libarchive2.py 66.44% <0%> (-28.26%) ⬇️
src/extractcode/__init__.py 64.21% <0%> (-27.9%) ⬇️
src/scancode/cli.py 67.27% <0%> (-25.62%) ⬇️
src/scancode/cli_test_utils.py 73.01% <0%> (-22.64%) ⬇️
src/scancode/cache.py 65.36% <0%> (-19.71%) ⬇️
src/commoncode/fileset.py 53.63% <0%> (-18.16%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63da926...c95017a. Read the comment docs.

@pombredanne

Copy link
Copy Markdown
Member

LGTM. Thanks!

@pombredanne
pombredanne merged commit fc2e320 into aboutcode-org:develop Sep 19, 2017
@sschuberth
sschuberth deleted the git-reconfigure branch September 20, 2017 06:29
@pombredanne

pombredanne commented Sep 20, 2017

Copy link
Copy Markdown
Member

Somehow there are a few things I am not entirely getting on the overall behavior here. I will dive in it a bit more and eventually submit a new PR/ticket about this

@sschuberth

Copy link
Copy Markdown
Collaborator Author

Like, did it break something? Or is it "only" a matter of understanding how it works?

@pombredanne

Copy link
Copy Markdown
Member

@sschuberth I guess I am not sure how this works and interacts with the SCANCODE_DEV_MODE :P

@sschuberth

Copy link
Copy Markdown
Collaborator Author

I was hoping to make that clear in the second paragraph of the top post in this PR :-)

@pombredanne

Copy link
Copy Markdown
Member

fair enough: let me reread all this first

@pombredanne

Copy link
Copy Markdown
Member

@sschuberth here are the issues that I can see:

If I have a git clone and I ran plain ./configure explicitly, this will use the etc/conf/dev and create the SCANCODE_DEV_MODE tag file, which is then used by the license cache check code to force a recheck of cache consistency wrt. the current code and license rules/files.

Now with the changes in this PR, a run of ./scancode with a git tree that is not clean will force a new ./configure run using etc/conf as a conf instead which as a side effect wipes the SCANCODE_DEV_MODE tag file, creates a SCANCODE_GIT_MODE and reconfigures and then re-index licenses even though I did not want any reconfiguration to take place in this case.

It furthermore echoes messages such as * (Re-)Configuring ScanCode because Git .... which should not be echoed at all IMHO.

There are other possible issues: doing a ./configure after a pull may not be enough and in many cases a ./configure --clean is needed: for instance say a python .py file was renamed: without a clean there may be dangling and orphaned .pyc files left over from before the rename of the corresponding .py file and this can create weird issues

I will come up with fixes for this

@sschuberth

Copy link
Copy Markdown
Collaborator Author

It furthermore echoes messages such as * (Re-)Configuring ScanCode because Git .... which should not be echoed at all IMHO.

Just a quick reply to this one: I disagree here. We already have echo "* Configuring ScanCode for first use...", so I believe if we reconfigure not necessarily because it's the first use, but because there are Git changes, we should say so, too.

@pombredanne

Copy link
Copy Markdown
Member

@sschuberth

Just a quick reply to this one: I disagree here.

Fair point!

So let me come with a new ticket with a clear statement of what we want , can/could/should do here

@pombredanne

Copy link
Copy Markdown
Member

When I say here, I meant what to do wrt. to running and configuring scancode from different user type standpoints and what should be automated and what should not

@pombredanne

Copy link
Copy Markdown
Member

@sschuberth since merging is creating some confusion based on @armijnhemel feedback ... may be we could revert these changes in a new PR and apply them anew with some updates?

@sschuberth

Copy link
Copy Markdown
Collaborator Author

As you prefer, I'm fine with that!

@pombredanne

pombredanne commented Sep 26, 2017

Copy link
Copy Markdown
Member

@sschuberth I reverted the #744 PR commit in develop and pushed the original branch of this PR as https://github.com/nexB/scancode-toolkit/tree/735-769-git-reconfigure

Follow up work will take place in in #769

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