-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TD-6: Add Makefile for most development tasks (#3)
* TD-6: Add new CI * Use wc-* and wdeps-test * Remove set up of thrift and BEAM in CI * Check TARGETARCH content * Change to compose v1 * Try to check arch again * Add default ARCH and move back to compose v2 * Replace TARGETARCH with BUILDARCH * Enable Buildkit * Add rebar3_lint plugin * Diagnose lint * Change CI order * Make wdeps-* work * Revert some elvis.config changes * Fix lint * Parallelize CI * Change artifact name * Move plt cache to dialyzer job * Fix test * Review fixes * Use --use-aliases alternative * Remove echo arch from Dockerfile
- Loading branch information
Showing
11 changed files
with
160 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
/.github/ | ||
/.vscode/ | ||
/.idea/ | ||
erl_crash.dump | ||
rebar3.crashdump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# NOTE | ||
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs | ||
# are the same. See: https://github.com/erlware/relx/pull/902 | ||
ERLANG_VERSION=24.2.0 | ||
THRIFT_VERSION=0.14.2.1 | ||
|
||
DOCKER_BUILDKIT=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ARG ERLANG_VERSION | ||
|
||
FROM docker.io/library/erlang:${ERLANG_VERSION} | ||
|
||
ARG THRIFT_VERSION | ||
ARG BUILDARCH | ||
|
||
RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${BUILDARCH}.tar.gz" \ | ||
| tar -xvz -C /usr/local/bin/ | ||
|
||
ENV CHARSET=UTF-8 | ||
ENV LANG=C.UTF-8 | ||
CMD /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# HINT | ||
# Use this file to override variables here. | ||
# For example, to run with podman put `DOCKER=podman` there. | ||
-include Makefile.env | ||
|
||
SERVICE := dominant | ||
|
||
# NOTE | ||
# Variables specified in `.env` file are used to pick and setup specific | ||
# component versions, both when building a development image and when running | ||
# CI workflows on GH Actions. This ensures that tasks run with `wc-` prefix | ||
# (like `wc-dialyze`) are reproducible between local machine and CI runners. | ||
DOTENV := $(shell grep -v '^\#' .env) | ||
|
||
# Development images | ||
|
||
DEV_IMAGE_TAG = $(SERVICE)-dev | ||
DEV_IMAGE_ID = $(file < .image.dev) | ||
|
||
DOCKER ?= docker | ||
DOCKERCOMPOSE ?= docker compose | ||
DOCKERCOMPOSE_W_ENV = DEV_IMAGE_TAG=$(DEV_IMAGE_TAG) $(DOCKERCOMPOSE) | ||
REBAR ?= rebar3 | ||
|
||
all: compile | ||
|
||
.PHONY: dev-image clean-dev-image wc-shell test | ||
|
||
dev-image: .image.dev | ||
|
||
.image.dev: Dockerfile.dev .env | ||
env $(DOTENV) $(DOCKERCOMPOSE_W_ENV) build $(SERVICE) | ||
$(DOCKER) image ls -q -f "reference=$(DEV_IMAGE_ID)" | head -n1 > $@ | ||
|
||
clean-dev-image: | ||
ifneq ($(DEV_IMAGE_ID),) | ||
$(DOCKER) image rm -f $(DEV_IMAGE_TAG) | ||
rm .image.dev | ||
endif | ||
|
||
DOCKER_WC_OPTIONS := -v $(PWD):$(PWD) --workdir $(PWD) | ||
DOCKER_WC_EXTRA_OPTIONS ?= --rm | ||
DOCKER_RUN = $(DOCKER) run $(DOCKER_WC_OPTIONS) $(DOCKER_WC_EXTRA_OPTIONS) | ||
|
||
DOCKERCOMPOSE_RUN = $(DOCKERCOMPOSE_W_ENV) run --name $(SERVICE) --service-ports $(DOCKER_WC_OPTIONS) | ||
|
||
wc-shell: dev-image | ||
$(DOCKER_RUN) --interactive --tty $(DEV_IMAGE_TAG) | ||
|
||
wc-%: dev-image | ||
$(DOCKER_RUN) $(DEV_IMAGE_TAG) make $* | ||
|
||
wdeps-shell: dev-image | ||
$(DOCKERCOMPOSE_RUN) $(SERVICE) su; \ | ||
$(DOCKERCOMPOSE_W_ENV) down | ||
|
||
wdeps-%: dev-image | ||
$(DOCKERCOMPOSE_RUN) -T $(SERVICE) make $*; \ | ||
res=$$?; \ | ||
$(DOCKERCOMPOSE_W_ENV) down; \ | ||
exit $$res | ||
|
||
# Erlang-specific tasks | ||
|
||
compile: | ||
$(REBAR) compile | ||
|
||
xref: | ||
$(REBAR) xref | ||
|
||
lint: | ||
$(REBAR) lint | ||
|
||
check-format: | ||
$(REBAR) fmt -c | ||
|
||
format: | ||
$(REBAR) fmt -w | ||
|
||
dialyze: | ||
$(REBAR) as test dialyzer | ||
|
||
release: | ||
$(REBAR) as prod release | ||
|
||
clean: | ||
$(REBAR) clean | ||
|
||
distclean: | ||
rm -rf _build | ||
|
||
test: | ||
$(REBAR) do eunit, ct | ||
|
||
test.%: test/dmt_%_tests_SUITE.erl | ||
$(REBAR) ct --suite=$^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: '3' | ||
services: | ||
|
||
dominant: # Keep in sync with $(SERVICE) | ||
image: $DEV_IMAGE_TAG | ||
build: | ||
dockerfile: Dockerfile.dev | ||
context: . | ||
args: | ||
ERLANG_VERSION: $ERLANG_VERSION | ||
THRIFT_VERSION: $THRIFT_VERSION | ||
volumes: | ||
- .:$PWD | ||
working_dir: $PWD | ||
depends_on: | ||
- machinegun | ||
ports: | ||
- "8022" | ||
command: /sbin/init | ||
|
||
machinegun: | ||
image: docker.io/rbkmoney/machinegun:c05a8c18cd4f7966d70b6ad84cac9429cdfe37ae | ||
ports: | ||
- "8022" | ||
command: /opt/machinegun/bin/machinegun foreground | ||
volumes: | ||
- ./test/machinegun/config.yaml:/opt/machinegun/etc/config.yaml | ||
- ./test/machinegun/cookie:/opt/machinegun/etc/cookie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[ | ||
{elvis, [ | ||
{verbose, true}, | ||
{config, [ | ||
#{ | ||
dirs => ["src"], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters