Skip to content

Commit 5aadf8c

Browse files
committed
Finished circleci docs
1 parent 2d22d02 commit 5aadf8c

File tree

2 files changed

+56
-40
lines changed

2 files changed

+56
-40
lines changed

.circleci/config.yml

-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ jobs:
33
build:
44
docker:
55
# specify the version you desire here
6-
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
76
- image: circleci/python:3.6.1
87

9-
# Specify service dependencies here if necessary
10-
# CircleCI maintains a library of pre-built images
11-
# documented at https://circleci.com/docs/2.0/circleci-images/
12-
# - image: circleci/postgres:9.4
138

149
working_directory: ~/repo
1510

docs/testing-and-ci.rst

+56-35
Original file line numberDiff line numberDiff line change
@@ -258,67 +258,88 @@ Time to celebrate with the API :)
258258
Continuous integration with CircleCI
259259
---------------------------------------
260260

261-
Maintaining a solid rapport with the ongoing software development process always turns out to be a walk on air. Ensuring a software build integrity and quality in every single commit makes it much more exciting.
261+
We have the tests, but we also want it to run on every commit. If you are using Github, CircleCI provides a very well in integrated servive to run you tests. We will use Circleci. v2
262262

263-
If the current software bulid is constantly available for testing, demo or release isn't it a developer's paradise on earth?
264-
Giving a cold shoulder to "Integration hell" the 'Continuous integration' process stands out to deliver all the above assets.
263+
We can configure our application to use Circle CI by adding a file named :code:`.circleci/circle.yml` which is a YAML(a human-readable data serialization format) text file. It automatically detects when a commit has been made and pushed to a Github repository that is using CircleCI, and each time this happens, it will try to build the project and runs tests. The build failure or success is notified to the developer.
265264

266-
Let us use circle CI software for our App.
267-
268-
We can configure our application to use Circle CI by adding a file named circle.yml which is a YAML(a human-readable data serialization format) text file. It automatically detects when a commit has been made and pushed to a GitHub repository that is using Circle CI, and each time this happens, it will try to build the project and runs tests. It also builds and once it is completed it notifies the developer in the way it is configured.
269-
270-
Steps to use Circle CI:
265+
Setting up CircleCI
266+
---------------------------------------
271267

272268
- Sign-in: To get started with Circle CI we can sign-in with our github account on circleci.com.
273269
- Activate Github webhook: Once the Signup process gets completed we need to enable the service hook in the github profile page.
274270
- Add circle.yml: We should add the yml file to the project.
275271

276272
Writing circle.yml file
277273
------------------------
278-
In order for circle CI to build our project we need to tell the system a little bit about it. we will be needed to add a file named circle.yml to the root of our repository. The basic options in the circle.yml should contain are language key which tells which language environment to select for our project and other options include the version of the language and command to run the tests, etc.
279274

280-
Below are the keywords that are used in writting circle.yml file.
275+
In order for circle CI to build our project we need to tell the system a little bit about it. we will be needed to add a file named :code:`.circleci/config.yml` to the root of our repository. We also need to create a :code:`pollsapi/requirements.txt` to define our dependencies.
281276

282-
- machine: adjusting the VM to your preferences and requirements
283-
- checkout: checking out and cloning your git repo
284-
- dependencies: setting up your project's language-specific dependencies
285-
- database: preparing the databases for your tests
286-
- test: running your tests
287-
- deployment: deploying your code to your web servers
277+
Add this to your :code:`pollsapi/requirements.txt`
288278

279+
.. code-block:: txt
289280
290-
- pre: commands run before CircleCI's inferred commands
291-
- override: commands run instead of CircleCI's inferred commands
292-
- post: commands run after CircleCI's inferred commands
281+
Django==2.0.3
282+
djangorestframework==3.7.7
293283
284+
And then add this to :code:`.circleci/config.yml`
294285

295-
Example for circle.yml for python project:
296286

297-
.. code-block:: python
287+
.. code-block:: yaml
288+
289+
version: 2
290+
jobs:
291+
build:
292+
docker:
293+
# specify the version you desire here
294+
- image: circleci/python:3.6.1
295+
296+
297+
working_directory: ~/repo
298298

299-
## Customize the test machine
300-
machine:
299+
steps:
300+
- checkout
301301

302-
timezone:
303-
Asia/Kolkata # Set the timezone
302+
# Download and cache dependencies
303+
- restore_cache:
304+
keys:
305+
- v1-dependencies-{{ checksum "pollsapi/requirements.txt" }}
306+
# fallback to using the latest cache if no exact match is found
307+
- v1-dependencies-
304308

305-
# Version of python to use
306-
python:
307-
version: 2.7.5
309+
- run:
310+
name: install dependencies
311+
command: |
312+
python3 -m venv venv
313+
. venv/bin/activate
314+
pip install -r pollsapi/requirements.txt
308315

309-
dependencies:
310-
pre:
311-
- pip install -r requirements.txt
316+
- save_cache:
317+
paths:
318+
- ./venv
319+
key: v1-dependencies-{{ checksum "requirements.txt" }}
312320

313-
test:
314-
override:
315-
- python manage.py test
321+
- run:
322+
name: run tests
323+
command: |
324+
. venv/bin/activate
325+
cd pollsapi
326+
python manage.py test
316327

317-
From now onwards whenever we push our code to our repository a new build will be created for it and the running of the test cases will be taken place. It gives us the potential to check how good our development process is taking place with out hitting a failed test case.
328+
- store_artifacts:
329+
path: test-reports
330+
destination: test-reports
318331

332+
Below are the important keywords that are used in writting circle.yml file.
319333

334+
- :code:`image`: Defines the base image including the language and version to use
335+
- :code:`run`: It specifies a :code:`command` which will be run to setup environent and run tests. :code:`pip install -r pollsapi/requirements.txt` sets up the environment and :code:`pip install -r pollsapi/requirements.txt`
320336

337+
If everything passed successfully, you should see a green checkmark
321338

339+
.. image:: circleci.png
322340

341+
Congratulations, you have tests running in a CI environment.
323342

343+
From now onwards whenever we push our code to our repository a new build will be created for it and the tests will run.
324344

345+
We are at the end of the first part of our book. You can read the appendix, which tell about some documentation tools and api consumption tools. Go forward and build some amazing apps and apis.

0 commit comments

Comments
 (0)