Skip to content

Commit

Permalink
fix cd pipeline for code proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
tenmoves committed Mar 30, 2023
1 parent d750034 commit 9959068
Show file tree
Hide file tree
Showing 29 changed files with 341 additions and 273 deletions.
117 changes: 58 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,71 @@ name: Elixir CI

on:
push:
branches: [ master, develop, testnet ]
branches: [master, develop, testnet]
pull_request:
branches: [ master, develop, testnet ]
branches: [master, develop, testnet]

env:
MIX_ENV: test

jobs:
build:

name: Build and test
runs-on: ubuntu-20.04

steps:
- name: Install OS Packages
uses: mstksg/get-package@2a4b48d55d72d43ca89ae58ec9ca1397d34a1c35
with:
apt-get: libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev libsodium-dev autoconf-archive libcmocka0 libcmocka-dev procps iproute2 build-essential git pkg-config gcc libtool automake libssl-dev uthash-dev autoconf doxygen libjson-c-dev libini-config-dev libcurl4-openssl-dev libltdl-dev libtss2-dev tss2
- uses: actions/checkout@v2
- name: Set up Elixir
uses: erlef/setup-beam@988e02bfe678367a02564f65ca2e37726dc0268f
id: beam
with:
elixir-version: '1.14.1' # Define the elixir version [required]
otp-version: '25.1' # Define the OTP version [required]
- name: Restore dependencies cache
uses: actions/cache@v3
id: mix-cache
with:
path: deps
key: ${{ runner.os }}-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-mix-
- name: Make Clean
run: mix clean
- name: Install dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: mix deps.get
- name: Check dependency updates
run: mix hex.outdated --within-requirements 1>/dev/null || echo 'Updates available!'
- name: Set Formatting
run: mix format --check-formatted
- name: Restore build cache
uses: actions/cache@v3
with:
path: _build
key: ${{ runner.os }}-build-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-build-
- name: Compile the codebase
run: mix compile --warnings-as-errors
- name: Set credo
run: mix credo
- name: Run Sobelow
run: mix sobelow
- name: Run tests
run: mix test --trace
- name: Retrieve PLT Cache
uses: actions/cache@v3
id: plt-cache
with:
path: priv/plts
key: ${{ runner.os }}-plts-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-plts-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-
- name: Create PLTs
if: steps.plt-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix dialyzer --plt
- name: Run dialyzer
run: mix dialyzer --no-check --ignore-exit-status
- name: Install OS Packages
uses: mstksg/get-package@2a4b48d55d72d43ca89ae58ec9ca1397d34a1c35
with:
apt-get: libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev libsodium-dev autoconf-archive libcmocka0 libcmocka-dev procps iproute2 build-essential git pkg-config gcc libtool automake libssl-dev uthash-dev autoconf doxygen libjson-c-dev libini-config-dev libcurl4-openssl-dev libltdl-dev libtss2-dev tss2
- uses: actions/checkout@v2
- name: Set up Elixir
uses: erlef/setup-beam@988e02bfe678367a02564f65ca2e37726dc0268f
id: beam
with:
elixir-version: "1.14.1" # Define the elixir version [required]
otp-version: "25.1" # Define the OTP version [required]
- name: Restore dependencies cache
uses: actions/cache@v3
id: mix-cache
with:
path: deps
key: ${{ runner.os }}-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-mix-
- name: Make Clean
run: mix clean
- name: Install dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: mix deps.get
- name: Check dependency updates
run: mix hex.outdated --within-requirements 1>/dev/null || echo 'Updates available!'
- name: Set Formatting
run: mix format --check-formatted
- name: Restore build cache
uses: actions/cache@v3
with:
path: _build
key: ${{ runner.os }}-build-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-build-
- name: Compile the codebase
run: mix compile --warnings-as-errors
- name: Set credo
run: mix credo
- name: Run Sobelow
run: mix sobelow
- name: Run tests
run: mix test --trace
- name: Retrieve PLT Cache
uses: actions/cache@v3
id: plt-cache
with:
path: priv/plts
key: ${{ runner.os }}-plts-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-plts-elixir-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-
- name: Create PLTs
if: steps.plt-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix dialyzer --plt
- name: Run dialyzer
run: mix dialyzer --no-check --ignore-exit-status
21 changes: 6 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ ARG MIX_ENV=prod

RUN apk add --no-cache --update \
build-base \
grep \
bash \
gcc \
make \
g++ \
libexecinfo-dev \
libexecinfo \
git \
npm \
python3 \
wget \
openssl \
libsodium-dev \
libexecinfo-dev \
gmp-dev


# Install hex and rebar
RUN mix local.rebar --force \
&& mix local.hex --if-missing --force
Expand All @@ -60,23 +59,15 @@ RUN git config user.name aebot \
&& git config user.email aebot@archethic.net \
&& git remote add origin https://github.com/archethic-foundation/archethic-node

# Install Dart Sass
RUN npm install -g sass

# build Sass -> CSS
RUN cd assets && \
sass --no-source-map --style=compressed css/app.scss ../priv/static/css/app.css && cd -

# build release
RUN mix do assets.deploy, distillery.release

RUN mix assets.deploy
RUN MIX_ENV=prod mix distillery.release
# gen PLT
RUN if [ $with_tests -eq 1 ]; then mix git_hooks.run pre_push ;fi

# Install
RUN mkdir -p /opt/app \
&& cd /opt/app \
&& tar zxf /opt/code/_build/${MIX_ENV}/rel/archethic_node/releases/*/archethic_node.tar.gz
&& tar zxf /opt/code/_build/${MIX_ENV}/rel/archethic_node/releases/*/archethic_node.tar.gz -C /opt/app
CMD /opt/app/bin/archethic_node foreground

################################################################################
Expand All @@ -85,7 +76,7 @@ FROM archethic-ci as build

FROM elixir:1.14.1-alpine

RUN apk add --no-cache --update bash git openssl libsodium
RUN apk add --no-cache --update bash git openssl libsodium libexecinfo

COPY --from=build /opt/app /opt/app
COPY --from=build /opt/code/.git /opt/code/.git
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ifeq ($(TPM_INSTALLED),0)
$(CC) src/c/crypto/tpm/keygen.c src/c/crypto/tpm/lib.c -o priv/c_dist/tpm_keygen -I src/c/crypto/tpm/lib.h $(TPMFLAGS)
endif


clean:
rm -f priv/c_dist/*
mix archethic.clean_db
Expand Down
8 changes: 5 additions & 3 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ config :archethic, ArchethicWeb.Endpoint,
config :archethic, :throttle,
by_ip_high: [
period: 1000,
limit: 5_000
limit: System.get_env("ARCHETHIC_THROTTLE_IP_HIGH", "5000")
],
by_ip_low: [
period: 1000,
limit: 5_000
limit: System.get_env("ARCHETHIC_THROTTLE_IP_LOW", "5000")
],
by_ip_and_path: [
period: 1000,
limit: 5_000
limit: System.get_env("ARCHETHIC_THROTTLE_IP_AND_PATH", "5000")
]
6 changes: 3 additions & 3 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ config :archethic, ArchethicWeb.Endpoint,
config :archethic, :throttle,
by_ip_high: [
period: 1000,
limit: 500
limit: System.get_env("ARCHETHIC_THROTTLE_IP_HIGH", "500")
],
by_ip_low: [
period: 1000,
limit: 20
limit: System.get_env("ARCHETHIC_THROTTLE_IP_LOW", "20")
],
by_ip_and_path: [
period: 1000,
limit: 20
limit: System.get_env("ARCHETHIC_THROTTLE_IP_AND_PATH", "20")
]
6 changes: 3 additions & 3 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ config :archethic, ArchethicWeb.Endpoint,
config :archethic, :throttle,
by_ip_high: [
period: 1000,
limit: 5_000
limit: System.get_env("ARCHETHIC_THROTTLE_IP_HIGH", "5000")
],
by_ip_low: [
period: 1000,
limit: 5_000
limit: System.get_env("ARCHETHIC_THROTTLE_IP_LOW", "5000")
],
by_ip_and_path: [
period: 1000,
limit: 5_000
limit: System.get_env("ARCHETHIC_THROTTLE_IP_AND_PATH", "5000")
]
4 changes: 3 additions & 1 deletion lib/archethic/bootstrap/transaction_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ defmodule Archethic.Bootstrap.TransactionHandler do
defp await_confirmation(tx_address, [node | rest]) do
case P2P.send_message(node, %GetTransactionSummary{address: tx_address}) do
{:ok,
%TransactionSummaryMessage{transaction_summary: %TransactionSummary{address: ^tx_address}}} ->
%TransactionSummaryMessage{
transaction_summary: %TransactionSummary{address: ^tx_address}
}} ->
:ok

{:ok, %NotFound{}} ->
Expand Down
36 changes: 20 additions & 16 deletions lib/archethic/crypto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1141,22 +1141,26 @@ defmodule Archethic.Crypto do
"""
@spec get_root_ca_public_key(key()) :: binary()
def get_root_ca_public_key(<<curve::8, origin_id::8, _::binary>>) do
case Keyword.get(@certification_public_keys, ID.to_origin(origin_id)) do
nil ->
"no_key"

# Only for dev
[] ->
""

curves when is_list(curves) ->
case Keyword.get(curves, ID.to_curve(curve)) do
nil ->
"no_key"

public_key ->
public_key
end
if System.get_env("ARCHETHIC_NETWORK_TYPE") == "testnet" do
""
else
case Keyword.get(@certification_public_keys, ID.to_origin(origin_id)) do
nil ->
"no_key"

# Only for dev
[] ->
""

curves when is_list(curves) ->
case Keyword.get(curves, ID.to_curve(curve)) do
nil ->
"no_key"

public_key ->
public_key
end
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/archethic/db/embedded_impl/chain_index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule Archethic.DB.EmbeddedImpl.ChainIndex do
{:ok, %{db_path: db_path}}
end

def code_change("1.0.7", state, _extra) do
def code_change("1.0.6", state, _extra) do
## We start the unstarted LRU cache
cache_max_size = Application.get_env(:archethic, Archethic.DB.ChainIndex.MaxCacheSize)
LRU.start_link(@archetic_db_tx_index_cache, cache_max_size)
Expand Down
10 changes: 6 additions & 4 deletions lib/archethic/election/hypergeometric_distribution.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ defmodule Archethic.Election.HypergeometricDistribution do
alias Archethic.P2P.Node
alias Archethic.PubSub

@executable Application.app_dir(:archethic, "/priv/c_dist/hypergeometric_distribution")
defp executable() do
Application.app_dir(:archethic, "/priv/c_dist/hypergeometric_distribution")
end

def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, opts, name: __MODULE__)
Expand Down Expand Up @@ -114,7 +116,7 @@ defmodule Archethic.Election.HypergeometricDistribution do

defp start_simulation_task(nb_nodes) do
Task.async(fn ->
pid = Port.open({:spawn_executable, @executable}, args: [Integer.to_string(nb_nodes)])
pid = Port.open({:spawn_executable, executable()}, args: [Integer.to_string(nb_nodes)])

receive do
{^pid, {:data, data}} ->
Expand All @@ -134,10 +136,10 @@ defmodule Archethic.Election.HypergeometricDistribution do
iex> HypergeometricDistribution.run_simulation(5)
5
iex> HypergeometricDistribution.run_simulation(20)
19
iex> HypergeometricDistribution.run_simulation(40)
37
Expand Down
Loading

0 comments on commit 9959068

Please sign in to comment.