Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Move from Gitlab to Github #1531

Merged
merged 19 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Benchmark

on:
push:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
benchmark:
name: benchmark
runs-on: ubuntu-latest
environment: master_n_tags
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/

- name: upload artifacts
uses: actions/upload-artifact@v3
with:
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

- 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: ${{ steps.app-token.outputs.token }}
8 changes: 6 additions & 2 deletions .github/workflows/calc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
78 changes: 61 additions & 17 deletions .github/workflows/pr.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -147,10 +151,50 @@ 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

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

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 }}
156 changes: 156 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
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: master_n_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-kusama:
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-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-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]
alvicsam marked this conversation as resolved.
Show resolved Hide resolved
# 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-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-polkadot"
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 }}
22 changes: 0 additions & 22 deletions .github/workflows/gitspiegel-trigger.yml

This file was deleted.

Loading
Loading