Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit e2b7699

Browse files
authored
* Vendor in swagger-codegen-generated code instead * Ensure testcase doesn't fail on client validation * Bump deps + switch to valitydev upstreams * valitydev/scoper@7f3183d * valitydev/woody_erlang@3ddacb9 * valitydev/cowboy_access_log@04da359 * valitydev/bouncer-proto@633ba73 * valitydev/bouncer_client_erlang@535449a * valitydev/genlib@82c5ff3 * valitydev/party-shop-proto@72faaf6 * valitydev/analytics-proto@f691834 * Add CI/CD @ GH Actions * Cleanup sys.config * Bump to valitydev/damsel@318a7a6
1 parent 69b2c2b commit e2b7699

Some content is hidden

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

59 files changed

+19125
-308
lines changed

.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# NOTE
2+
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs
3+
# are the same. See: https://github.com/erlware/relx/pull/902
4+
SERVICE_NAME=anapi
5+
OTP_VERSION=24.2.0
6+
REBAR_VERSION=3.18
7+
THRIFT_VERSION=0.14.2.2

.github/workflows/build-image.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'epic/**'
8+
pull_request:
9+
branches: ['**']
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
21+
- name: Setup Buildx
22+
uses: docker/setup-buildx-action@v1
23+
24+
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
25+
- name: Update environment variables
26+
run: grep -v '^#' .env >> $GITHUB_ENV
27+
28+
- name: Log in to the Container registry
29+
uses: docker/login-action@v1.12.0
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Construct tags / labels for an image
36+
id: meta
37+
uses: docker/metadata-action@v3.6.2
38+
with:
39+
images: |
40+
${{ env.REGISTRY }}/${{ github.repository }}
41+
tags: |
42+
type=sha
43+
44+
- name: Build and push Docker image
45+
uses: docker/build-push-action@v2.9.0
46+
with:
47+
push: ${{ github.event_name == 'push' }}
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
build-args: |
51+
SERVICE_NAME=${{ env.SERVICE_NAME }}
52+
OTP_VERSION=${{ env.OTP_VERSION }}
53+
THRIFT_VERSION=${{ env.THRIFT_VERSION }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Erlang CI Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'epic/**'
8+
pull_request:
9+
branches: ['**']
10+
11+
jobs:
12+
setup:
13+
name: Load .env
14+
runs-on: ubuntu-latest
15+
outputs:
16+
otp-version: ${{ steps.otp-version.outputs.version }}
17+
rebar-version: ${{ steps.rebar-version.outputs.version }}
18+
thrift-version: ${{ steps.thrift-version.outputs.version }}
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
- run: grep -v '^#' .env >> $GITHUB_ENV
23+
- id: otp-version
24+
run: echo "::set-output name=version::$OTP_VERSION"
25+
- id: rebar-version
26+
run: echo "::set-output name=version::$REBAR_VERSION"
27+
- id: thrift-version
28+
run: echo "::set-output name=version::$THRIFT_VERSION"
29+
30+
run:
31+
name: Run checks
32+
needs: setup
33+
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.1
34+
with:
35+
otp-version: ${{ needs.setup.outputs.otp-version }}
36+
rebar-version: ${{ needs.setup.outputs.rebar-version }}
37+
use-thrift: true
38+
thrift-version: ${{ needs.setup.outputs.thrift-version }}

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ erl_crash.dump
1212
/_checkouts/
1313

1414
# generated
15-
apps/swag_server/*
16-
apps/swag_client/*
1715
*.beam
1816

1917
# containerization
2018
\#*
2119
.\#*
22-
Dockerfile
23-
docker-compose.yml
2420

2521
tags
22+
Makefile.env

.gitmodules

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

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ARG OTP_VERSION
2+
3+
# Build the release
4+
FROM docker.io/library/erlang:${OTP_VERSION} AS builder
5+
6+
# Install thrift compiler
7+
ARG THRIFT_VERSION
8+
9+
ARG TARGETARCH
10+
RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${TARGETARCH}.tar.gz" \
11+
| tar -xvz -C /usr/local/bin/
12+
13+
# Copy sources
14+
RUN mkdir /build
15+
COPY . /build/
16+
17+
# Build the release
18+
WORKDIR /build
19+
RUN rebar3 compile
20+
RUN rebar3 as prod release
21+
22+
# Make a runner image
23+
FROM docker.io/library/erlang:${OTP_VERSION}-slim
24+
25+
ARG SERVICE_NAME
26+
27+
# Set env
28+
ENV CHARSET=UTF-8
29+
ENV LANG=C.UTF-8
30+
31+
# Expose SERVICE_NAME as env so CMD expands properly on start
32+
ENV SERVICE_NAME=${SERVICE_NAME}
33+
34+
# Set runtime
35+
WORKDIR /opt/${SERVICE_NAME}
36+
37+
COPY --from=builder /build/_build/prod/rel/${SERVICE_NAME} /opt/${SERVICE_NAME}
38+
39+
ENTRYPOINT []
40+
CMD /opt/${SERVICE_NAME}/bin/${SERVICE_NAME} foreground
41+
42+
EXPOSE 8022

Dockerfile.dev

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ARG OTP_VERSION
2+
3+
FROM docker.io/library/erlang:${OTP_VERSION}
4+
5+
# Install thrift compiler
6+
ARG THRIFT_VERSION
7+
8+
ARG TARGETARCH
9+
RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${TARGETARCH}.tar.gz" \
10+
| tar -xvz -C /usr/local/bin/
11+
12+
# Set env
13+
ENV CHARSET=UTF-8
14+
ENV LANG=C.UTF-8
15+
16+
# Set runtime
17+
CMD /bin/bash

Makefile

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# HINT
2+
# Use this file to override variables here.
3+
# For example, to run with podman put `DOCKER=podman` there.
4+
-include Makefile.env
5+
6+
# NOTE
7+
# Variables specified in `.env` file are used to pick and setup specific
8+
# component versions, both when building a development image and when running
9+
# CI workflows on GH Actions. This ensures that tasks run with `wc-` prefix
10+
# (like `wc-dialyze`) are reproducible between local machine and CI runners.
11+
DOTENV := $(shell grep -v '^\#' .env)
12+
13+
# Development images
14+
DEV_IMAGE_TAG = anapi-dev
15+
DEV_IMAGE_ID = $(file < .image.dev)
16+
17+
DOCKER ?= docker
18+
REBAR ?= rebar3
19+
20+
all: compile
21+
22+
.PHONY: dev-image clean-dev-image wc-shell test
23+
24+
dev-image: .image.dev
25+
26+
.image.dev: Dockerfile.dev .env
27+
$(DOCKER) build $(DOTENV:%=--build-arg %) -f Dockerfile.dev -t $(DEV_IMAGE_TAG)
28+
$(DOCKER) image ls -q -f "reference=$(DEV_IMAGE_TAG)" | head -n1 > $@
29+
30+
clean-dev-image:
31+
ifneq ($(DEV_IMAGE_ID),)
32+
$(DOCKER) image rm -f $(DEV_IMAGE_TAG)
33+
rm .image.dev
34+
endif
35+
36+
DOCKER_WC_OPTIONS := -v $(PWD):$(PWD) --workdir $(PWD)
37+
DOCKER_WC_EXTRA_OPTIONS ?= --rm
38+
DOCKER_RUN = $(DOCKER) run -t $(DOCKER_WC_OPTIONS) $(DOCKER_WC_EXTRA_OPTIONS)
39+
40+
# Utility tasks
41+
42+
wc-shell: dev-image
43+
$(DOCKER_RUN) --interactive --tty $(DEV_IMAGE_TAG)
44+
45+
wc-%: dev-image
46+
$(DOCKER_RUN) $(DEV_IMAGE_TAG) make $*
47+
48+
# Rebar tasks
49+
50+
rebar-shell:
51+
$(REBAR) shell
52+
53+
compile:
54+
$(REBAR) compile
55+
56+
xref:
57+
$(REBAR) xref
58+
59+
lint:
60+
$(REBAR) lint
61+
62+
check-format:
63+
$(REBAR) fmt -c
64+
65+
dialyze:
66+
$(REBAR) as test dialyzer
67+
68+
release:
69+
$(REBAR) as prod release
70+
71+
eunit:
72+
$(REBAR) eunit --cover
73+
74+
common-test:
75+
$(REBAR) ct --cover
76+
77+
cover:
78+
$(REBAR) covertool generate
79+
80+
format:
81+
$(REBAR) fmt -w
82+
83+
clean:
84+
$(REBAR) clean
85+
86+
distclean: clean-build-image
87+
rm -rf _build
88+
89+
test: eunit common-test
90+
91+
cover-report:
92+
$(REBAR) cover

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# anapi - ЛК API
1+
# anapi-v1
2+
3+
> DERPECATED in favor of https://github.com/valitydev/anapi-v2.
4+
5+
ЛК API

apps/anapi/src/anapi.app.src

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
%%% limitations under the License.
1515
%%%
1616

17-
{application, anapi , [
17+
{application, anapi, [
1818
{description, "A service that does analytical api"},
1919
{vsn, "0.1.0"},
2020
{registered, []},
21-
{mod, {anapi , []}},
21+
{mod, {anapi, []}},
2222
{applications, [
2323
kernel,
2424
stdlib,
@@ -38,7 +38,6 @@
3838
snowflake,
3939
woody_user_identity,
4040
payproc_errors,
41-
how_are_you,
4241
erl_health,
4342
scoper,
4443
uac,

0 commit comments

Comments
 (0)