Skip to content

Commit 45bf9f9

Browse files
committed
Merge remote-tracking branch 'upstream/main' into patch-1
2 parents 19171d0 + c03aeb6 commit 45bf9f9

File tree

144 files changed

+4336
-1488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+4336
-1488
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ max_line_length = 80
99

1010
[*.md]
1111
trim_trailing_whitespace = false
12+
13+
[*.{yaml,yml}]
14+
indent_size = 2

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# GitHub code owners
2+
# See https://help.github.com/articles/about-codeowners/
3+
#
4+
# KEEP THIS FILE SORTED. Order is important. Last match takes precedence.
5+
6+
* @aiordache @ulyssessouza

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Python package
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
DOCKER_BUILDKIT: '1'
7+
8+
jobs:
9+
flake8:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-python@v4
14+
with:
15+
python-version: '3.x'
16+
- run: pip install -U flake8
17+
- name: Run flake8
18+
run: flake8 docker/ tests/
19+
20+
unit-tests:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0-alpha - 3.11.0"]
25+
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
- name: Install dependencies
33+
run: |
34+
python3 -m pip install --upgrade pip
35+
pip3 install -r test-requirements.txt -r requirements.txt
36+
- name: Run unit tests
37+
run: |
38+
docker logout
39+
rm -rf ~/.docker
40+
py.test -v --cov=docker tests/unit
41+
42+
integration-tests:
43+
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
variant: [ "integration-dind", "integration-dind-ssl", "integration-dind-ssh" ]
47+
48+
steps:
49+
- uses: actions/checkout@v3
50+
- name: make ${{ matrix.variant }}
51+
run: |
52+
docker logout
53+
rm -rf ~/.docker
54+
make ${{ matrix.variant }}

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Release Tag WITHOUT `v` Prefix (e.g. 6.0.0)"
8+
required: true
9+
dry-run:
10+
description: 'Dry run'
11+
required: false
12+
type: boolean
13+
default: true
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-22.04
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
24+
25+
- name: Generate Pacakge
26+
run: |
27+
pip3 install wheel
28+
python setup.py sdist bdist_wheel
29+
env:
30+
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DOCKER: ${{ inputs.tag }}
31+
32+
- name: Publish to PyPI
33+
uses: pypa/gh-action-pypi-publish@release/v1
34+
if: '! inputs.dry-run'
35+
with:
36+
password: ${{ secrets.PYPI_API_TOKEN }}
37+
38+
- name: Create GitHub release
39+
uses: ncipollo/release-action@v1
40+
if: '! inputs.dry-run'
41+
with:
42+
artifacts: "dist/*"
43+
generateReleaseNotes: true
44+
draft: true
45+
commit: ${{ github.sha }}
46+
token: ${{ secrets.GITHUB_TOKEN }}
47+
tag: ${{ inputs.tag }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ html/*
1313
_build/
1414
README.rst
1515

16+
# setuptools_scm
17+
_version.py
18+
1619
env/
1720
venv/
1821
.idea/
22+
*.iml

.readthedocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ version: 2
33
sphinx:
44
configuration: docs/conf.py
55

6+
build:
7+
os: ubuntu-20.04
8+
tools:
9+
python: '3.10'
10+
611
python:
7-
version: 3.5
812
install:
913
- requirements: docs-requirements.txt
1014
- requirements: requirements.txt

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
ARG PYTHON_VERSION=2.7
1+
ARG PYTHON_VERSION=3.10
22

33
FROM python:${PYTHON_VERSION}
44

5-
RUN mkdir /src
65
WORKDIR /src
76

87
COPY requirements.txt /src/requirements.txt
9-
RUN pip install -r requirements.txt
8+
RUN pip install --no-cache-dir -r requirements.txt
109

1110
COPY test-requirements.txt /src/test-requirements.txt
12-
RUN pip install -r test-requirements.txt
11+
RUN pip install --no-cache-dir -r test-requirements.txt
1312

14-
COPY . /src
15-
RUN pip install .
13+
COPY . .
14+
ARG SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER
15+
RUN pip install --no-cache-dir .

Dockerfile-docs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PYTHON_VERSION=3.7
1+
ARG PYTHON_VERSION=3.10
22

33
FROM python:${PYTHON_VERSION}
44

@@ -10,6 +10,6 @@ RUN addgroup --gid $gid sphinx \
1010

1111
WORKDIR /src
1212
COPY requirements.txt docs-requirements.txt ./
13-
RUN pip install -r requirements.txt -r docs-requirements.txt
13+
RUN pip install --no-cache-dir -r requirements.txt -r docs-requirements.txt
1414

1515
USER sphinx

Dockerfile-py3

Lines changed: 0 additions & 15 deletions
This file was deleted.

Jenkinsfile

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!groovy
22

3-
def imageNameBase = "dockerbuildbot/docker-py"
4-
def imageNamePy2
3+
def imageNameBase = "dockerpinata/docker-py"
54
def imageNamePy3
5+
def imageDindSSH
66
def images = [:]
77

88
def buildImage = { name, buildargs, pyTag ->
@@ -13,26 +13,27 @@ def buildImage = { name, buildargs, pyTag ->
1313
img = docker.build(name, buildargs)
1414
img.push()
1515
}
16-
images[pyTag] = img.id
16+
if (pyTag?.trim()) images[pyTag] = img.id
1717
}
1818

1919
def buildImages = { ->
20-
wrappedNode(label: "ubuntu && !zfs && amd64", cleanWorkspace: true) {
20+
wrappedNode(label: "amd64 && ubuntu-2004 && overlay2", cleanWorkspace: true) {
2121
stage("build image") {
2222
checkout(scm)
2323

24-
imageNamePy2 = "${imageNameBase}:py2-${gitCommit()}"
2524
imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}"
26-
27-
buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7")
28-
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7")
25+
imageDindSSH = "${imageNameBase}:sshdind-${gitCommit()}"
26+
withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') {
27+
buildImage(imageDindSSH, "-f tests/Dockerfile-ssh-dind .", "")
28+
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.10 .", "py3.10")
29+
}
2930
}
3031
}
3132
}
3233

3334
def getDockerVersions = { ->
34-
def dockerVersions = ["17.06.2-ce"]
35-
wrappedNode(label: "ubuntu && !zfs && amd64") {
35+
def dockerVersions = ["19.03.12"]
36+
wrappedNode(label: "amd64 && ubuntu-2004 && overlay2") {
3637
def result = sh(script: """docker run --rm \\
3738
--entrypoint=python \\
3839
${imageNamePy3} \\
@@ -46,8 +47,6 @@ def getDockerVersions = { ->
4647

4748
def getAPIVersion = { engineVersion ->
4849
def versionMap = [
49-
'17.06': '1.30',
50-
'18.03': '1.37',
5150
'18.09': '1.39',
5251
'19.03': '1.40'
5352
]
@@ -68,39 +67,64 @@ def runTests = { Map settings ->
6867
throw new Exception("Need test image object, e.g.: `runTests(testImage: img)`")
6968
}
7069
if (!dockerVersion) {
71-
throw new Exception("Need Docker version to test, e.g.: `runTests(dockerVersion: '1.12.3')`")
70+
throw new Exception("Need Docker version to test, e.g.: `runTests(dockerVersion: '19.03.12')`")
7271
}
7372
if (!pythonVersion) {
74-
throw new Exception("Need Python version being tested, e.g.: `runTests(pythonVersion: 'py2.7')`")
73+
throw new Exception("Need Python version being tested, e.g.: `runTests(pythonVersion: 'py3.x')`")
7574
}
7675

7776
{ ->
78-
wrappedNode(label: "ubuntu && !zfs && amd64", cleanWorkspace: true) {
77+
wrappedNode(label: "amd64 && ubuntu-2004 && overlay2", cleanWorkspace: true) {
7978
stage("test python=${pythonVersion} / docker=${dockerVersion}") {
8079
checkout(scm)
8180
def dindContainerName = "dpy-dind-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
8281
def testContainerName = "dpy-tests-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
8382
def testNetwork = "dpy-testnet-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
84-
try {
85-
sh """docker network create ${testNetwork}"""
86-
sh """docker run -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
87-
dockerswarm/dind:${dockerVersion} dockerd -H tcp://0.0.0.0:2375
88-
"""
89-
sh """docker run \\
90-
--name ${testContainerName} \\
91-
-e "DOCKER_HOST=tcp://${dindContainerName}:2375" \\
92-
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
93-
--network ${testNetwork} \\
94-
--volumes-from ${dindContainerName} \\
95-
${testImage} \\
96-
py.test -v -rxs --cov=docker tests/
97-
"""
98-
} finally {
99-
sh """
100-
docker stop ${dindContainerName} ${testContainerName}
101-
docker rm -vf ${dindContainerName} ${testContainerName}
102-
docker network rm ${testNetwork}
103-
"""
83+
withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') {
84+
try {
85+
// unit tests
86+
sh """docker run --rm \\
87+
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
88+
${testImage} \\
89+
py.test -v -rxs --cov=docker tests/unit
90+
"""
91+
// integration tests
92+
sh """docker network create ${testNetwork}"""
93+
sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
94+
${imageDindSSH} dockerd -H tcp://0.0.0.0:2375
95+
"""
96+
sh """docker run --rm \\
97+
--name ${testContainerName} \\
98+
-e "DOCKER_HOST=tcp://${dindContainerName}:2375" \\
99+
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
100+
--network ${testNetwork} \\
101+
--volumes-from ${dindContainerName} \\
102+
-v $DOCKER_CONFIG/config.json:/root/.docker/config.json \\
103+
${testImage} \\
104+
py.test -v -rxs --cov=docker tests/integration
105+
"""
106+
sh """docker stop ${dindContainerName}"""
107+
// start DIND container with SSH
108+
sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
109+
${imageDindSSH} dockerd --experimental"""
110+
sh """docker exec ${dindContainerName} sh -c /usr/sbin/sshd """
111+
// run SSH tests only
112+
sh """docker run --rm \\
113+
--name ${testContainerName} \\
114+
-e "DOCKER_HOST=ssh://${dindContainerName}:22" \\
115+
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
116+
--network ${testNetwork} \\
117+
--volumes-from ${dindContainerName} \\
118+
-v $DOCKER_CONFIG/config.json:/root/.docker/config.json \\
119+
${testImage} \\
120+
py.test -v -rxs --cov=docker tests/ssh
121+
"""
122+
} finally {
123+
sh """
124+
docker stop ${dindContainerName}
125+
docker network rm ${testNetwork}
126+
"""
127+
}
104128
}
105129
}
106130
}

MAINTAINERS

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
[Org]
1212
[Org."Core maintainers"]
1313
people = [
14-
"shin-",
14+
"aiordache",
15+
"ulyssessouza",
1516
]
1617
[Org.Alumni]
1718
people = [
@@ -20,6 +21,7 @@
2021
"dnephin",
2122
"mnowster",
2223
"mpetazzoni",
24+
"shin-",
2325
]
2426

2527
[people]
@@ -35,6 +37,11 @@
3537
3638
GitHub = "aanand"
3739

40+
[people.aiordache]
41+
Name = "Anca Iordache"
42+
43+
GitHub = "aiordache"
44+
3845
[people.bfirsh]
3946
Name = "Ben Firshman"
4047
@@ -59,3 +66,8 @@
5966
Name = "Joffrey F"
6067
6168
GitHub = "shin-"
69+
70+
[people.ulyssessouza]
71+
Name = "Ulysses Domiciano Souza"
72+
73+
GitHub = "ulyssessouza"

0 commit comments

Comments
 (0)