Skip to content

Commit 5b22b7a

Browse files
committed
Add shared configuration snippet.
Usage instructions are modified accordingly with the usage of shared configuration snippets. Close #1. Fix documentation typo.
1 parent 6d089b8 commit 5b22b7a

4 files changed

Lines changed: 107 additions & 77 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog],
66
and this project adheres to [Semantic Versioning].
77

88
## [Unreleased]
9+
### Added
10+
- Travis CI shared configuration snippet intented to be sourced in user
11+
configuration (`dev.yml`).
912

1013
## [0.1.2] - 2020-01-13
1114
### Fixed

README.md

Lines changed: 22 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Helps to install Python to Travis CI machines in Linux, macOS and Windows.
1212
_travis-python_ is just a Bash script providing a helper function:
1313

1414
```bash
15-
install_python $LOCATION $SPECIFIER
15+
install_python <location> <specifier>
1616
```
1717

1818
The specified Python version, if found, will be installed at the specified
@@ -35,89 +35,31 @@ Usage
3535
To be able to use _travis-python_, the Travis machine needs to be configured
3636
to be able to run in the three operating systems.
3737

38-
First, use a `shell` environment as it is the only minimal environment available
39-
in the three OS:
38+
The easiest way to do it is to [import][travis-config-imports] the shared
39+
configuration snippet:
4040

4141
```yaml
42-
language: shell
42+
import: neimad/travis-python:dev.yml
4343
```
4444
45-
Then, specify the required operating systems:
45+
Read [the configuration documentation] to understand how it works.
4646
47-
```yaml
48-
os:
49-
- linux
50-
- osx
51-
- windows
52-
```
53-
54-
Finally, load the _travis-python_ script during the `pre-install` phase:
47+
Then, specify the wanted Python version using the `PYTHON` environment
48+
variable:
5549

5650
```yaml
57-
pre-install:
58-
- curl -o travis-python.bash -sSL https://git.io/JeaZo
59-
&& source travis-python.bash
60-
- install_python $LOCATION $VERSION
61-
```
51+
import: neimad/travis-python:dev.yml
6252
63-
### Jobs for multiple Python versions
64-
65-
You can run jobs for multiple Python versions by using an environment variable
66-
within the job matrix:
67-
68-
```yaml
6953
env:
70-
- PYTHON="3.7"
71-
- PYTHON="3.6"
72-
73-
pre-install:
74-
- install_python $LOCATION $PYTHON
54+
- PYTHON=3.8
55+
- PYTHON=3.7
56+
- PYTHON=2
7557
```
58+
By default, it will generate a build matrix using the three operating systems
59+
available on Travis CI (Linux, macOS and Windows).
7660

77-
### Caching data
78-
79-
To speed up your jobs, you can cache the Python environment:
80-
81-
```yaml
82-
pre-install:
83-
- install_python $HOME/Python $PYTHON
84-
85-
cache:
86-
directories:
87-
- $HOME/Python
88-
```
89-
90-
### Minimal recommended configuration
91-
92-
```yaml
93-
language: shell
94-
95-
os:
96-
- linux
97-
- osx
98-
- windows
99-
100-
osx_image: xcode11
101-
102-
env:
103-
- PYTHON="3.8"
104-
- PYTHON="3.7"
105-
- PYTHON="3.6"
106-
- PYTHON="2"
107-
108-
pre-install:
109-
- curl -o travis-python.bash -sSL https://git.io/JeaZo
110-
&& source travis-python.bash
111-
- install_python $HOME/Python $PYTHON
112-
113-
install: ...
114-
115-
script: ...
116-
117-
cache:
118-
directories:
119-
- $HOME/Python
120-
```
61+
The Python distribution is installed during the `pre-install` phase and
62+
available using the `python` program name (whether it is Python 2 or 3).
12163

12264
Behind the scene
12365
----------------
@@ -168,14 +110,17 @@ License
168110

169111
`travis-python` is licensed under the [GNU GPL 3 or later][license].
170112

171-
[license]: https://github.com/neimad/travis-python/blob/master/LICENSE.md
172-
[the changelog]: CHANGELOG.md
173-
[ci]: https://travis-ci.org/neimad/travis-python
174113
[ci-badge]: https://img.shields.io/travis/neimad/travis-python?style=flat-square
175114
[release-badge]: https://img.shields.io/github/v/tag/neimad/travis-python?sort=semver&style=flat-square
176-
177115
[license-badge]: https://img.shields.io/github/license/neimad/travis-python?style=flat-square
116+
117+
[license]: LICENSE.md
118+
[the changelog]: CHANGELOG.md
119+
[the configuration documentation]: doc/Travis_Configuration.md
178120
[look at the existing tickets]: https://github.com/neimad/travis-python/issues
179121
[make a pull request]: https://github.com/neimad/travis-python/pulls
122+
[ci]: https://travis-ci.org/neimad/travis-python
123+
180124
[travis-python-versions]: https://docs.travis-ci.com/user/languages/python/#specifying-python-versions
125+
[travis-config-imports]: https://docs.travis-ci.com/user/build-config-imports/
181126
[shellspec]: https://shellspec.info

dev.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Travis CI configuration snippet to use the latest development version of
2+
# travis-python.
3+
#
4+
# Just import it in your Travis CI configuration:
5+
#
6+
# import: neimad/travis-python:dev.yml
7+
#
8+
9+
language: shell
10+
11+
os:
12+
- linux
13+
- osx
14+
- windows
15+
16+
before_install:
17+
- wget https://raw.githubusercontent.com/neimad/travis-python/master/travis-python.bash
18+
- source travis-python.bash
19+
- install_python $HOME/python $PYTHON

doc/Travis_Configuration.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Travis CI Configuration
2+
3+
This document helps you understand how the Travis CI machine is configured to
4+
use `travis-python` when you import one of ours shared configuration snippets.
5+
6+
It is usefull if you want to use a custom configuration without importing
7+
snippet.
8+
9+
## CI Environment
10+
11+
The `shell` environment is used because it is the only minimal environment
12+
available in the three OSes:
13+
14+
```yaml
15+
language: shell
16+
```
17+
18+
## Operating system
19+
20+
As `travis-python` is intented to be used to test Python software on Linux,
21+
macOS and Windows; all three are specified:
22+
23+
```yaml
24+
os:
25+
- linux
26+
- osx
27+
- windows
28+
```
29+
30+
## Script loading
31+
32+
The `travis-python` script is loaded during the `pre-install` phase.
33+
34+
It need to be sourced in order to modify environment variables (like `PATH`) in
35+
the current shell. But as macOS machines use Bash 3.2, sourcing from `stdin` is
36+
not supported:
37+
38+
```yaml
39+
pre-install:
40+
- source <(curl -sSL $url) # not supported on Bash 3.2
41+
```
42+
43+
So, the script is downloaded using `wget` then sourced:
44+
45+
```yaml
46+
pre-install:
47+
- wget https://raw.githubusercontent.com/neimad/travis-python/master/travis-python.bash
48+
- source travis-python.bash
49+
```
50+
51+
## Python installation
52+
53+
Finally, the Python distribution can be installed in the `$HOME/python`
54+
directory:
55+
56+
```yaml
57+
pre-install:
58+
- ...
59+
- install_python $HOME/python $PYTHON
60+
```
61+
62+
The Python distribution version to install is specified using the `PYTHON`
63+
environment variable.

0 commit comments

Comments
 (0)