Skip to content

Commit

Permalink
trigger gitlab pipleine from gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
ggera committed Aug 20, 2024
1 parent 550480d commit d358837
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 198 deletions.
68 changes: 15 additions & 53 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,22 @@
name: Build Images
name: Trigger GitLab CI

on:
push:
branches:
- github-runner
workflow_run:
workflows: ["Srtool build", "Deploy Chain docs"]
types:
- completed

jobs:
build-images:
trigger_gitlab:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 120
env:
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
AWS_REGISTRY: ${{ secrets.ECR_REGISTRY }}
CI_COMMIT_SHORT_SHA: ${{ github.sha }}
CI_COMMIT_BRANCH: ${{ github.ref_name }}
CI_COMMIT_TAG: ${{ github.ref_name }}
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- name: Checkout
uses: actions/checkout@v4

- name: Display AWS and Docker Versions
run: |
aws --version
docker --version
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to ECR
uses: docker/login-action@v3
with:
registry: ${{ secrets.ECR_REGISTRY }}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Build Docker Images
run: |
./.maintain/build-image.sh build
- name: Push Image - Tag
if: startsWith(github.ref, 'refs/tags/')
run: |
./.maintain/push-image.sh build "${{ env.CI_COMMIT_TAG }}"
- name: Push Image - Latest
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-rc') && !contains(github.ref, 'dev-')
- name: Trigger GitLab CI
env:
GITLAB_TRIGGER_TOKEN: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
run: |
./.maintain/push-image.sh build "latest"
curl -X POST \
-F token=$GITLAB_TRIGGER_TOKEN \
-F ref=${{ github.ref_name }} \
https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/trigger/pipeline
7 changes: 3 additions & 4 deletions .github/workflows/check-clippy-all-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: $ ${{ github.job }}-${{ github.ref }}-clippy-all-features-${{ hashFiles('**/Cargo.lock') }}
key: $ ${{ github.job }}-${{ github.ref_name }}-clippy-all-features-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
$ ${{ github.job }}-${{ github.ref }}-clippy-all-features-
$ ${{ github.job }}-${{ github.ref_name }}-clippy-all-features-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -55,6 +55,5 @@ jobs:
-e SKIP_WASM_BUILD=1 \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "
cargo clippy --all-targets --all-features --locked --quiet && \
chown -R $(id -u):$(id -g) target/"
cargo clippy --all-targets --all-features --locked --quiet
7 changes: 3 additions & 4 deletions .github/workflows/check-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: $ ${{ github.job }}-${{ github.ref }}-clippy-${{ hashFiles('**/Cargo.lock') }}
key: $ ${{ github.job }}-${{ github.ref_name }}-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
$ ${{ github.job }}-${{ github.ref }}-clippy-
$ ${{ github.job }}-${{ github.ref_name }}-clippy-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -55,5 +55,4 @@ jobs:
-e SKIP_WASM_BUILD=1 \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "
cargo clippy --all-targets --locked --quiet && \
chown -R $(id -u):$(id -g) target/"
cargo clippy --all-targets --locked --quiet
7 changes: 3 additions & 4 deletions .github/workflows/check-rustdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: $ ${{ github.job }}-${{ github.ref }}-rustdoc-${{ hashFiles('**/Cargo.lock') }}
key: $ ${{ github.job }}-${{ github.ref_name }}-rustdoc-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
$ ${{ github.job }}-${{ github.ref }}-rustdoc-
$ ${{ github.job }}-${{ github.ref_name }}-rustdoc-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -55,5 +55,4 @@ jobs:
-e SKIP_WASM_BUILD=1 \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "
cargo doc --all-features --no-deps --locked && \
chown -R $(id -u):$(id -g) target/"
cargo doc --all-features --no-deps --locked
2 changes: 1 addition & 1 deletion .github/workflows/docs-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy Chain docs
name: Deploy Chain docs

on:
push:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/test-all-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: $ ${{ github.job }}-${{ github.ref }}-clippy-${{ hashFiles('**/Cargo.lock') }}
key: $ ${{ github.job }}-${{ github.ref_name }}-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
$ ${{ github.job }}-${{ github.ref }}-clippy-
$ ${{ github.job }}-${{ github.ref_name }}-clippy-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -55,5 +55,4 @@ jobs:
-e SKIP_WASM_BUILD=1 \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "
cargo test --all-features --all-targets --locked && \
chown -R $(id -u):$(id -g) target/"
cargo test --all-features --all-targets --locked
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: $ ${{ github.job }}-${{ github.ref }}-clippy-${{ hashFiles('**/Cargo.lock') }}
key: $ ${{ github.job }}-${{ github.ref_name }}-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
$ ${{ github.job }}-${{ github.ref }}-clippy-
$ ${{ github.job }}-${{ github.ref_name }}-clippy-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -55,5 +55,4 @@ jobs:
-e SKIP_WASM_BUILD=1 \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "
cargo test --all-targets --locked && \
chown -R $(id -u):$(id -g) target/"
cargo test --all-targets --locked
52 changes: 28 additions & 24 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
default:
interruptible: true

.check_skip_rust:
build-images:
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:
- |-
if echo "$CI_COMMIT_TITLE" | grep -q "ci-skip-rust"; then
echo "Skipping rust tests due to commit title"
exit 0
fi
include:
- local: '.gitlab/check.yml'
- local: '.gitlab/test.yml'
- local: '.gitlab/build.yml'

variables:
CARGO_CACHE_PATH: $CARGO_CACHE_PATH
CARGO_HOME: ${CI_PROJECT_DIR}/.cargo
- 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

workflow:
auto_cancel:
on_new_commit: interruptible
- ./.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"

stages:
- check
- test
- build
29 changes: 0 additions & 29 deletions .gitlab/build.yml

This file was deleted.

41 changes: 0 additions & 41 deletions .gitlab/check.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .gitlab/test.yml

This file was deleted.

18 changes: 11 additions & 7 deletions .maintain/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ set -e

target_tag=$1

# Build the builder image and push it sequentially
# 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
wait

# Build and tag images in parallel
build_and_tag() {
local node_type=$1
local image_name=$2
Expand All @@ -26,10 +28,12 @@ build_and_tag() {
.
}

build_and_tag "kilt-parachain" "kilt-node" "kilt-parachain/collator"
build_and_tag "kilt-parachain" "kilt-node" "kilt-parachain/collator" &

build_and_tag "standalone-node" "standalone-node" "kilt/prototype-chain"
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-provider-node-template" "dip-provider-node-template" "kilt-parachain/collator" &

build_and_tag "dip-consumer-node-template" "dip-consumer-node-template" "kilt-parachain/collator"
build_and_tag "dip-consumer-node-template" "dip-consumer-node-template" "kilt-parachain/collator" &

wait

0 comments on commit d358837

Please sign in to comment.