Skip to content

Instantly share code, notes, and snippets.

View excavador's full-sized avatar

Oleg Tsarev excavador

View GitHub Profile
load("@io_bazel_rules_docker//container:container.bzl", "repositories", "container_pull", "container_image")
DEFAULT_VERSION = "1.1.54292"
def _pull_name(kind, version):
return "external_clickhouse_{}_{}".format(kind, version)
def _pull_label(kind, version):
return "@{}//image".format(_pull_name(kind, version))
def _clickhouse_export_impl(ctx):
print(ctx.file.server, dir(ctx.attr.server), type(ctx.attr.server))
server_source = ctx.attr.server.files.to_list()[0]
client_source = ctx.attr.client.files.to_list()[0]
server_result = ctx.outputs.server
client_result = ctx.outputs.client
...
_clickhouse_export = rule(
implementation = _clickhouse_export_impl,
COMMAND = """#!/bin/bash
set -x
ls -al
docker load --input {server_source} | awk '{{print $3}}' > {server_result}
docker load --input {client_source} | awk '{{print $3}}' > {client_result}
"""
def _clickhouse_export_impl(ctx):
server_source = ctx.attr.server.files.to_list()[0]
client_source = ctx.attr.client.files.to_list()[0]
import os
import sys
import queue
import threading
import re
import requests
import logging
import colorlog
import hashlib
load("//bzl:fmt.bzl", "fmt")
fmt(name="fmt")
@excavador
excavador / dummy constants columns for FOREIGN KEY
Last active August 11, 2017 18:57
Annoying PostgreSQL limitations
TODO
[jenkins@ci-slave-1:Ireland oleg]$ grep -A 1 -B 1 error_log /home/jenkins/backend-ci/bin/nginx.conf
pid /home/jenkins/backend-ci/bin/nginx.pid;
error_log /dev/stderr error;
--
access_log /dev/stderr combined_plus;
error_log /dev/stderr error;
[jenkins@ci-slave-1:Ireland oleg]$ /sbin/nginx -c /home/jenkins/backend-ci/bin/nginx.conf
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
$(FMT).state: bin/xargs-if-changed
rm -f $@
touch $@
$(FMT): bin/xargs-if-changed bin/gofmt $(FMT).state $(SIGN__GO__SOURCE) $(SIGN__GO__TEST) $(SIGN__GO__GENERATED)
$(info [fmt])
make/02.files-go-source.sh | XARGS_STATE=$(FMT).state XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/gofmt -l -s -w
make/02.files-go-test.sh | XARGS_STATE=$(FMT).state XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/gofmt -l -s -w
touch $@
fmt: $(FMT)
$(VET).state:
@touch $@
$(VET): bin/xargs-if-changed bin/vet $(VET).state $(SIGN__GO__SOURCE) $(SIGN__GO__TEST) $(SIGN__GO__GENERATED)
$(info [vet])
@(make/02.files-go-source.sh; make/02.files-go-test.sh) | XARGS_STATE=$(VET).state XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/vet
@touch $@
vet: $(VET)
➜ make/02.files-go-source.sh | XARGS_STATE=bin/make/fmt XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/gofmt -l -s -w
/Users/oleg/pp/backend/src/cmd/make/xargs-if-changed/main.go
➜ bin/xargs-if-changed --help
Usage: xargs-if-changed <tool with arguments>
tool
1. reads file paths from stdin
2. reads content of every file and calculate MD5
3. checks MD5 for this file in <XARGS_STATE>
4. if file was changed executes "<tool with arguments> <file path>"
5. if execution was successfull writes actual MD5 for <file path> to <XARGS_STATE>