Extracting an Open-Source Project From An Existing Codebase
About me:
Hello! I'm Sophie!
I am a software developer @ Acquisio
I organize Ruby meetups
I love snowboarding, GIFs and my rabbits
@sophiedeziel
So you got that big pile of useful code
Why?
- Will simplify your actual codebase
- Can bring collaborators
- Fresh and new ideas
- Useful code for your future (or parallel) projects
Ideal for a first Open-Source project!
Where to find useful code to extract?
About anywhere!
Are you solving common problems?
Have some cool scripts?
This talk is a step by step guide to extract a project from existing code
Step 1:
Identify and move the key parts of your code.
Tests
Coupling
Dependencies
Step 2:
Refactor your code to move as much as possible in well defined classes/modules
Decouple
Test in isolation
Break dependencies
Step 3:
Setup of the project
Package manager
Create a new folder for your project and follow the instructions specific to your ecosystem. Examples:
> bundle gem [gemname]
> npm init
create a __init__.py file
Etc.
Checklist:
- Dependencies
- Test framework
- Version Management System
Step 4:
Move the code!
Pro tip: Move the tests first
- Make sure all dev and test dependencies are set up
- Some minor changes to the test setup are expected
- Make sure they run
- Make sure they fail properly
Move the implementation
Make those tests pass!
Refactor
Add features
Refactor again
Step 5:
Try it locally
Configure your codebase
- Integrations test
- Follow your ecosystem's way of packaging the library
- Add it as a dependency to your application
- Make the tests pass!
Step 6:
Publish!
Licence
choosealicense.com
Code of conduct
contributor-covenant.org
Version number
I recommend following Semantic Versioning
MAJOR . MINOR . PATCH
Pro tip: Use Git/Github features
- Readme for documentation
- Push hooks to test
- Issue tracker
- Projects
- Tags for releases
- Branches to merge and release bugfixes across versions
Publish!
Some command examples:
-
bundle exec rake release
-
git push
-
npm publish
-
python setup.py sdist upload -r pypi
Step 6:
Profit.
Step 6:
Maintenance
Bugs
New features
Pull requests
Never forget about the documentation
Tools
- CI servers are good friends
- Contributing guides are your friends
- Set expectations on PR (fully tested, code style)
- Use automated review tools (CodeClimate, Hound)
Don't burn out
Step 7:
Profit!
Thank you!
Questions?
Extracting an Open-Source Project From An Existing Codebase
By Sophie Déziel
Extracting an Open-Source Project From An Existing Codebase
- 1,442