diff --git a/.github/workflows/check-clippy-all-features.yml b/.github/workflows/check-clippy-all-features.yml new file mode 100644 index 0000000000..34a401e1a3 --- /dev/null +++ b/.github/workflows/check-clippy-all-features.yml @@ -0,0 +1,24 @@ +name: Clippy check --all-features +on: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + RUSTFLAGS: "-Dwarnings" + +jobs: + clippy_check: + runs-on: ubuntu-24.04 + steps: + - name: Maximize build space + uses: easimon/maximize-build-space@master + with: + remove-android: 'true' + remove-dotnet: 'true' + temp-reserve-mb: 'true' + - uses: actions/checkout@v4 + - name: Run Clippy + run: SKIP_WASM_BUILD=1 cargo clippy --all-targets --all-features --locked --quiet diff --git a/.github/workflows/check-clippy.yml b/.github/workflows/check-clippy.yml new file mode 100644 index 0000000000..d5968aae6c --- /dev/null +++ b/.github/workflows/check-clippy.yml @@ -0,0 +1,25 @@ +name: Clippy check +on: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + RUSTFLAGS: "-Dwarnings" + +jobs: + clippy_check: + runs-on: ubuntu-24.04 + if: ${{ !contains(github.event.head_commit.message, '[ci-skip-rust]') }} + steps: + - name: Maximize build space + uses: easimon/maximize-build-space@master + with: + remove-android: 'true' + remove-dotnet: 'true' + temp-reserve-mb: 'true' + - uses: actions/checkout@v4 + - name: Run Clippy + run: SKIP_WASM_BUILD=1 cargo clippy --all-targets --all-features --locked --quiet diff --git a/.github/workflows/check-fmt.yml b/.github/workflows/check-fmt.yml new file mode 100644 index 0000000000..af3416b464 --- /dev/null +++ b/.github/workflows/check-fmt.yml @@ -0,0 +1,22 @@ +name: Check fmt + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + check-fmt: + runs-on: ubuntu-latest + container: + image: paritytech/ci-unified:bullseye-1.74.0 + if: ${{ !contains(github.event.head_commit.message, 'ci-skip-rust') }} + steps: + - uses: actions/checkout@v4 + - name: Run cargo fmt + run: cargo fmt -- --check + - name: Run taplo + run: taplo fmt --check diff --git a/.github/workflows/docpublish.yml b/.github/workflows/docpublish.yml new file mode 100644 index 0000000000..81881c9428 --- /dev/null +++ b/.github/workflows/docpublish.yml @@ -0,0 +1,25 @@ +name: Build and Deploy API docs + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + container: + image: paritytech/ci-unified:bullseye-1.74.0 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install and Build + run: RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps --locked + + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages # The branch the action should deploy to. + folder: docs/api # The folder the action should deploy to. \ No newline at end of file diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 0000000000..f78a7843df --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,35 @@ +name: Integration tests + +on: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + integration-tests: + runs-on: ubuntu-latest + if: ${{ !contains(github.event.head_commit.message, 'ci-skip-integration-tests') }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js environment + run: | + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash + echo 'export NVM_DIR="$HOME/.nvm"' >> $HOME/.bashrc + echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.bashrc + eval "$(cat $HOME/.bashrc | tail -n +10)" + nvm install + nvm use + yarn --immutable + working-directory: ./integration-tests/chopsticks + + - name: Lint & Test + run: | + yarn ts-check + yarn lint + yarn test:CI + working-directory: ./integration-tests/chopsticks + diff --git a/.github/workflows/srtool-build.yml b/.github/workflows/srtool-build.yml new file mode 100644 index 0000000000..3d6f41e736 --- /dev/null +++ b/.github/workflows/srtool-build.yml @@ -0,0 +1,84 @@ +name: Srtool build + +on: + release: + types: [published] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + SUBWASM_VERSION: v0.20.0 + +jobs: + build-wasm: + runs-on: ubuntu-latest + + strategy: + matrix: + runtime: [peregrine, spiritnet] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Srtool build + id: srtool_build + uses: chevdor/srtool-actions@v0.9.2 + env: + PARACHAIN_PALLET_ID: "0x50" + AUTHORIZE_UPGRADE_PREFIX: "0x02" + AUTHORIZE_UPGRADE_CHECK_VERSION: "true" + with: + chain: ${{ matrix.runtime }} + runtime_dir: runtimes/${{ matrix.runtime }} + + - name: Summary + run: | + echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.runtime }}-srtool-digest.json + cat ${{ matrix.runtime }}-srtool-digest.json + echo "Compact Runtime: ${{ steps.srtool_build.outputs.wasm }}" + echo "Compressed Runtime: ${{ steps.srtool_build.outputs.wasm_compressed }}" + + - name: Install subwasm + run: | + wget https://github.com/chevdor/subwasm/releases/download/${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_${{ env.SUBWASM_VERSION }}.deb + sudo dpkg -i subwasm_linux_amd64_${{ env.SUBWASM_VERSION }}.deb + subwasm --version + + - name: Show Runtime information + shell: bash + run: | + subwasm info ${{ steps.srtool_build.outputs.wasm }} + subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} + subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.runtime }}-info.json + subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.runtime }}-compressed-info.json + + - name: Extract the metadata + shell: bash + run: | + subwasm meta ${{ steps.srtool_build.outputs.wasm }} + subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.runtime }}-metadata.json + + - name: Check the metadata diff + shell: bash + run: | + subwasm get -o ${{ matrix.runtime }}-live.wasm wss://${{ matrix.runtime }}.kilt.io + subwasm diff --no-color ${{ matrix.runtime }}-live.wasm ${{ steps.srtool_build.outputs.wasm }} || \ + echo "Subwasm call failed, check the logs. This is likely because ${{ matrix.runtime }} is not known by subwasm" | \ + tee ${{ matrix.chain }}-diff.txt + + - name: Archive Subwasm results + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + with: + name: ${{ matrix.runtime }}-runtime + path: | + ${{ matrix.runtime }}-info.json + ${{ matrix.runtime }}-compressed-info.json + ${{ matrix.runtime }}-metadata.json + ${{ matrix.runtime }}-diff.txt + ${{ steps.srtool_build.outputs.wasm }} + ${{ steps.srtool_build.outputs.wasm_compressed }} + ${{ matrix.runtime }}-srtool-digest.json + diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml new file mode 100644 index 0000000000..2ba4b9f67e --- /dev/null +++ b/.github/workflows/try-runtime.yml @@ -0,0 +1,51 @@ +name: Try-runtime + +on: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 + CARGO_HOME: ./.cargo + +jobs: + test-try-runtime: + strategy: + matrix: + runtime: [peregrine, spiritnet] + runs-on: ubuntu-latest + container: + image: paritytech/ci-unified:bullseye-1.74.0 + + if: ${{ !contains(github.event.head_commit.message, 'ci-skip-rust') }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up caching for Cargo + uses: actions/cache@v4 + with: + path: ${{ secrets.CARGO_CACHE_PATH }} + key: cargo-try-runtime-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + cargo-try-runtime-${{ matrix.runtime }}- + + - name: Run try-runtime + run: | + echo "Running ${{ matrix.runtime }} runtime migration check" + + echo "---------- Downloading try-runtime CLI ----------" + curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime + chmod +x ./try-runtime + echo "Using try-runtime-cli version:" + ./try-runtime --version + + echo "---------- Building ${{ matrix.runtime }} runtime ----------" + cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime + + echo "---------- Executing on-runtime-upgrade for ${{ matrix.runtime }} ----------" + ./try-runtime --runtime ./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \ + on-runtime-upgrade --disable-spec-version-check --checks=all ${{ matrix.subcommand_extra_args }} live --uri wss://${{ matrix.runtime }}.kilt.io diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 60547ef0e4..6085136437 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,216 +1,19 @@ -.check_skip_rust: - before_script: - - |- - if echo "$CI_COMMIT_TITLE" | grep -q "ci-skip-rust"; then - echo "Skipping rust tests due to commit title" - exit 0 - fi +default: + interruptible: true +include: + - local: '.gitlab/check.yml' + - local: '.gitlab/test.yml' + - local: '.gitlab/build.yml' -.check_skip_integration_tests: - before_script: - - |- - if echo "$CI_COMMIT_TITLE" | grep -q "ci-skip-integration-tests"; then - echo "Skipping integration tests due to commit title" - exit 0 - fi +variables: + CARGO_CACHE_PATH: $CARGO_CACHE_PATH + CARGO_HOME: ${CI_PROJECT_DIR}/.cargo workflow: auto_cancel: on_new_commit: interruptible - stages: + - check - test - build - -clippy-and-docs: - extends: .check_skip_rust - interruptible: true - timeout: 2 hours - image: paritytech/ci-unified:bullseye-1.74.0 - stage: test - script: - - cargo clippy --all-features --all-targets --locked -- -D warnings - - RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps --locked - -fmt: - interruptible: true - extends: .check_skip_rust - image: paritytech/ci-unified:bullseye-1.74.0 - stage: test - script: - - cargo fmt -- --check - - cargo install taplo-cli --version 0.9.0 - - taplo fmt --check - -test: - interruptible: true - extends: .check_skip_rust - timeout: 2 hours - image: paritytech/ci-unified:bullseye-1.74.0 - stage: test - script: - - cargo test --all --all-targets --locked - -test-features: - extends: .check_skip_rust - interruptible: true - timeout: 2 hours - image: paritytech/ci-unified:bullseye-1.74.0 - stage: test - script: - - cargo test --all --all-features --all-targets --locked - -integration-tests: - extends: .check_skip_integration_tests - interruptible: true - timeout: 30 minutes - image: paritytech/ci-unified:bullseye-1.74.0 - stage: test - variables: - CI: "true" - script: - - cd ./integration-tests/chopsticks - - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash - - export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use - - eval "[ -f .nvmrc ] && nvm install" && nvm use - - yarn --immutable - - yarn ts-check - - yarn lint - - yarn test:CI - -# TODO: The try-runtime-cli executable could be built as part of the Docker image directly, saving some time. -test-try-runtime: - extends: .check_skip_rust - interruptible: true - parallel: - matrix: - - RUNTIME: "peregrine" - ENDPOINT: "wss://peregrine.kilt.io:443" - - RUNTIME: "spiritnet" - ENDPOINT: "wss://spiritnet.kilt.io:443" - timeout: 2 hours - image: paritytech/ci-unified:bullseye-1.74.0 - stage: test - variables: - TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 - script: - - curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${TRY_RUNTIME_CLI_VERSION_TAG}/try-runtime-x86_64-unknown-linux-musl -o try-runtime - - chmod +x ./try-runtime - - ./try-runtime --version - - cargo build --locked --release -p ${RUNTIME}-runtime --features try-runtime - - ./try-runtime --runtime ./target/release/wbuild/${RUNTIME}-runtime/${RUNTIME}_runtime.compact.compressed.wasm on-runtime-upgrade --disable-spec-version-check --checks=all live --uri=${ENDPOINT} - -build: - interruptible: true - timeout: 2 hours - image: - name: kiltprotocol/kilt-ci:2.7.31 - entrypoint: [""] - stage: build - only: - refs: - - develop - - master - - /^[0-9]+(?:\.[0-9]+){2}(?:-(rc)*([0-9])+)?$/ - - /^[dev-](\w*-)*[0-9]?$/ - variables: - DOCKER_HUB_PARACHAIN: "kiltprotocol/kilt-node" - DOCKER_HUB_STANDALONE: "kiltprotocol/standalone-node" - DOCKER_HUB_DIP_PROVIDER_TEMPLATE: "kiltprotocol/dip-provider-node-template" - DOCKER_HUB_DIP_CONSUMER_TEMPLATE: "kiltprotocol/dip-consumer-node-template" - before_script: - - aws --version - - docker --version - script: - - echo -n $CI_REGISTRY_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY - - aws ecr get-login-password | docker login --username AWS --password-stdin $AWS_REGISTRY - - ./.maintain/docker-auth-config.sh - - - ./.maintain/build-image.sh build - - "if [[ ! -z ${CI_COMMIT_BRANCH} ]]; then ./.maintain/push-image.sh build ${CI_COMMIT_SHORT_SHA}; fi" - - "if [[ ! -z ${CI_COMMIT_BRANCH} ]]; then ./.maintain/push-image.sh build latest-${CI_COMMIT_BRANCH}; fi" - - "if [[ ! -z ${CI_COMMIT_TAG} ]]; then ./.maintain/push-image.sh build ${CI_COMMIT_TAG}; fi" - - "if [[ ! -z ${CI_COMMIT_TAG} && ! -z ${CI_COMMIT_TAG##*-rc*} && ! -z ${CI_COMMIT_TAG##*dev-*} ]]; then ./.maintain/push-image.sh build latest; fi" - -build-wasm-peregrine: - interruptible: true - image: - name: paritytech/srtool:1.74.0 - entrypoint: [""] - stage: build - only: - - develop - - master - - /^[0-9]+(?:\.[0-9]+){2}(?:-(rc)*([0-9])+)?$/ - script: - - export PACKAGE=peregrine-runtime - - export RUNTIME_DIR=runtimes/peregrine - - export PARACHAIN_PALLET_ID=0x50 - - export AUTHORIZE_UPGRADE_PREFIX=0x02 - - cp -r * /build - - /srtool/build build - - subwasm meta --format=json+scale /out/peregrine_runtime.compact.wasm > /out/peregrine-metadata.json - - subwasm get -o peregrine-live.wasm wss://peregrine.kilt.io - - subwasm diff --no-color peregrine-live.wasm /out/peregrine_runtime.compact.wasm | tee /out/peregrine-diff.txt - - mkdir ./out - - mv /out/* ./out/ - artifacts: - paths: - - out/*.wasm - - out/*.json - - out/*.txt - expire_in: 12 week - -build-wasm-spiritnet: - interruptible: true - image: - name: paritytech/srtool:1.74.0 - entrypoint: [""] - stage: build - only: - - develop - - master - - /^[0-9]+(?:\.[0-9]+){2}(?:-(rc)*([0-9])+)?$/ - script: - - export PACKAGE=spiritnet-runtime - - export RUNTIME_DIR=runtimes/spiritnet - - export PARACHAIN_PALLET_ID=0x50 - - export AUTHORIZE_UPGRADE_PREFIX=0x02 - - cp -r * /build - - /srtool/build build - - subwasm meta --format=json+scale /out/spiritnet_runtime.compact.wasm > /out/spiritnet-metadata.json - - subwasm get -o spiritnet-live.wasm wss://spiritnet.kilt.io - - subwasm diff --no-color spiritnet-live.wasm /out/spiritnet_runtime.compact.wasm | tee /out/spiritnet-diff.txt - - mkdir ./out - - mv /out/* ./out/ - artifacts: - paths: - - out/*.wasm - - out/*.json - - out/*.txt - expire_in: 12 week - -build-wasm-try-runtime: - interruptible: true - parallel: - matrix: - - RUNTIME: "peregrine" - - RUNTIME: "spiritnet" - image: - name: paritytech/ci-unified:bullseye-1.74.0 - entrypoint: [""] - stage: build - only: - - develop - - master - - /^[0-9]+(?:\.[0-9]+){2}(?:-(rc)*([0-9])+)?$/ - script: - - cargo build --release -p ${RUNTIME}-runtime --features try-runtime - - mkdir ./out - - mv target/release/wbuild/${RUNTIME}-runtime/${RUNTIME}_runtime.compact.compressed.wasm ./dangerous_${RUNTIME}.try-runtime.wasm - artifacts: - name: ${RUNTIME}_try-runtime - paths: - - ./dangerous_${RUNTIME}.try-runtime.wasm - expire_in: 12 week diff --git a/.gitlab/build.yml b/.gitlab/build.yml new file mode 100644 index 0000000000..cd4eee0613 --- /dev/null +++ b/.gitlab/build.yml @@ -0,0 +1,29 @@ +build: + timeout: 2 hours + image: + name: kiltprotocol/kilt-ci:2.7.31 + entrypoint: [""] + stage: build + only: + refs: + - develop + - master + - /^[0-9]+(?:\.[0-9]+){2}(?:-(rc)*([0-9])+)?$/ + - /^[dev-](\w*-)*[0-9]?$/ + variables: + DOCKER_HUB_PARACHAIN: "kiltprotocol/kilt-node" + DOCKER_HUB_STANDALONE: "kiltprotocol/standalone-node" + DOCKER_HUB_DIP_PROVIDER_TEMPLATE: "kiltprotocol/dip-provider-node-template" + DOCKER_HUB_DIP_CONSUMER_TEMPLATE: "kiltprotocol/dip-consumer-node-template" + before_script: + - aws --version + - docker --version + script: + - echo -n $CI_REGISTRY_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY + - aws ecr get-login-password | docker login --username AWS --password-stdin $AWS_REGISTRY + - ./.maintain/docker-auth-config.sh + - ./.maintain/build-image.sh build + - "if [[ ! -z ${CI_COMMIT_BRANCH} ]]; then ./.maintain/push-image.sh build ${CI_COMMIT_SHORT_SHA}; fi" + - "if [[ ! -z ${CI_COMMIT_BRANCH} ]]; then ./.maintain/push-image.sh build latest-${CI_COMMIT_BRANCH}; fi" + - "if [[ ! -z ${CI_COMMIT_TAG} ]]; then ./.maintain/push-image.sh build ${CI_COMMIT_TAG}; fi" + - "if [[ ! -z ${CI_COMMIT_TAG} && ! -z ${CI_COMMIT_TAG##*-rc*} && ! -z ${CI_COMMIT_TAG##*dev-*} ]]; then ./.maintain/push-image.sh build latest; fi" diff --git a/.gitlab/check.yml b/.gitlab/check.yml new file mode 100644 index 0000000000..b9b051dc8b --- /dev/null +++ b/.gitlab/check.yml @@ -0,0 +1,33 @@ +.check_skip_rust: + before_script: + - |- + if echo "$CI_COMMIT_TITLE" | grep -q "ci-skip-rust"; then + echo "Skipping rust tests due to commit title" + exit 0 + fi + +#cargo-clippy: +# extends: .check_skip_rust +# image: paritytech/ci-unified:bullseye-1.74.0 +# variables: +# RUSTDOCFLAGS: '-D warnings' +# stage: check +# cache: +# key: cargo-clippy +# paths: +# - ${CARGO_CACHE_PATH} +# script: +# - SKIP_WASM_BUILD=1 cargo clippy --all-targets --locked --quiet +# +#cargo-clippy-all-features: +# extends: .check_skip_rust +# image: paritytech/ci-unified:bullseye-1.74.0 +# variables: +# RUSTDOCFLAGS: '-D warnings' +# stage: check +# cache: +# key: cargo-clippy-all-features +# paths: +# - ${CARGO_CACHE_PATH} +# script: +# - SKIP_WASM_BUILD=1 cargo clippy --all-targets --all-features --locked --quiet diff --git a/.gitlab/test.yml b/.gitlab/test.yml new file mode 100644 index 0000000000..2eef4dc3a0 --- /dev/null +++ b/.gitlab/test.yml @@ -0,0 +1,36 @@ +test: + extends: .check_skip_rust + timeout: 2 hours + image: paritytech/ci-unified:bullseye-1.74.0 + stage: test + cache: + key: cargo-test + paths: + - ${CARGO_CACHE_PATH} + script: + - cargo test --all-targets --locked + +test-rustdoc: + extends: .check_skip_rust + image: paritytech/ci-unified:bullseye-1.74.0 + variables: + SKIP_WASM_BUILD: 1 + stage: check + cache: + key: cargo-test-rustdoc + paths: + - ${CARGO_CACHE_PATH} + script: + - cargo doc --all-features --no-deps --locked + +test-features: + extends: .check_skip_rust + timeout: 2 hours + image: paritytech/ci-unified:bullseye-1.74.0 + stage: test + cache: + key: cargo-test-features + paths: + - ${CARGO_CACHE_PATH} + script: + - cargo test --all-features --all-targets --locked diff --git a/.maintain/build-image.sh b/.maintain/build-image.sh index b179b7928f..ad88929b43 100755 --- a/.maintain/build-image.sh +++ b/.maintain/build-image.sh @@ -1,40 +1,39 @@ #!/bin/bash +set -e + target_tag=$1 +# Build the builder image and push it in the background docker build \ --target builder \ --cache-from $AWS_REGISTRY/kilt-parachain/collator:builder \ -t $AWS_REGISTRY/kilt-parachain/collator:builder \ - . -docker push $AWS_REGISTRY/kilt-parachain/collator:builder + . & +docker push $AWS_REGISTRY/kilt-parachain/collator:builder & -# build parachain image and standalone image -docker build \ - --cache-from $AWS_REGISTRY/kilt-parachain/collator:builder \ - --cache-from $AWS_REGISTRY/kilt-parachain/collator:$target_tag \ - --build-arg NODE_TYPE=kilt-parachain \ - -t local/kilt-node:$target_tag \ - . -docker build \ - --cache-from $AWS_REGISTRY/kilt-parachain/collator:builder \ - --cache-from $AWS_REGISTRY/kilt/prototype-chain:$target_tag \ - --build-arg NODE_TYPE=standalone-node \ - -t local/standalone-node:$target_tag \ - . +wait -# build DIP provider and consumer templates -PROVIDER_BIN_NAME="dip-provider-node-template" -docker build \ - --cache-from $AWS_REGISTRY/kilt-parachain/collator:builder \ - --cache-from $AWS_REGISTRY/$PROVIDER_BIN_NAME:$target_tag \ - --build-arg NODE_TYPE=$PROVIDER_BIN_NAME \ - -t local/$PROVIDER_BIN_NAME:$target_tag \ - . -CONSUMER_BIN_NAME="dip-consumer-node-template" -docker build \ - --cache-from $AWS_REGISTRY/kilt-parachain/collator:builder \ - --cache-from $AWS_REGISTRY/$CONSUMER_BIN_NAME:$target_tag \ - --build-arg NODE_TYPE=$CONSUMER_BIN_NAME \ - -t local/$CONSUMER_BIN_NAME:$target_tag \ - . +# Build and tag images in parallel +build_and_tag() { + local node_type=$1 + local image_name=$2 + local cache_image=$3 + + docker build \ + --cache-from $AWS_REGISTRY/kilt-parachain/collator:builder \ + --cache-from $AWS_REGISTRY/$cache_image:$target_tag \ + --build-arg NODE_TYPE=$node_type \ + -t local/$image_name:$target_tag \ + . +} + +build_and_tag "kilt-parachain" "kilt-node" "kilt-parachain/collator" & + +build_and_tag "standalone-node" "standalone-node" "kilt/prototype-chain" & + +build_and_tag "dip-provider-node-template" "dip-provider-node-template" "kilt-parachain/collator" & + +build_and_tag "dip-consumer-node-template" "dip-consumer-node-template" "kilt-parachain/collator" & + +wait diff --git a/.maintain/push-image.sh b/.maintain/push-image.sh index ba46da0ea1..cf00a396ca 100755 --- a/.maintain/push-image.sh +++ b/.maintain/push-image.sh @@ -6,24 +6,25 @@ target_tag=$2 PROVIDER_BIN_NAME="dip-provider-node-template" CONSUMER_BIN_NAME="dip-consumer-node-template" -# publish to docker hub -docker tag local/standalone-node:$source_tag ${DOCKER_HUB_STANDALONE}:$target_tag -docker tag local/kilt-node:$source_tag ${DOCKER_HUB_PARACHAIN}:$target_tag -docker tag local/$PROVIDER_BIN_NAME:$source_tag ${DOCKER_HUB_DIP_PROVIDER_TEMPLATE}:$target_tag -docker tag local/$CONSUMER_BIN_NAME:$source_tag ${DOCKER_HUB_DIP_CONSUMER_TEMPLATE}:$target_tag +# Function to tag and push images +tag_and_push() { + local source=$1 + local target=$2 -docker push ${DOCKER_HUB_STANDALONE}:$target_tag -docker push ${DOCKER_HUB_PARACHAIN}:$target_tag -docker push ${DOCKER_HUB_DIP_PROVIDER_TEMPLATE}:$target_tag -docker push ${DOCKER_HUB_DIP_CONSUMER_TEMPLATE}:$target_tag + docker tag $source $target + docker push $target & +} -# publish to AWS -docker tag local/standalone-node:$source_tag $AWS_REGISTRY/kilt/prototype-chain:$target_tag -docker tag local/kilt-node:$source_tag $AWS_REGISTRY/kilt-parachain/collator:$target_tag -docker tag local/$PROVIDER_BIN_NAME:$source_tag $AWS_REGISTRY/$PROVIDER_BIN_NAME:$target_tag -docker tag local/$CONSUMER_BIN_NAME:$source_tag $AWS_REGISTRY/$CONSUMER_BIN_NAME:$target_tag +# Tag and push to Docker Hub +tag_and_push local/standalone-node:$source_tag ${DOCKER_HUB_STANDALONE}:$target_tag +tag_and_push local/kilt-node:$source_tag ${DOCKER_HUB_PARACHAIN}:$target_tag +tag_and_push local/$PROVIDER_BIN_NAME:$source_tag ${DOCKER_HUB_DIP_PROVIDER_TEMPLATE}:$target_tag +tag_and_push local/$CONSUMER_BIN_NAME:$source_tag ${DOCKER_HUB_DIP_CONSUMER_TEMPLATE}:$target_tag -docker push $AWS_REGISTRY/kilt/prototype-chain:$target_tag -docker push $AWS_REGISTRY/kilt-parachain/collator:$target_tag -docker push $AWS_REGISTRY/$PROVIDER_BIN_NAME:$target_tag -docker push $AWS_REGISTRY/$CONSUMER_BIN_NAME:$target_tag +# Tag and push to AWS +tag_and_push local/standalone-node:$source_tag $AWS_REGISTRY/standalone-node:$target_tag +tag_and_push local/kilt-node:$source_tag $AWS_REGISTRY/kilt-node:$target_tag +tag_and_push local/$PROVIDER_BIN_NAME:$source_tag $AWS_REGISTRY/$PROVIDER_BIN_NAME:$target_tag +tag_and_push local/$CONSUMER_BIN_NAME:$source_tag $AWS_REGISTRY/$CONSUMER_BIN_NAME:$target_tag + +wait diff --git a/.maintain/srtool.Dockerfile b/.maintain/srtool.Dockerfile deleted file mode 100644 index 717c6fd4c2..0000000000 --- a/.maintain/srtool.Dockerfile +++ /dev/null @@ -1,69 +0,0 @@ -FROM docker.io/library/ubuntu:22.04 - -LABEL maintainer "chevdor@gmail.com" -LABEL description="This image contains tools for Substrate blockchains runtimes." - -ARG RUSTC_VERSION="1.64.0" -ENV RUSTC_VERSION=$RUSTC_VERSION -ENV DOCKER_IMAGE="paritytech/srtool" -ENV PROFILE=release -ENV PACKAGE=polkadot-runtime -ENV BUILDER=builder -ARG UID=1000 -ARG GID=998 - -ENV SRTOOL_TEMPLATES=/srtool/templates - -RUN groupadd -g $GID $BUILDER && \ - useradd --no-log-init -m -u $UID -s /bin/bash -d /home/$BUILDER -r -g $BUILDER $BUILDER -RUN mkdir -p ${SRTOOL_TEMPLATES} && \ - mkdir /build && chown -R $BUILDER /build && \ - mkdir /out && chown -R $BUILDER /out - -WORKDIR /tmp -ENV DEBIAN_FRONTEND=noninteractive - -# Tooling -ARG SUBWASM_VERSION=0.18.0 -ARG TERA_CLI_VERSION=0.2.1 -ARG TOML_CLI_VERSION=0.2.1 - -COPY ./templates ${SRTOOL_TEMPLATES}/ -RUN apt update && \ - apt upgrade -y && \ - apt install --no-install-recommends -y \ - cmake pkg-config libssl-dev make \ - git clang bsdmainutils ca-certificates curl && \ - curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 --output /usr/bin/jq && chmod a+x /usr/bin/jq && \ - rm -rf /var/lib/apt/lists/* /tmp/* && apt clean - -RUN curl -L https://github.com/chevdor/subwasm/releases/download/v${SUBWASM_VERSION}/subwasm_linux_amd64_v${SUBWASM_VERSION}.deb --output subwasm.deb && dpkg -i subwasm.deb && subwasm --version && \ - curl -L https://github.com/chevdor/tera-cli/releases/download/v${TERA_CLI_VERSION}/tera-cli_linux_amd64.deb --output tera_cli.deb && dpkg -i tera_cli.deb && tera --version && \ - curl -L https://github.com/chevdor/toml-cli/releases/download/v${TOML_CLI_VERSION}/toml_linux_amd64_v${TOML_CLI_VERSION}.deb --output toml.deb && dpkg -i toml.deb && toml --version && \ - rm -rf /tmp/* - -COPY ./scripts/* /srtool/ -COPY VERSION /srtool/ -COPY RUSTC_VERSION /srtool/ - -USER root -ENV RUSTUP_HOME="/home/${BUILDER}/rustup" -ENV CARGO_HOME="/home/${BUILDER}/cargo" -ENV PATH="/srtool:$PATH" - -RUN echo $SHELL && \ - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ - . $CARGO_HOME/env && \ - rustup toolchain add stable ${RUSTC_VERSION} && \ - rustup target add wasm32-unknown-unknown --toolchain $RUSTC_VERSION && \ - chmod -R a+w $RUSTUP_HOME $CARGO_HOME && \ - rustup show && rustc -V - -RUN git config --global --add safe.directory /build && \ - /srtool/version && \ - echo 'PATH=".:$HOME/cargo/bin:$PATH"' >> $HOME/.bashrc - -VOLUME [ "/build", "$CARGO_HOME", "/out" ] -WORKDIR /srtool - -CMD ["/srtool/build"]