@@ -460,3 +460,68 @@ hard coding them.
460
460
assert cumulative_product(array) == [0 ] * len (array)
461
461
462
462
|
463
+
464
+ CI / CD
465
+ ^^^^^^^
466
+
467
+ The term CI/CD stands for "continuous integration / continuous deployment". The idea
468
+ integrates `development ` with software `operations ` and can be a non-trivial topic
469
+ to cover, let alone implement.
470
+ This concept is equally applicable to the previous section on :ref: `packaging <packaging >`
471
+ as well as the next section on :ref: `documentation <documentation >`. We'll include it here
472
+ because it's a great idea to implement for automated testing.
473
+
474
+ What would be great is if we could automate running our tests on all changes to the code.
475
+ Not just locally, but using our version control system, so that contributions made to
476
+ the code are automatically tested without us needing to pull down that branch and running
477
+ the tests manually to see if everything is okay. We want a nice "green light" to give us
478
+ the `all-clear ` -- always.
479
+
480
+ There are several services out there that will integrate with your version control hosting
481
+ platform and automatically run a customizable workflow when events happen
482
+ (e.g., on a `pull request ` or a new `push ` to the repository). If you're hosting your
483
+ project on GitHub though, using the freely available
484
+ `Github Actions <https://github.com/features/actions >`_ is a super simple way to provide this
485
+ functionality for your Python project.
486
+
487
+ We basically just need to include a configuration file in our project in a special location
488
+ and GitHub will automatically understand what to do. Here is a really basic example to get
489
+ started that will run ``pytest `` for us everytime we have new commits or PRs to the `develop `
490
+ branch of our project using multiple versions of Python.
491
+
492
+ .. code-block :: yaml
493
+ :caption : .github/workflows/tests.yml
494
+
495
+ name : tests
496
+
497
+ on :
498
+ push :
499
+ branches : [ master, develop ]
500
+ pull_request :
501
+ branches : [ develop ]
502
+
503
+ jobs :
504
+ testing :
505
+ runs-on : ubuntu-latest
506
+ strategy :
507
+ matrix :
508
+ python-version : ['3.8', '3.9']
509
+
510
+ steps :
511
+ - uses : actions/checkout@v2
512
+ - name : Set up Python ${{ matrix.python-version }}
513
+ uses : actions/setup-python@v2
514
+ with :
515
+ python-version : ${{ matrix.python-version }}
516
+
517
+ - name : Install Project
518
+ run : |
519
+ python -m pip install --upgrade pip setuptools wheel pytest hypothesis
520
+ python -m pip install pipenv
521
+ pipenv install --deploy --system
522
+
523
+ - name : Run Tests
524
+ run : |
525
+ pytest -v
526
+
527
+ |
0 commit comments