Skip to content

Commit 79844e8

Browse files
committed
Merge remote-tracking branch 'origin/master' into BNP_update_suexec
2 parents f1be94b + e251756 commit 79844e8

File tree

130 files changed

+8036
-200
lines changed

Some content is hidden

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

130 files changed

+8036
-200
lines changed

.circleci/config.yml

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
1+
---
12
version: 2.1
23

4+
master_filter: &master_filter
5+
filters:
6+
tags:
7+
ignore: /.*/
8+
branches:
9+
only:
10+
- master
11+
12+
ubuntu_machine: &ubuntu_machine
13+
machine:
14+
image: ubuntu-2004:202111-02
15+
docker_layer_caching: true
16+
317
workflows:
418
version: 2
519
ci:
620
jobs:
721
- build
8-
- test-influxdb
22+
- test-influxdb:
23+
matrix:
24+
parameters:
25+
version: ["2.0", "2.1", "2.2", "2.3"]
26+
- publish_docker_images:
27+
<<: *master_filter
28+
- test-influxdb-binaries:
29+
matrix:
30+
parameters:
31+
product:
32+
- "influxdb/1.9/data"
33+
- "influxdb/1.9/meta"
34+
- "influxdb/1.10/data"
35+
- "influxdb/1.10/meta"
936

1037
jobs:
1138
build:
@@ -17,11 +44,58 @@ jobs:
1744
- run: bash circle-test.sh
1845

1946
test-influxdb:
20-
machine: true
47+
<<: *ubuntu_machine
48+
parameters:
49+
version:
50+
type: string
51+
enum: ["2.0", "2.1", "2.2", "2.3"]
2152
steps:
2253
- checkout
23-
- run: sudo apt-get update && sudo apt-get install -y jq
24-
- run: bash influxdb/test/test-2x-e2e.sh
54+
- run: |
55+
sudo apt-get update &&
56+
sudo apt-get install -y jq
57+
- run: bash influxdb/test/test-2x-e2e.sh << parameters.version >>
2558
- store_artifacts:
2659
path: influxdb/test/logs
2760
destination: container-logs
61+
62+
publish_docker_images:
63+
docker:
64+
- image: 'cimg/python:3.6'
65+
steps:
66+
- checkout
67+
- run:
68+
name: Install Prerequisite Packages
69+
command: |
70+
sudo bash -s \<<EOF
71+
#!/bin/bash
72+
set -o errexit \
73+
-o nounset \
74+
-o pipefail
75+
76+
export DEBIAN_FRONTEND=noninteractive
77+
apt-get update
78+
apt-get install --yes git
79+
EOF
80+
81+
python3 -m pip install -r \
82+
.circleci/scripts/update_manifest_file/requirements.txt
83+
- run:
84+
name: Get Enterprise Information
85+
command: |
86+
python3 .circleci/scripts/get_enterprise_info
87+
- run:
88+
name: Do Enterprise Release
89+
command: |
90+
.circleci/scripts/do-enterprise-release
91+
92+
test-influxdb-binaries:
93+
<<: *ubuntu_machine
94+
parameters:
95+
product:
96+
type: string
97+
steps:
98+
- checkout
99+
- run:
100+
name: Validate Docker Image Binaries
101+
command: influxdb/test/test-binaries << parameters.product >>

.circleci/scripts/create-draft-pr

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
set -o errexit \
3+
-o nounset \
4+
-o pipefail
5+
6+
# ${1} -> ENDPOINT
7+
# ${2} -> HEAD
8+
# ${3} -> TITLE
9+
10+
read -d '' -r DATA <<EOF || true
11+
{
12+
"title": "${3}",
13+
"head": "${2}",
14+
"base": "master",
15+
"draft": true
16+
}
17+
EOF
18+
19+
curl \
20+
-X POST \
21+
-H "Accept: application/vnd.github.v3+json" \
22+
-H "Authorization: Bearer ${GITHUB_MACHINE_TOKEN}" \
23+
"${1}" -d "${DATA}"
24+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
set -o errexit \
3+
-o nounset \
4+
-o pipefail
5+
6+
if [[ ${PRODUCT:-} != 'influxdb' ]] || \
7+
[[ ${VERSION_MAJOR:-} != '1' ]] || \
8+
[[ ${VERSION_MINOR:-} != '9' ]]
9+
then
10+
printf 'Release is not Enterprise skipping...\n'; exit 0
11+
fi
12+
13+
git clone [email protected]:/docker-library/official-images
14+
15+
python3 .circleci/scripts/update_manifest_file official-images/library/influxdb
16+
17+
pushd official-images
18+
19+
# CircleCI preloads the ssh-agent with the secret key required to clone
20+
# the repository. Unfortunately, this secret key does not have the
21+
# required permissions to `push`. This flushes the ssh-agent of
22+
# keys so that the `${SSH_MACHINE_SECKEY}` is always used.
23+
ssh-add -D && base64 -d <<<"${SSH_MACHINE_SECKEY}" | ssh-add -
24+
25+
git config user.name "${GITHUB_MACHINE_NAME}"
26+
git config user.email "${GITHUB_MACHINE_EMAIL}"
27+
28+
# We always branch from 'origin/master' to use the most up-to-date
29+
# source and avoid merge conflicts.
30+
git checkout -b "CI_release_${VERSION}" "origin/master"
31+
32+
git add . && git commit -m "feat: release Enterprise ${VERSION}"
33+
34+
# If this workflow is executed multiple times, it's possible that a branch
35+
# named `CI_release_${VERSION}` already exists. If this is the
36+
# case, we overwrite it with our commits.
37+
git remote add influxdata [email protected]:/influxdata/official-images
38+
git push -f --set-upstream influxdata "CI_release_${VERSION}"
39+
40+
popd
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/usr/bin/python3
2+
from typing import Dict
3+
from typing import Generator
4+
from typing import Optional
5+
import os
6+
import re
7+
import subprocess
8+
import enum
9+
10+
11+
def getenv(variable: str) -> str:
12+
"""
13+
Retrieves `variable` from the environment.
14+
"""
15+
# `os.getenv` returns `Dict[str]` which is incompatible with functions
16+
# that require `str` parameters. If `os.getenv` returns a value, it is
17+
# unwrapped and returned to the caller.
18+
value = os.getenv(variable)
19+
if value is not None:
20+
return value
21+
22+
raise RuntimeError('Missing environment variable "{}".'.format(variable))
23+
24+
25+
class GitDiff(enum.Enum):
26+
# fmt: off
27+
ADDED = "\+"
28+
REMOVED = "\-"
29+
# fmt: on
30+
31+
def __str__(self):
32+
return str(self.value)
33+
34+
35+
def parse_env_line(line: str, diff: GitDiff) -> Optional[Dict[str, str]]:
36+
"""
37+
Matches version line in dockerfile.
38+
"""
39+
# fmt: off
40+
matches = re.match(
41+
r"^" + str(diff) + # changed?
42+
r"ENV\s+INFLUXDB_VERSION\s+" + # prelude
43+
r"((\d+)" + # major cg: 2
44+
r"(?:\.(\d+))?" + # minor? cg: 3
45+
r"(?:\.(\d+))?" + # patch? cg: 4
46+
r"(?:\-?(rc\d+))?)" + # rc? cg: 5
47+
r"-c" + # interlude
48+
r"(\d+)" + # repeat major cg: 6
49+
r"(?:\.(\d+))?" + # repeat minor? cg: 7
50+
r"(?:\.(\d+))?" + # repeat patch? cg: 8
51+
r"(?:\-?(rc\d+))?", # repeat rc? cg: 9
52+
line)
53+
54+
if matches is not None:
55+
# I tried using capture-group back-references within the regular
56+
# expression. However, it couldn't handle optional capture-
57+
# groups. So, instead, we check for equality here.
58+
if (matches.group(2) == matches.group(6) and
59+
matches.group(3) == matches.group(7) and
60+
matches.group(4) == matches.group(8) and
61+
matches.group(5) == matches.group(9)):
62+
return {
63+
"VERSION": matches.group(1),
64+
"VERSION_MAJOR": matches.group(2),
65+
"VERSION_MINOR": matches.group(3) if matches.group(3) else "",
66+
"VERSION_PATCH": matches.group(4) if matches.group(4) else "",
67+
"VERSION_RC": matches.group(5) if matches.group(5) else "",
68+
}
69+
return None
70+
# fmt: on
71+
72+
73+
def parse_version() -> Optional[str]:
74+
"""
75+
Parse version from "ENV" line in git.
76+
"""
77+
# Retrieve all lines that have changed since the commit between
78+
# HEAD~1 and HEAD. This is more robust than just parsing the
79+
# current Dockerfile as it ensures that `INFLUXDB_VERSION`
80+
# actually changed.
81+
# fmt: off
82+
process = subprocess.run(
83+
["git", "diff", "--unified=0", "HEAD~1..HEAD", "influxdb" ],
84+
stdout=subprocess.PIPE,
85+
stderr=subprocess.PIPE,
86+
)
87+
# fmt: on
88+
89+
version_prev = None
90+
version_curr = None
91+
for line in process.stdout.decode("utf-8").split("\n"):
92+
line = line.rstrip(" \t")
93+
prev = parse_env_line(line, GitDiff.REMOVED)
94+
curr = parse_env_line(line, GitDiff.ADDED)
95+
96+
if prev is not None:
97+
version_prev = prev
98+
if curr is not None:
99+
version_curr = curr
100+
101+
# fmt: off
102+
if (version_prev is not None and
103+
version_curr is not None):
104+
# if the versions differ, then this must be a release
105+
if version_prev["VERSION"] != version_curr["VERSION"]:
106+
return version_curr
107+
# fmt: on
108+
109+
# If the `INFLUXDB_VERSION` line has changed but the version has
110+
# not changed, reset so the next encounter of `version_prev`
111+
# does not cause this to return the incorrect `version_curr`.
112+
if version_curr != None:
113+
version_prev = None
114+
version_curr = None
115+
116+
# no version change in dockerfile
117+
return None
118+
119+
120+
version = parse_version()
121+
if version is not None:
122+
with open(getenv("BASH_ENV"), "a") as stream:
123+
stream.write("export PRODUCT=influxdb\n")
124+
for key, value in version.items():
125+
stream.write("export {}={}\n".format(key, value))

0 commit comments

Comments
 (0)