From 41c9637b689b7cf9f2e200743f66e68cb781f006 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Thu, 31 Oct 2024 16:21:41 +0100 Subject: [PATCH 01/19] [ci] Move from Gitlab to Github --- .github/workflows/calc.yml | 8 +++++-- .github/workflows/e2e.yml | 37 +++++++++++++++++++++++++++++++++ .github/workflows/pr.yml | 38 +++++++++++++++++++--------------- .github/workflows/semantic.yml | 8 +++++-- 4 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/e2e.yml diff --git a/.github/workflows/calc.yml b/.github/workflows/calc.yml index bcd5c2e12..6218812e1 100644 --- a/.github/workflows/calc.yml +++ b/.github/workflows/calc.yml @@ -2,9 +2,13 @@ name: calc on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: build: diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 000000000..66957539a --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,37 @@ +name: E2E Tests + +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + e2e: + name: e2e + runs-on: ubuntu-latest + container: + image: node:18 + strategy: + matrix: + include: + - chain-name: westend + chain-url: wss://westend-rpc.polkadot.io + - chain-name: kusama + chain-url: wss://apps-kusama-rpc.polkadot.io + - chain-name: polkadot + chain-url: wss://apps-rpc.polkadot.io + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: e2e tests + run: | + yarn --immutable + echo "Tests for ${{ matrix.chain-name }}" + yarn test:latest-e2e-tests --log-level info --chain ${{ matrix.chain-name }} --local ${{ matrix.chain-url }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8151bbf4f..d0401cd5c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,6 +8,10 @@ on: branches: - master +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: lint: # The type of runner that the job will run on @@ -21,7 +25,7 @@ jobs: - name: Install Node v18 uses: actions/setup-node@v4 with: - node-version: '18.14' + node-version: "18.14" - name: Get yarn cache directory path id: yarn-cache-dir-path @@ -41,7 +45,7 @@ jobs: - name: Linter. run: yarn lint tests: - # The type of runner that the job will run on + # The type of runner that the job will run on runs-on: ubuntu-latest steps: @@ -51,7 +55,7 @@ jobs: - name: Install Node v18 uses: actions/setup-node@v4 with: - node-version: '18.14' + node-version: "18.14" - name: Get yarn cache directory path id: yarn-cache-dir-path @@ -82,7 +86,7 @@ jobs: - name: Install Node v18 uses: actions/setup-node@v4 with: - node-version: '18.14' + node-version: "18.14" - name: Get yarn cache directory path id: yarn-cache-dir-path @@ -113,7 +117,7 @@ jobs: - name: Install Node v18 uses: actions/setup-node@v4 with: - node-version: '18.14' + node-version: "18.14" - name: Get yarn cache directory path id: yarn-cache-dir-path @@ -134,11 +138,11 @@ jobs: run: yarn build:docs build-npm-release: - # This test is to make sure sidecar can release a binary without any errors. - # This script does not publish a release, but instead uses yarn to create a tarball and - # install it locally. Once installed a binary is attached to sidecars node_modules, and that - # binary is then tested against. For more in depth information reference the docs at - # `../../scripts/README.md`. + # This test is to make sure sidecar can release a binary without any errors. + # This script does not publish a release, but instead uses yarn to create a tarball and + # install it locally. Once installed a binary is attached to sidecars node_modules, and that + # binary is then tested against. For more in depth information reference the docs at + # `../../scripts/README.md`. runs-on: ubuntu-latest @@ -147,10 +151,10 @@ jobs: node-version: [18.x] steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - run: yarn - - run: yarn test:test-release + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: yarn + - run: yarn test:test-release diff --git a/.github/workflows/semantic.yml b/.github/workflows/semantic.yml index c01e94a51..2dccdfc22 100644 --- a/.github/workflows/semantic.yml +++ b/.github/workflows/semantic.yml @@ -13,11 +13,15 @@ on: - opened - edited - synchronize - + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: validate-title: permissions: - pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs + pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs name: Validate PR Title runs-on: ubuntu-latest steps: From f3ae4a400f555a7ccdaadf9857ed629e46729ce6 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Fri, 1 Nov 2024 10:27:09 +0100 Subject: [PATCH 02/19] add build docker jobs --- .github/workflows/pr.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d0401cd5c..45aceabb5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -158,3 +158,19 @@ jobs: node-version: ${{ matrix.node-version }} - run: yarn - run: yarn test:test-release + + build_docker: + name: Build docker image + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: false + tags: | + docker.io/parity/substrate-api-sidecar:latest From 19640b371a6c7eb467a5125837240faeb0189fe3 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Fri, 1 Nov 2024 11:09:25 +0100 Subject: [PATCH 03/19] add deploy --- .github/workflows/deploy.yml | 112 +++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..430332ee9 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,112 @@ +name: Deploy + +on: + push: + branches: + - master + tags: + - v* + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +#to use reusable workflow +permissions: + id-token: write + contents: read + +env: + APP: "substrate-api-sidecar" + +jobs: + set-variables: + # This workaround sets the container image for each job using 'set-variables' job output. + # env variables don't work for PR from forks, so we need to use outputs. + runs-on: ubuntu-latest + outputs: + VERSION: ${{ steps.version.outputs.VERSION }} + steps: + - name: Define version + id: version + run: | + export COMMIT_SHA=${{ github.sha }} + export COMMIT_SHA_SHORT=${COMMIT_SHA:0:8} + export REF_NAME=${{ github.ref_name }} + export REF_SLUG=${REF_NAME//\//_} + if [[ ${REF_SLUG} == "master" ]] + then + VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT} + echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT + else + VERSION=${REF_SLUG} + echo "VERSION=${REF_SLUG}" >> $GITHUB_OUTPUT + fi + echo "set VERSION=${VERSION}" + + build_push_docker: + name: Build docker image + runs-on: ubuntu-latest + environment: tags + needs: [set-variables] + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + steps: + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: | + docker.io/parity/substrate-api-sidecar:${{ env.VERSION }} + + deploy-stg: + name: Deploy Staging + runs-on: ubuntu-latest + needs: [set-variables, build_push_docker] + environment: parity-stg + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + ARGOCD_SERVER: "argocd-stg.teleport.parity.io" + steps: + - name: Deploy to ArgoCD + uses: paritytech/argocd-deployment-action@main + with: + environment: "parity-stg" + tag: "${{ env.VERSION }}" + app_name: "${{ env.APP }}" + app_packages: "${{ env.APP }}" + argocd_server: ${{ env.ARGOCD_SERVER }} + teleport_token: ${{ env.APP }} + teleport_app_name: "argocd-stg" + argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} + + deploy-prod: + name: Deploy Production + runs-on: ubuntu-latest + needs: [set-variables, deploy-stg] + # Deploy only if the tag is v* + if: startsWith(github.ref, 'refs/tags/v') + environment: parity-prod + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + ARGOCD_SERVER: "argocd-prod.teleport.parity.io" + steps: + - name: Deploy to ArgoCD + uses: paritytech/argocd-deployment-action@main + with: + environment: "parity-prod" + tag: "${{ env.VERSION }}" + app_name: "${{ env.APP }}" + app_packages: "${{ env.APP }}" + argocd_server: ${{ env.ARGOCD_SERVER }} + teleport_token: ${{ env.APP }} + teleport_app_name: "argocd-prod" + argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} From f1317a2a246ce2b982b20f9eef10b5e3dd844d74 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Fri, 1 Nov 2024 11:19:26 +0100 Subject: [PATCH 04/19] rename env in deploy --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 430332ee9..fce9b9399 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -47,7 +47,7 @@ jobs: build_push_docker: name: Build docker image runs-on: ubuntu-latest - environment: tags + environment: master_n_tags needs: [set-variables] env: VERSION: ${{ needs.set-variables.outputs.VERSION }} From 4edb6c43c9d288d5b15dc2478c923a74c26760a0 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Fri, 1 Nov 2024 11:28:06 +0100 Subject: [PATCH 05/19] move e2e to pr, rename pr.yml to ci.yml, add benchmark --- .github/workflows/benchmark.yml | 32 ++++++++++++++++++++++++ .github/workflows/{pr.yml => ci.yml} | 24 ++++++++++++++++++ .github/workflows/e2e.yml | 37 ---------------------------- 3 files changed, 56 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/benchmark.yml rename .github/workflows/{pr.yml => ci.yml} (87%) delete mode 100644 .github/workflows/e2e.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 000000000..13f50988d --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,32 @@ +name: Benchmark + +on: + push: + branches: + - master + tags: + - v* + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + benchmark: + name: benchmark + runs-on: ubuntu-latest + container: + image: paritytech/node-wrk:latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: benchmarks + run: | + yarn --immutable + echo "Benchmarks for polkadot" + mkdir -p artifacts + yarn bench --log-level info --ws-url wss://rpc.polkadot.io + mv benchmarks.txt artifacts/ diff --git a/.github/workflows/pr.yml b/.github/workflows/ci.yml similarity index 87% rename from .github/workflows/pr.yml rename to .github/workflows/ci.yml index 45aceabb5..c2d2b6e5c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/ci.yml @@ -174,3 +174,27 @@ jobs: push: false tags: | docker.io/parity/substrate-api-sidecar:latest + + e2e: + name: e2e + runs-on: ubuntu-latest + container: + image: node:18 + strategy: + matrix: + include: + - chain-name: westend + chain-url: wss://westend-rpc.polkadot.io + - chain-name: kusama + chain-url: wss://apps-kusama-rpc.polkadot.io + - chain-name: polkadot + chain-url: wss://apps-rpc.polkadot.io + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: e2e tests + run: | + yarn --immutable + echo "Tests for ${{ matrix.chain-name }}" + yarn test:latest-e2e-tests --log-level info --chain ${{ matrix.chain-name }} --local ${{ matrix.chain-url }} diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index 66957539a..000000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: E2E Tests - -on: - push: - branches: - - master - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - e2e: - name: e2e - runs-on: ubuntu-latest - container: - image: node:18 - strategy: - matrix: - include: - - chain-name: westend - chain-url: wss://westend-rpc.polkadot.io - - chain-name: kusama - chain-url: wss://apps-kusama-rpc.polkadot.io - - chain-name: polkadot - chain-url: wss://apps-rpc.polkadot.io - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: e2e tests - run: | - yarn --immutable - echo "Tests for ${{ matrix.chain-name }}" - yarn test:latest-e2e-tests --log-level info --chain ${{ matrix.chain-name }} --local ${{ matrix.chain-url }} From 327f453b5f6ee6056273e28ec9640bc1ad8bfa20 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Fri, 1 Nov 2024 11:38:00 +0100 Subject: [PATCH 06/19] fix deply --- .github/workflows/deploy.yml | 62 ++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fce9b9399..f4b521c11 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,7 +67,7 @@ jobs: tags: | docker.io/parity/substrate-api-sidecar:${{ env.VERSION }} - deploy-stg: + deploy-stg-kusama: name: Deploy Staging runs-on: ubuntu-latest needs: [set-variables, build_push_docker] @@ -81,32 +81,76 @@ jobs: with: environment: "parity-stg" tag: "${{ env.VERSION }}" - app_name: "${{ env.APP }}" + app_name: "substrate-api-sidecar-kusama" app_packages: "${{ env.APP }}" argocd_server: ${{ env.ARGOCD_SERVER }} teleport_token: ${{ env.APP }} teleport_app_name: "argocd-stg" argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} - deploy-prod: + deploy-stg-polkadot: + name: Deploy Staging + runs-on: ubuntu-latest + needs: [set-variables, build_push_docker] + environment: parity-stg + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + ARGOCD_SERVER: "argocd-stg.teleport.parity.io" + steps: + - name: Deploy to ArgoCD + uses: paritytech/argocd-deployment-action@main + with: + environment: "parity-stg" + tag: "${{ env.VERSION }}" + app_name: "substrate-api-sidecar-polkadot" + app_packages: "${{ env.APP }}" + argocd_server: ${{ env.ARGOCD_SERVER }} + teleport_token: ${{ env.APP }} + teleport_app_name: "argocd-stg" + argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} + + deploy-prod-kusama: + name: Deploy Production + runs-on: ubuntu-latest + needs: [set-variables, deploy-stg-kusama, deploy-stg-polkadot] + # Deploy only if the tag is v* + if: startsWith(github.ref, 'refs/tags/v') + environment: parity-chains + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + ARGOCD_SERVER: "argocd-chains.teleport.parity.io" + steps: + - name: Deploy to ArgoCD + uses: paritytech/argocd-deployment-action@main + with: + environment: "parity-chains" + tag: "${{ env.VERSION }}" + app_name: "substrate-api-sidecar-kusama" + app_packages: "${{ env.APP }}" + argocd_server: ${{ env.ARGOCD_SERVER }} + teleport_token: ${{ env.APP }} + teleport_app_name: "argocd-chains" + argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} + + deploy-prod-polkadot: name: Deploy Production runs-on: ubuntu-latest - needs: [set-variables, deploy-stg] + needs: [set-variables, deploy-stg-kusama, deploy-stg-polkadot] # Deploy only if the tag is v* if: startsWith(github.ref, 'refs/tags/v') - environment: parity-prod + environment: parity-chains env: VERSION: ${{ needs.set-variables.outputs.VERSION }} - ARGOCD_SERVER: "argocd-prod.teleport.parity.io" + ARGOCD_SERVER: "argocd-chains.teleport.parity.io" steps: - name: Deploy to ArgoCD uses: paritytech/argocd-deployment-action@main with: - environment: "parity-prod" + environment: "parity-chains" tag: "${{ env.VERSION }}" - app_name: "${{ env.APP }}" + app_name: "substrate-api-sidecar-polkadot" app_packages: "${{ env.APP }}" argocd_server: ${{ env.ARGOCD_SERVER }} teleport_token: ${{ env.APP }} - teleport_app_name: "argocd-prod" + teleport_app_name: "argocd-chains" argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} From 023e6a21efe632196ee3f3b891175e38aa8e2921 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Fri, 1 Nov 2024 11:41:13 +0100 Subject: [PATCH 07/19] artifact for benches --- .github/workflows/benchmark.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 13f50988d..4a0e77f5d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -30,3 +30,9 @@ jobs: mkdir -p artifacts yarn bench --log-level info --ws-url wss://rpc.polkadot.io mv benchmarks.txt artifacts/ + + - name: upload artifacts + uses: actions/upload-artifact@v3 + with: + name: benchmarks + path: ./artifacts From dc2b7602bd9a04ef178d5e3542efaa85435d2ae6 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 4 Nov 2024 11:37:33 +0100 Subject: [PATCH 08/19] run benches in github and store results in gh-pages --- .github/workflows/benchmark.yml | 13 +++++++ .../benchmarks/generate_benchmark_result.sh | 37 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 scripts/ci/benchmarks/generate_benchmark_result.sh diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 4a0e77f5d..1b3aa608c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -6,6 +6,7 @@ on: - master tags: - v* + # temporary for testing pull_request: types: [opened, synchronize, reopened, ready_for_review] @@ -36,3 +37,15 @@ jobs: with: name: benchmarks path: ./artifacts + + - name: Modify benches result for benhcmark action + run: ./scripts/ci/generate_benchmark_result.sh artifacts/benchmarks.txt > artifacts/benchmarks.json + + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 #1.20.4 + with: + tool: "customSmallerIsBetter" + output-file-path: artifacts/benchmarks.json + # Push and deploy GitHub pages branch automatically + auto-push: true + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/ci/benchmarks/generate_benchmark_result.sh b/scripts/ci/benchmarks/generate_benchmark_result.sh new file mode 100755 index 000000000..5ae9db475 --- /dev/null +++ b/scripts/ci/benchmarks/generate_benchmark_result.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# The script parses benchmarks.txt file and creates file suitable for https://github.com/benchmark-action/github-action-benchmark +# Usage: generate_benchmark_result.sh + +RESULT_FILE=$1 + +if [ -z "${RESULT_FILE}" ] +then + echo "Usage: $0 " + exit 1 +fi + + +BENCHMARKS=$(cat ${RESULT_FILE} | grep Result | awk '{print $3}') +NBENCHMARKS=$(echo ${BENCHMARKS} | wc -w) +COUNTER=0 +echo "[" +for benchmark in ${BENCHMARKS} +do + COUNTER=$((COUNTER+1)) + # "/accounts/{accountId}/balance-info:" -> "accounts-{accountId}-balance-info" + benchmark_name=$(echo ${benchmark} | cut -d ":" -f1 | sed 's/\///' | sed 's/\//-/g' ) + result=$(cat ${RESULT_FILE} | grep -A 20 ${benchmark} | grep "Avg RequestTime(Latency)" | awk '{print $3}') + unit=${result: -2} + result_value=${result::-2} + echo " {" + echo " \"name\": \"${benchmark_name}\"," + echo " \"result\": ${result_value}," + echo " \"unit\": \"${unit}\"" + if [ $COUNTER -eq $NBENCHMARKS ] + then + echo " }" + else + echo " }," + fi +done +echo "]" \ No newline at end of file From d8b5aacd11e31382c1f7c4349c830e9019601f1b Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 4 Nov 2024 12:27:22 +0100 Subject: [PATCH 09/19] fix path --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 1b3aa608c..b6280eb0b 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -39,7 +39,7 @@ jobs: path: ./artifacts - name: Modify benches result for benhcmark action - run: ./scripts/ci/generate_benchmark_result.sh artifacts/benchmarks.txt > artifacts/benchmarks.json + run: ./scripts/ci/benchmarks/generate_benchmark_result.sh artifacts/benchmarks.txt > artifacts/benchmarks.json - name: Store benchmark result uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 #1.20.4 From 061b0a2bf49e3b3636339dc0ac03793396976b6b Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 4 Nov 2024 14:33:47 +0100 Subject: [PATCH 10/19] try benches in my branch --- .github/workflows/benchmark.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b6280eb0b..f88a8b0fb 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -4,11 +4,9 @@ on: push: branches: - master + - as-move-ci # temporary for testing tags: - v* - # temporary for testing - pull_request: - types: [opened, synchronize, reopened, ready_for_review] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -18,6 +16,7 @@ jobs: benchmark: name: benchmark runs-on: ubuntu-latest + environment: master_n_tags container: image: paritytech/node-wrk:latest steps: @@ -38,6 +37,12 @@ jobs: name: benchmarks path: ./artifacts + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.POLKADOTSDK_GHPAGES_APP_ID }} + private-key: ${{ secrets.POLKADOTSDK_GHPAGES_APP_KEY }} + - name: Modify benches result for benhcmark action run: ./scripts/ci/benchmarks/generate_benchmark_result.sh artifacts/benchmarks.txt > artifacts/benchmarks.json @@ -48,4 +53,4 @@ jobs: output-file-path: artifacts/benchmarks.json # Push and deploy GitHub pages branch automatically auto-push: true - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ steps.app-token.outputs.token }} From 2824437451dd1bf109c4f340c454dc72296045ae Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 4 Nov 2024 15:13:50 +0100 Subject: [PATCH 11/19] fix vats --- .github/workflows/benchmark.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index f88a8b0fb..455e31c3d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -23,6 +23,12 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.GH_APP_SAS_APP_ID }} + private-key: ${{ secrets.GH_APP_SAS_APP_KEY }} + - name: benchmarks run: | yarn --immutable @@ -37,12 +43,6 @@ jobs: name: benchmarks path: ./artifacts - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ secrets.POLKADOTSDK_GHPAGES_APP_ID }} - private-key: ${{ secrets.POLKADOTSDK_GHPAGES_APP_KEY }} - - name: Modify benches result for benhcmark action run: ./scripts/ci/benchmarks/generate_benchmark_result.sh artifacts/benchmarks.txt > artifacts/benchmarks.json From e6d8ff8c911fb855622e9467769744f5df30483b Mon Sep 17 00:00:00 2001 From: alvicsam Date: Tue, 5 Nov 2024 11:27:20 +0100 Subject: [PATCH 12/19] install git --- .github/workflows/benchmark.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 455e31c3d..75bb72497 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -29,6 +29,8 @@ jobs: app-id: ${{ secrets.GH_APP_SAS_APP_ID }} private-key: ${{ secrets.GH_APP_SAS_APP_KEY }} + - run: apt-get update && apt-get install -y git + - name: benchmarks run: | yarn --immutable From 9373264e4cd1b1bef33b99da860db327f218d55d Mon Sep 17 00:00:00 2001 From: alvicsam Date: Tue, 5 Nov 2024 13:45:30 +0100 Subject: [PATCH 13/19] 2 steps bench --- .github/workflows/benchmark.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 75bb72497..45ad453f2 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -23,14 +23,6 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ secrets.GH_APP_SAS_APP_ID }} - private-key: ${{ secrets.GH_APP_SAS_APP_KEY }} - - - run: apt-get update && apt-get install -y git - - name: benchmarks run: | yarn --immutable @@ -45,6 +37,27 @@ jobs: name: benchmarks path: ./artifacts + benchmark-publish: + name: benchmark publish + runs-on: ubuntu-latest + needs: [benchmark] + environment: master_n_tags + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.GH_APP_SAS_APP_ID }} + private-key: ${{ secrets.GH_APP_SAS_APP_KEY }} + + - name: download artifacts + uses: actions/download-artifact@v3 + with: + name: benchmarks + path: ./artifacts + - name: Modify benches result for benhcmark action run: ./scripts/ci/benchmarks/generate_benchmark_result.sh artifacts/benchmarks.txt > artifacts/benchmarks.json From 252d24dc3ec1fd59ed9bfe679904e46592abd4b1 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Tue, 5 Nov 2024 15:06:14 +0100 Subject: [PATCH 14/19] rm test from benches --- .github/workflows/benchmark.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 45ad453f2..bf78fb621 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - as-move-ci # temporary for testing tags: - v* From 73ddc636cb2ddb3c4146b4bdbe0c101725ad7339 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Tue, 5 Nov 2024 15:06:43 +0100 Subject: [PATCH 15/19] rm tags from benches --- .github/workflows/benchmark.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index bf78fb621..010a2e202 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -4,8 +4,6 @@ on: push: branches: - master - tags: - - v* concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} From c3741c02ff627a46a236c0da7866ed5ecd3de3aa Mon Sep 17 00:00:00 2001 From: alvicsam Date: Tue, 5 Nov 2024 15:08:48 +0100 Subject: [PATCH 16/19] rm gitlab --- .github/workflows/gitspiegel-trigger.yml | 22 -- .gitlab-ci.yml | 273 ----------------------- 2 files changed, 295 deletions(-) delete mode 100644 .github/workflows/gitspiegel-trigger.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/gitspiegel-trigger.yml b/.github/workflows/gitspiegel-trigger.yml deleted file mode 100644 index dce3aaf2f..000000000 --- a/.github/workflows/gitspiegel-trigger.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: gitspiegel sync - -# This workflow doesn't do anything, it's only use is to trigger "workflow_run" -# webhook, that'll be consumed by gitspiegel -# This way, gitspiegel won't do mirroring, unless this workflow runs, -# and running the workflow is protected by GitHub - -on: - pull_request: - types: - - opened - - synchronize - - unlocked - - ready_for_review - - reopened - -jobs: - sync: - runs-on: ubuntu-latest - steps: - - name: Do nothing - run: echo "let's go" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 81efb4ad0..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,273 +0,0 @@ -# Gitlab-CI Workflow -# stages: -# build: -# - Runs on commits on master or tags that match the pattern v1.0, v2.1rc1 -# deploy-staging: -# - Runs on commits on master or tags that match the pattern v1.0, v2.1rc1 (continues deployment) -# deploy-production: -# - Runs on tags that match the pattern v1.0, v2.1rc1 (manual deployment) - -variables: - CONTAINER_REPO: "docker.io/parity/substrate-api-sidecar" - DOCKERFILE_DIRECTORY: "./" - CI_IMAGE: "$BUILDAH_IMAGE" # defined in group variables - BUILDAH_COMMAND: "buildah --storage-driver overlay2" - NODE_IMAGE: "node:18" - BENCHMARK_IMAGE: "paritytech/node-wrk:latest" - -default: - retry: - max: 2 - when: - - runner_system_failure - - unknown_failure - - api_failure - interruptible: true - before_script: - - |- - if [[ $CI_COMMIT_TAG =~ ^v[0-9]+\.[0-9]+.*$ ]]; then - export DOCKER_IMAGE_TAG="${CI_COMMIT_TAG}" - export BUILD_LATEST_IMAGE="true" - else - export DOCKER_IMAGE_TAG="${CI_COMMIT_SHORT_SHA}-beta" - fi - -stages: - - test - - build - - deploy-staging - - deploy-production - - benchmark - - check-benchmark - - push-benchmark - -.collect-artifacts: &collect-artifacts - artifacts: - name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" - when: on_success - expire_in: 1 days - paths: - - ./artifacts/ - -.test-refs: &test-refs - rules: - - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - -.test-refs-manual: &test-refs-manual - rules: - - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - when: manual - -.publish-refs: &publish-refs - rules: - - if: $CI_PIPELINE_SOURCE == "pipeline" - when: never - - if: $CI_PIPELINE_SOURCE == "schedule" - - if: $CI_COMMIT_REF_NAME == "master" - - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - -.dockerize: &dockerize - stage: build - image: $CI_IMAGE - tags: - - kubernetes-parity-build - -.kubernetes-env: &kubernetes-env - image: $CI_IMAGE - tags: - - kubernetes-parity-build - -.deploy-k8s: &deploy-k8s - image: quay.io/argoproj/argocd:v2.7.9 - variables: - ARGOCD_OPTS: --grpc-web --grpc-web-root-path /$DOMAIN - script: - - argocd app list - # app1 - - argocd app set $APP1 --helm-set substrate-api-sidecar.image.tag="${DOCKER_IMAGE_TAG}" - - argocd app sync $APP1 - - argocd app wait $APP1 --timeout 180 - # app2 - - argocd app set $APP2 --helm-set substrate-api-sidecar.image.tag="${DOCKER_IMAGE_TAG}" - - argocd app sync $APP2 - - argocd app wait $APP2 --timeout 180 - tags: - - kubernetes-parity-build - -.e2e-template: &e2e-template - stage: test - <<: *kubernetes-env - variables: - CI_IMAGE: $NODE_IMAGE - CHAIN_NAME: "" - CHAIN_URL: "" - script: - - yarn --immutable - - echo "Tests for ${CHAIN_URL}" - - yarn test:latest-e2e-tests --log-level info --chain ${CHAIN_NAME} --local ${CHAIN_URL} - allow_failure: true - -e2e-westend: - <<: *e2e-template - variables: - CI_IMAGE: $NODE_IMAGE - CHAIN_NAME: "westend" - CHAIN_URL: "wss://westend-rpc.polkadot.io" - -e2e-kusama: - <<: *e2e-template - variables: - CI_IMAGE: $NODE_IMAGE - CHAIN_NAME: "kusama" - CHAIN_URL: "wss://apps-kusama-rpc.polkadot.io" - -e2e-polkadot: - <<: *e2e-template - variables: - CI_IMAGE: $NODE_IMAGE - CHAIN_NAME: "polkadot" - CHAIN_URL: "wss://apps-rpc.polkadot.io" - -build-docker: - <<: *dockerize - <<: *publish-refs - script: - - echo building "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" - - if [[ $BUILD_LATEST_IMAGE ]]; then - $BUILDAH_COMMAND build - --format=docker - --tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" - --tag "$CONTAINER_REPO:latest" "$DOCKERFILE_DIRECTORY"; - else - $BUILDAH_COMMAND build - --format=docker - --tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" "$DOCKERFILE_DIRECTORY"; - fi - - $BUILDAH_COMMAND info - - echo ${Docker_Hub_Pass_Parity} | - buildah login --username ${Docker_Hub_User_Parity} --password-stdin docker.io - - echo pushing "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" - - if [[ $BUILD_LATEST_IMAGE ]]; then - $BUILDAH_COMMAND push --format=v2s2 "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"; - $BUILDAH_COMMAND push --format=v2s2 "$CONTAINER_REPO:latest"; - else - $BUILDAH_COMMAND push --format=v2s2 "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"; - fi - -push-docker-image-description: - stage: build - before_script: - - echo - extends: - - .kubernetes-env - variables: - CI_IMAGE: paritytech/dockerhub-description - DOCKERHUB_REPOSITORY: parity/substrate-api-sidecar - DOCKER_USERNAME: $Docker_Hub_User_Parity - DOCKER_PASSWORD: $Docker_Hub_Pass_Parity - README_FILEPATH: $CI_PROJECT_DIR/Dockerfile.README.md - SHORT_DESCRIPTION: "REST service to interact with blockchain nodes built using Substrate's FRAME framework." - rules: - - if: $CI_COMMIT_REF_NAME == "master" - changes: - - Dockerfile.README.md - script: - - cd / && sh entrypoint.sh - -# checks that dockerimage can be built without publishing -build-docker-pr: - <<: *dockerize - <<: *test-refs - script: - - echo building "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" - - if [[ $BUILD_LATEST_IMAGE ]]; then - $BUILDAH_COMMAND build - --format=docker - --tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" - --tag "$CONTAINER_REPO:latest" "$DOCKERFILE_DIRECTORY"; - else - $BUILDAH_COMMAND build - --format=docker - --tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" "$DOCKERFILE_DIRECTORY"; - fi - - $BUILDAH_COMMAND info - -deploy-staging: - stage: deploy-staging - extends: .deploy-k8s - <<: *publish-refs - environment: - name: parity-stg - variables: - DOMAIN: parity-stg - APP1: substrate-api-sidecar-kusama - APP2: substrate-api-sidecar-polkadot - -deploy-production: - stage: deploy-production - extends: .deploy-k8s - environment: - name: parity-chains - variables: - DOMAIN: parity-chains - APP1: substrate-api-sidecar-kusama - APP2: substrate-api-sidecar-polkadot - rules: - - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - when: manual - -bench-polkadot: &bench-polkadot - stage: benchmark - <<: *kubernetes-env - <<: *collect-artifacts - <<: *publish-refs - variables: - CI_IMAGE: $BENCHMARK_IMAGE - CHAIN_NAME: "polkadot" - CHAIN_URL: "wss://rpc.polkadot.io" - script: - - yarn --immutable - - echo "Benchmarks for ${CHAIN_URL}" - - mkdir -p artifacts - - yarn bench --log-level info --ws-url ${CHAIN_URL} - - mv benchmarks.txt artifacts/ - -# manual step to run benchmarks in PR pipeline -bench-polkadot-manual-pr: - stage: benchmark - <<: *bench-polkadot - <<: *test-refs-manual - - -# temporary disabled for collecting results -# check-benchmark: -# stage: check-benchmark -# <<: *publish-refs -# <<: *kubernetes-env -# <<: *collect-artifacts -# needs: -# - job: benchmark -# artifacts: true -# variables: -# GITHUB_REPO: "paritytech/substrate-api-sidecar" -# CI_IMAGE: "paritytech/benchmarks:latest" -# THRESHOLD: 60000 -# GITHUB_TOKEN: $GITHUB_PR_TOKEN -# script: -# - export RESULT=$(cat artifacts/result.txt | grep AvgRequestTime | awk '{print $2}') -# - check_single_bench_result -g $GITHUB_REPO -# -c $THRESHOLD -# -v $RESULT - -push-benchmark: - stage: push-benchmark - <<: *publish-refs - <<: *kubernetes-env - needs: - - job: bench-polkadot - artifacts: true - variables: - PROMETHEUS_URL: "https://pushgateway.parity-build.parity.io" - CI_IMAGE: "paritytech/benchmarks:latest" - script: - - scripts/ci/benchmarks/push_benchmark_results.sh artifacts/benchmarks.txt From e26c40d5524f2201df601d1f342dd21104955286 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Tue, 5 Nov 2024 16:28:52 +0100 Subject: [PATCH 17/19] change deps --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f4b521c11..9045d272e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -112,7 +112,7 @@ jobs: deploy-prod-kusama: name: Deploy Production runs-on: ubuntu-latest - needs: [set-variables, deploy-stg-kusama, deploy-stg-polkadot] + needs: [set-variables, deploy-stg-kusama] # Deploy only if the tag is v* if: startsWith(github.ref, 'refs/tags/v') environment: parity-chains @@ -135,7 +135,7 @@ jobs: deploy-prod-polkadot: name: Deploy Production runs-on: ubuntu-latest - needs: [set-variables, deploy-stg-kusama, deploy-stg-polkadot] + needs: [set-variables, deploy-stg-polkadot] # Deploy only if the tag is v* if: startsWith(github.ref, 'refs/tags/v') environment: parity-chains From 91b4173a0e4ef12932419585baa36eb167ca5662 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Thu, 7 Nov 2024 15:38:45 +0100 Subject: [PATCH 18/19] upd artifacts action version --- .github/workflows/benchmark.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 010a2e202..610cae19c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - as-move-ci concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -29,10 +30,10 @@ jobs: mv benchmarks.txt artifacts/ - name: upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: benchmarks - path: ./artifacts + path: ./artifacts/ benchmark-publish: name: benchmark publish @@ -50,10 +51,10 @@ jobs: private-key: ${{ secrets.GH_APP_SAS_APP_KEY }} - name: download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: benchmarks - path: ./artifacts + path: artifacts - name: Modify benches result for benhcmark action run: ./scripts/ci/benchmarks/generate_benchmark_result.sh artifacts/benchmarks.txt > artifacts/benchmarks.json From 18558f467441b40ec58e2956b5e0b26326be9d7b Mon Sep 17 00:00:00 2001 From: alvicsam Date: Thu, 7 Nov 2024 16:25:33 +0100 Subject: [PATCH 19/19] rm test branch from workflow --- .github/workflows/benchmark.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 610cae19c..6f4ffa9f0 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - as-move-ci concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}