Skip to content

Commit

Permalink
Merge commit 'e56014a254466050b28ec3a181062a74d76c02fd' into update-b…
Browse files Browse the repository at this point in the history
…uild-tools
  • Loading branch information
Daniel Holbach committed Jun 9, 2020
2 parents bf90d56 + e56014a commit 70fd52c
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 34 deletions.
10 changes: 5 additions & 5 deletions tools/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
steps:
- checkout
- run: cd build; make
- run: docker run --rm -v "$PWD:$PWD" -w "$PWD" --entrypoint sh weaveworks/build-golang -c ./lint .
- run: docker run --rm -v "$PWD:$PWD" -w "$PWD" --entrypoint sh weaveworks/build-golang -c ./shell-lint .
- run: docker run --rm -v "$PWD/cover:/go/src/cover" -w "/go/src/cover" --entrypoint sh weaveworks/build-golang -c make
- run: docker run --rm -v "$PWD/socks:/go/src/socks" -w "/go/src/socks" --entrypoint sh weaveworks/build-golang -c "make proxy"
- run: docker run --rm -v "$PWD/runner:/go/src/runner" -w "/go/src/runner" --entrypoint sh weaveworks/build-golang -c make
- run: docker run --rm -v "$PWD:$PWD" -w "$PWD" --entrypoint sh weaveworks/build-golang -c "./shell-lint ."
- run: docker run --rm -v "$PWD:/go/src" -w "/go/src/cover" --entrypoint sh weaveworks/build-golang -c make
- run: docker run --rm -v "$PWD:/go/src" -w "/go/src/socks" --entrypoint sh weaveworks/build-golang -c "make proxy"
- run: docker run --rm -v "$PWD:/go/src" -w "/go/src/runner" --entrypoint sh weaveworks/build-golang -c make
- run: docker run --rm -v "$PWD:/go/src" -w "/go/src" --entrypoint sh weaveworks/build-golang -c "./lint ./build ./config_management ./cover ./dependencies ./integration ./provisioning ./runner ./scheduler ./socks"

- deploy:
command: |
Expand Down
11 changes: 7 additions & 4 deletions tools/build/golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.13.1-stretch
FROM golang:1.13.5-stretch
RUN apt-get update && \
apt-get install -y \
curl \
Expand All @@ -8,13 +8,16 @@ RUN apt-get update && \
libprotobuf-dev \
make \
protobuf-compiler \
python-pip \
python3 \
python3-pip \
python-requests \
python-yaml \
libssl-dev \
python-openssl \
shellcheck \
unzip && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN pip install attrs pyhcl yapf==0.16.2 flake8==3.3.0
RUN pip3 install attrs==19.2.0 pyhcl yapf==0.16.2 flake8==3.3.0
RUN curl -fsSLo shfmt https://github.com/mvdan/sh/releases/download/v1.3.0/shfmt_v1.3.0_linux_amd64 && \
echo "b1925c2c405458811f0c227266402cf1868b4de529f114722c2e3a5af4ac7bb2 shfmt" | sha256sum -c && \
chmod +x shfmt && \
Expand All @@ -34,7 +37,7 @@ RUN go get -tags netgo \
github.com/golang/protobuf/protoc-gen-go \
github.com/kisielk/errcheck \
github.com/mjibson/esc \
github.com/prometheus/prometheus/cmd/promtool && \
&& \
rm -rf /go/pkg /go/src
RUN mkdir protoc && \
cd protoc && \
Expand Down
5 changes: 3 additions & 2 deletions tools/dependencies/cross_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ def cross_versions(config):
def main(argv):
try:
config = _validate_input(argv)
print(linesep.join('\t'.join(triple)
for triple in cross_versions(config)))
print(
linesep.join('\t'.join(triple)
for triple in cross_versions(config)))
except Exception as e:
print(str(e))
exit(_ERROR_RUNTIME)
Expand Down
23 changes: 15 additions & 8 deletions tools/lint
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,16 @@ matches_any() {
return 1
}

filter_out() {
read_patterns() {
local patterns_file="$1"
if [ -n "$patterns_file" ] && [ -r "$patterns_file" ]; then
local patterns
patterns=$(sed '/^#.*$/d ; /^\s*$/d' "$patterns_file") # Remove blank lines and comments before we start iterating.
[ -n "$DEBUG" ] && echo >&2 "> Filters:" && echo >&2 "$patterns"
sed '/^#.*$/d ; /^\s*$/d' "$patterns_file" # Remove blank lines and comments.
fi
}

filter_out() {
local patterns="$1"
if [ -n "$patterns" ]; then
local filtered_out=()
while read -r filename; do
matches_any "$filename" "$patterns" && filtered_out+=("$filename") || echo "$filename"
Expand All @@ -238,11 +242,13 @@ filter_out() {
lint_directory() {
local dirname="$1"
local lint_result=0
matches_any "$dirname" "$PATTERNS" && return 0
[ -n "$DEBUG" ] && echo >&2 "> Linting directory: $dirname"
# This test is just checking if there are any Go files in the directory
if compgen -G "$dirname/*.go" >/dev/null; then
lint_go "${dirname}" || lint_result=1
fi
find . -maxdepth 1 "$dirname" | filter_out "$LINT_IGNORE_FILE" | lint_files
find "$dirname" -maxdepth 1 | filter_out "$PATTERNS" | lint_files || lint_result=1
return $lint_result
}

Expand All @@ -255,11 +261,12 @@ lint_directories() {
}

list_directories() {
if [ $# -gt 0 ]; then
find "$@" \( -name vendor -o -name .git -o -name .cache -o -name .pkg \) -prune -o -type d
fi
find "$@" \( -name vendor -o -name .git -o -name .cache -o -name .pkg \) -prune -o -type d
}

PATTERNS=$(read_patterns "$LINT_IGNORE_FILE")
[ -n "$DEBUG" ] && echo >&2 "> Filters:" && echo >&2 "$PATTERNS"

if [ $# = 1 ] && [ -f "$1" ]; then
lint "$1"
else
Expand Down
6 changes: 4 additions & 2 deletions tools/provisioning/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ resource "google_compute_instance" "tf_test_vm" {
zone = "${var.gcp_zone}"
count = "${var.num_hosts}"

disk {
image = "${var.gcp_image}"
boot_disk {
initialize_params {
image = "${var.gcp_image}"
}
}

tags = [
Expand Down
12 changes: 6 additions & 6 deletions tools/provisioning/gcp/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ output "username" {
}

output "public_ips" {
value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip}"]
value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.nat_ip}"]
}

output "private_ips" {
value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.address}"]
value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.network_ip}"]
}

output "hostnames" {
Expand All @@ -24,7 +24,7 @@ output "hostnames" {
output "private_etc_hosts" {
value = "${join("\n",
"${formatlist("%v %v.%v.%v",
google_compute_instance.tf_test_vm.*.network_interface.0.address,
google_compute_instance.tf_test_vm.*.network_interface.0.network_ip,
google_compute_instance.tf_test_vm.*.name,
google_compute_instance.tf_test_vm.*.zone,
var.app
Expand All @@ -36,7 +36,7 @@ output "private_etc_hosts" {
output "public_etc_hosts" {
value = "${join("\n",
"${formatlist("%v %v.%v.%v",
google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip,
google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.nat_ip,
google_compute_instance.tf_test_vm.*.name,
google_compute_instance.tf_test_vm.*.zone,
var.app
Expand All @@ -47,8 +47,8 @@ output "public_etc_hosts" {
output "ansible_inventory" {
value = "${format("[all]\n%s", join("\n",
"${formatlist("%v private_ip=%v",
google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip,
google_compute_instance.tf_test_vm.*.network_interface.0.address
google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.nat_ip,
google_compute_instance.tf_test_vm.*.network_interface.0.network_ip
)}"
))}"
}
Expand Down
10 changes: 3 additions & 7 deletions tools/scheduler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ def avg(test):
test_times_dict = dict(test_times)
test_times.sort(key=operator.itemgetter(1))

shards = {i: [] for i in xrange(shard_count)}
shards = {i: [] for i in range(shard_count)}
while test_times:
test_name, time = test_times.pop()

# find shortest shard and put it in that
s, _ = min(
((i, sum(test_times_dict[t] for t in shards[i]))
for i in xrange(shard_count)),
for i in range(shard_count)),
key=operator.itemgetter(1))

shards[s].append(test_name)
Expand Down Expand Up @@ -123,9 +123,6 @@ def _matches_any_regex(name, regexes):
return matches


# See also: https://circleci.com/account/api
CIRCLE_CI_API_TOKEN = 'cffb83afd920cfa109cbd3e9eecb7511a2d18bb9'

# N.B.: When adding a project below, please ensure:
# - its CircleCI project is either public, or is followed by the user attached
# to the above API token
Expand All @@ -137,8 +134,7 @@ def _matches_any_regex(name, regexes):
('weaveworks/weave', 'positive-cocoa-90213', 'us-central1-a', True, None),
('weaveworks/scope', 'scope-integration-tests', 'us-central1-a', False,
None),
('weaveworks/wks', 'wks-tests', 'us-central1-a', True,
CIRCLE_CI_API_TOKEN),
('weaveworks/wksctl', 'wks-tests', 'us-central1-a', True, None),
]


Expand Down
1 change: 1 addition & 0 deletions tools/scheduler/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
flask==1.0.0
google-api-python-client==1.6.7
werkzeug<1.0

0 comments on commit 70fd52c

Please sign in to comment.