Skip to content

Commit

Permalink
ci: add polkadex to xcm workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
BuddyGlas authored and CertainLach committed Sep 1, 2023
1 parent bb61299 commit a479654
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 8 deletions.
22 changes: 20 additions & 2 deletions .baedeker/xcm-unique.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local relay = {
['unique', 'moonbeam'],
['unique', 'statemint'],
['unique', 'astar'],
['unique', 'polkadex'],
]
])),
}},
Expand All @@ -23,7 +24,7 @@ local relay = {
bin: $.bin,
wantedKeys: 'relay',
},
for name in ['alice', 'bob', 'charlie', 'dave', 'eve', 'ferdie']
for name in ['alice', 'bob', 'charlie', 'dave', 'eve', 'ferdie', 'gregory']
},
};

Expand Down Expand Up @@ -116,9 +117,26 @@ local astar = {
},
};

local polkadex = {
name: 'polkadex',
bin: 'bin/polkadex',
paraId: 1006,
spec: {Genesis:{
chain: 'mainnet',
modify:: m.genericPara($),
}},
nodes: {
[name]: {
bin: $.bin,
wantedKeys: 'para',
},
for name in ['alice', 'bob']
},
};

relay + {
parachains: {
[para.name]: para,
for para in [unique, acala, moonbeam, statemint, astar]
for para in [unique, acala, moonbeam, statemint, astar, polkadex]
},
}
4 changes: 2 additions & 2 deletions .docker/Dockerfile-astar.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ RUN --mount=type=cache,target=/cargo-home/registry \
--mount=type=cache,target=/unique_parachain/Astar/target \
cd Astar && \
CARGO_INCREMENTAL=0 cargo build --release --locked && \
mv ./target/release/astar-collator /unique_parachain/Astar/
mv ./target/release/astar-collator /unique_parachain/Astar/astar

# ===== BIN ======

FROM ubuntu:22.04 as builder-astar

COPY --from=builder-astar-bin /unique_parachain/Astar/astar-collator /bin/astar-collator
COPY --from=builder-astar-bin /unique_parachain/Astar/astar /bin/astar
ENTRYPOINT ["/bin/astar-collator"]
46 changes: 46 additions & 0 deletions .docker/Dockerfile-polkadex.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# ===== Rust builder =====
FROM ubuntu:22.04 as rust-builder
LABEL maintainer="Unique.Network"

ENV CARGO_HOME="/cargo-home"
ENV PATH="/cargo-home/bin:$PATH"
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && \
apt-get install -y curl cmake pkg-config libssl-dev git clang llvm libudev-dev protobuf-compiler && \
apt-get clean && \
rm -r /var/lib/apt/lists/*

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none

RUN rustup toolchain install {{ RUST_TOOLCHAIN }} && \
rustup target add wasm32-unknown-unknown --toolchain {{ RUST_TOOLCHAIN }} && \
rustup default {{ RUST_TOOLCHAIN }} && \
rustup target list --installed && \
rustup show

RUN mkdir /unique_parachain
WORKDIR /unique_parachain

# ===== BUILD ACALA =====
FROM rust-builder as builder-polkadex-bin

WORKDIR /unique_parachain

RUN git clone --depth 1 -b {{ POLKADEX_BUILD_BRANCH }} https://github.com/Polkadex-Substrate/parachain.git

RUN --mount=type=cache,target=/cargo-home/registry \
--mount=type=cache,target=/cargo-home/git \
--mount=type=cache,target=/unique_parachain/parachain/target \
cd parachain && \
CARGO_INCREMENTAL=0 cargo build --release --locked && \
mkdir /unique_parachain/Polkadex && \
mv ./target/release/parachain-polkadex-node /unique_parachain/Polkadex/polkadex

# ===== BIN ======

FROM ubuntu:22.04 as builder-polkadex

COPY --from=builder-polkadex-bin /unique_parachain/Polkadex/polkadex /bin/polkadex
ENTRYPOINT ["/bin/polkadex"]
40 changes: 40 additions & 0 deletions .docker/additional/Dockerfile-chainql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ===== Rust builder =====
FROM ubuntu:22.04 as rust-builder
LABEL maintainer="Unique.Network"

ENV CARGO_HOME="/cargo-home"
ENV PATH="/cargo-home/bin:$PATH"
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && \
apt-get install -y curl cmake pkg-config libssl-dev git clang llvm libudev-dev protobuf-compiler && \
apt-get clean && \
rm -r /var/lib/apt/lists/*

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none

RUN rustup toolchain uninstall $(rustup toolchain list) && \
rustup toolchain install nightly-2022-11-15 && \
rustup default nightly-2022-11-15 && \
rustup target list --installed && \
rustup show
RUN rustup target add wasm32-unknown-unknown --toolchain nightly-2022-11-15

RUN mkdir /unique_parachain
WORKDIR /unique_parachain

# ===== BUILD CHAINQL =====
FROM rust-builder as builder-chainql-bin

RUN mkdir chainql
WORKDIR /chainql

RUN git clone -b {{ CHAINQL }} --depth 1 https://github.com/UniqueNetwork/chainql.git . && \
cargo build --release

# ===== RUN ======

FROM ubuntu:22.04 as builder-chainql

COPY --from=builder-chainql-bin /chainql/target/release/chainql /chainql/target/release/chainql
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ MOONBEAM_BUILD_BRANCH=runtime-2403
ASTAR_BUILD_BRANCH=v5.11.0
UNIQUE_MAINNET_BRANCH=release-v942057
UNIQUE_REPLICA_FROM=wss://ws.unique.network:443
POLKADEX_BUILD_BRANCH=v1.1.0


KUSAMA_MAINNET_BRANCH=release-v1.0.0
STATEMINE_BUILD_BRANCH=release-parachains-v9430
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: develop
# Triger: PR at 'develop' branch with following types of events.
on:
pull_request:
branches: [ 'develop' ]
branches: [ 'develop', 'ci/baedeker' ]
types: [ opened, reopened, synchronize, ready_for_review, converted_to_draft ]

#Concurency group for control execution queue over github runners.
Expand Down
39 changes: 36 additions & 3 deletions .github/workflows/xcm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ jobs:
id: create_matrix
with:
matrix: |
network {opal}, relay_branch {${{ env.UNIQUEWEST_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.WESTMINT_BUILD_BRANCH }}}, astar_version {${{ env.ASTAR_BUILD_BRANCH }}}, runtest {testXcmOpal}, runtime_features {opal-runtime}
network {quartz}, relay_branch {${{ env.KUSAMA_MAINNET_BRANCH }}}, acala_version {${{ env.KARURA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONRIVER_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINE_BUILD_BRANCH }}}, astar_version {${{ env.SHIDEN_BUILD_BRANCH }}}, runtest {testXcmQuartz}, runtime_features {quartz-runtime}
network {unique}, relay_branch {${{ env.POLKADOT_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINT_BUILD_BRANCH }}}, astar_version {${{ env.ASTAR_BUILD_BRANCH }}}, runtest {testXcmUnique}, runtime_features {unique-runtime}
network {unique}, relay_branch {${{ env.POLKADOT_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINT_BUILD_BRANCH }}}, astar_version {${{ env.ASTAR_BUILD_BRANCH }}}, polkadex_version {${{ env.POLKADEX_BUILD_BRANCH }}}, runtest {testXcmUnique}, runtime_features {unique-runtime}
xcm-build:

Expand Down Expand Up @@ -251,6 +249,40 @@ jobs:
fi
shell: bash

# Check POLKADEX version and build it if it doesn't exist in repository
- name: Generate ENV related extend Dockerfile file for POLKADEX
uses: cuchi/[email protected]
with:
template: .docker/Dockerfile-polkadex.j2
output_file: .docker/Dockerfile-polkadex.${{ matrix.polkadex_version }}.yml
variables: |
RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
POLKADEX_BUILD_BRANCH=${{ matrix.polkadex_version }}
- name: Check if the dockerhub repository contains the needed POLKADEX version
run: |
# aquire token
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ secrets.CORE_DOCKERHUB_USERNAME }}'", "password": "'${{ secrets.CORE_DOCKERHUB_TOKEN }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
export TOKEN=$TOKEN
# Get TAGS from DOCKERHUB repository
POLKADEX_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/uniquenetwork/builder-polkadex/tags/?page_size=100 | jq -r '."results"[]["name"]')
# Show TAGS
echo "POLKADEX TAGS:"
echo $POLKADEX_TAGS
# Check correct version POLKADEX and build it if it doesn't exist in POLKADEX TAGS
if [[ ${POLKADEX_TAGS[*]} =~ (^|[[:space:]])"${{ matrix.polkadex_version }}"($|[[:space:]]) ]]; then
echo "Repository has needed POLKADEX version";
docker pull uniquenetwork/builder-polkadex:${{ matrix.polkadex_version }}
else
echo "Repository has not needed POLKADEX version, so build it";
cd .docker/ && docker build --file ./Dockerfile-polkadex.${{ matrix.polkadex_version }}.yml --tag uniquenetwork/builder-polkadex:${{ matrix.polkadex_version }} .
echo "Push needed POLKADEX version to the repository";
docker push uniquenetwork/builder-polkadex:${{ matrix.polkadex_version }}
fi
shell: bash


- name: Run find-and-replace to remove slashes from branch name
uses: mad9000/actions-find-and-replace-string@4
id: branchname
Expand Down Expand Up @@ -294,6 +326,7 @@ jobs:
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/moonbeam':{dockerImage:'uniquenetwork/builder-moonbeam:${{ matrix.moonbeam_version }}'}})
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/cumulus':{dockerImage:'uniquenetwork/builder-cumulus:${{ matrix.cumulus_version }}'}})
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/astar':{dockerImage:'uniquenetwork/builder-astar:${{ matrix.astar_version }}'}})
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/polkadex':{dockerImage:'uniquenetwork/builder-polkadex:${{ matrix.polkadex_version }}'}})
- name: Upload network config
uses: actions/upload-artifact@v3
Expand Down

0 comments on commit a479654

Please sign in to comment.