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

Create a version number for the crawler #30

Merged
merged 2 commits into from
Nov 28, 2016
Merged

Create a version number for the crawler #30

merged 2 commits into from
Nov 28, 2016

Conversation

adilsoncarvalho
Copy link
Owner

Resolves #15

It looks for a file for the class with a .version extension to be
created by the CI and uses the class name + dev during development
@adilsoncarvalho
Copy link
Owner Author

The code added on f6392bf will look for a file within the class file with the .version extension to get the version number. If it is not present it'll be assumed a dev version.

For each spider class the CI must provide a version file with the short sha1 so it will be loaded and used as the version for the spider.

The CI must be smart enough to detect that that spider got changed to it would be important to change its version. Maybe there is a way to get from git the last commit that changed it.

The file structure

# the class file
/scrapy/nfcrawler/nfcrawler/spiders/pr_nfce.py

# the expected version file
/scrapy/nfcrawler/nfcrawler/spiders/pr_nfce.version

The versions

# during development
spider-name/dev

# production
spider-name/f6392bf

@adilsoncarvalho
Copy link
Owner Author

Getting the sha1 of the last change on file

git rev-list HEAD -1 -- FILENAME

There is no --short option 😭

➜  barateza-nfcrawler git:(15-issue) git rev-list HEAD -1 -- nfcrawler/nfcrawler/spiders/pr_nfce.py
f6392bfd8dd119cc6f62c6a726988bc9bb754a58

➜  barateza-nfcrawler git:(15-issue) git rev-list HEAD -1 -- Dockerfile
cdd8b270d06c067d77104f3a538c1d96b37f2964

@adilsoncarvalho
Copy link
Owner Author

There is a --short option (with another name) 🎊

➜  barateza-nfcrawler git:(15-issue) git rev-list HEAD -1 --abbrev-commit -- Dockerfile
cdd8b27

@adilsoncarvalho
Copy link
Owner Author

adilsoncarvalho commented Nov 28, 2016

Added spider version on commit 9afa76e.

{
  "spider": {"version": "pr-nfce/dev"}
}

@adilsoncarvalho
Copy link
Owner Author

Maybe we should consider storing the Scrapy stats. See issue #32

@adilsoncarvalho adilsoncarvalho merged commit d09d52a into master Nov 28, 2016
@adilsoncarvalho adilsoncarvalho deleted the 15-issue branch November 28, 2016 21:28
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.

1 participant