diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 000000000..c76aa8871 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,109 @@ +name: Backend CI + +on: + push: + branches: + - master + paths: + - ".github/workflows/backend*" + - "backend/**" + - "!frontend/**" + pull_request: + paths: + - ".github/workflows/backend*" + - "backend/**" + - "!frontend/**" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +defaults: + run: + working-directory: ./backend + +jobs: + check: + name: Check Code + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Rust Cache + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + with: + workspaces: backend + + - name: Build + run: cargo check --all-targets --verbose + tests: + name: Run tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Rust Cache + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + with: + workspaces: backend + cache-on-failure: true + + - name: Cargo test + run: cargo test --verbose --jobs 1 + docs: + name: Check Documentation + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Rust Cache + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + with: + workspaces: backend + + - name: Check internal documentation links + run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items + fmt: + name: Run rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: clippy, rustfmt + + - name: Cargo fmt + run: cargo fmt --verbose --all -- --check diff --git a/.github/workflows/backend_check.yml b/.github/workflows/backend_check.yml deleted file mode 100644 index ef6ea86db..000000000 --- a/.github/workflows/backend_check.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Backend CI - cargo check - -on: - push: - branches: - - master - paths: - - '.github/workflows/backend*' - - 'backend/**' - - '!frontend/**' - pull_request: - paths: - - '.github/workflows/backend*' - - 'backend/**' - - '!frontend/**' - -env: - CARGO_TERM_COLOR: always - -defaults: - run: - working-directory: ./backend - -jobs: - check: - name: Check Code - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Rust Cache - uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1 - with: - workspaces: backend - - - name: Build - run: cargo check --all-targets --verbose diff --git a/.github/workflows/backend_docs.yml b/.github/workflows/backend_docs.yml deleted file mode 100644 index b09b7bc69..000000000 --- a/.github/workflows/backend_docs.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Backend CI - cargo doc - -on: - push: - branches: - - master - paths: - - '.github/workflows/backend*' - - 'backend/**' - - '!frontend/**' - pull_request: - paths: - - '.github/workflows/backend*' - - 'backend/**' - - '!frontend/**' - -env: - CARGO_TERM_COLOR: always - -defaults: - run: - working-directory: ./backend - -jobs: - docs: - name: Check Documentation - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Rust Cache - uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1 - with: - workspaces: backend - - - name: Check internal documentation links - run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items diff --git a/.github/workflows/backend_fmt.yml b/.github/workflows/backend_fmt.yml deleted file mode 100644 index 8320a524e..000000000 --- a/.github/workflows/backend_fmt.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Backend CI - cargo fmt - -on: - push: - branches: - - master - paths: - - '.github/workflows/backend*' - - 'backend/**' - - '!frontend/**' - pull_request: - paths: - - '.github/workflows/backend*' - - 'backend/**' - - '!frontend/**' - -env: - CARGO_TERM_COLOR: always - -defaults: - run: - working-directory: ./backend - -jobs: - fmt: - name: Run rustfmt - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: clippy, rustfmt - - - name: Cargo fmt - run: cargo fmt --verbose --all -- --check diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml deleted file mode 100644 index c1d68604d..000000000 --- a/.github/workflows/backend_tests.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Backend CI - cargo test - -on: - push: - branches: - - master - paths: - - '.github/workflows/backend*' - - 'backend/**' - - '!frontend/**' - pull_request: - paths: - - '.github/workflows/backend*' - - 'backend/**' - - '!frontend/**' - -env: - CARGO_TERM_COLOR: always - -defaults: - run: - working-directory: ./backend - -jobs: - tests: - name: Run tests - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Rust Cache - uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1 - with: - workspaces: backend - - - name: Cargo test - run: cargo test --verbose --jobs 1 diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..23cd5325b --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,73 @@ +name: Docker Build +# Workflow checks that docker build works + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + IMAGE_NAME: parity/substrate-telemetry + +jobs: + set-variables: + name: Set variables + 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} == "main" ]] + then + echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT + else + echo "VERSION=${REF_SLUG}" >> $GITHUB_OUTPUT + fi + echo "set VERSION=${VERSION}" + + build_backend: + name: Build backend docker image + runs-on: ubuntu-latest + needs: [set-variables] + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Build and push Docker image from main + uses: docker/build-push-action@v5 + with: + context: backend + file: ./backend/Dockerfile + push: false + tags: | + ${{ env.IMAGE_NAME }}-backend:${{ env.VERSION }} + + build_frontend: + name: Build frontend docker image + runs-on: ubuntu-latest + needs: [set-variables] + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Build and push Docker image from main + uses: docker/build-push-action@v5 + with: + context: frontend + file: ./frontend/Dockerfile + push: false + tags: | + ${{ env.IMAGE_NAME }}-frontend:${{ env.VERSION }} diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 858354808..bf7766b58 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -15,6 +15,10 @@ on: - 'frontend/**' - '!backend/**' +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + defaults: run: working-directory: ./frontend @@ -28,10 +32,10 @@ jobs: node-version: [14.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/publish-deploy.yml b/.github/workflows/publish-deploy.yml new file mode 100644 index 000000000..b6dd75c5b --- /dev/null +++ b/.github/workflows/publish-deploy.yml @@ -0,0 +1,141 @@ +name: Publish and 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: + IMAGE_NAME: parity/substrate-telemetry + APP: "substrate-telemetry" + +jobs: + set-variables: + name: Set variables + 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 + echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT + else + echo "VERSION=${REF_SLUG}" >> $GITHUB_OUTPUT + fi + echo "set VERSION=${VERSION}" + + build_backend: + name: Build backend docker image + runs-on: ubuntu-latest + needs: [set-variables] + environment: master_n_tags + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and push Docker image from master + uses: docker/build-push-action@v5 + with: + context: backend + file: ./backend/Dockerfile + push: true + tags: | + ${{ env.IMAGE_NAME }}-backend:${{ env.VERSION }} + + build_frontend: + name: Build frontend docker image + runs-on: ubuntu-latest + needs: [set-variables] + environment: master_n_tags + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and push Docker image from master + uses: docker/build-push-action@v5 + with: + context: frontend + file: ./frontend/Dockerfile + push: true + tags: | + ${{ env.IMAGE_NAME }}-frontend:${{ env.VERSION }} + + deploy-stg: + name: Deploy Staging + runs-on: ubuntu-latest + needs: [set-variables, build_backend, build_frontend] + 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: "frontend,backend" + argocd_additional_args: "-p substrate-telemetry.image.backend.repository=docker.io/parity/substrate-telemetry-backend -p substrate-telemetry.image.frontend.repository=docker.io/parity/substrate-telemetry-frontend" + 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] + environment: parity-prod + # Deploy only if the tag is v* + if: startsWith(github.ref, 'refs/tags/v') + 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: "frontend,backend" + argocd_additional_args: "-p substrate-telemetry.image.backend.repository=docker.io/parity/substrate-telemetry-backend -p substrate-telemetry.image.frontend.repository=docker.io/parity/substrate-telemetry-frontend" + argocd_server: ${{ env.ARGOCD_SERVER }} + teleport_token: ${{ env.APP }} + teleport_app_name: "argocd-prod" + argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} diff --git a/.gitignore b/.gitignore index e7e1f36fe..1d03a2083 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # See https://help.github.com/ignore-files/ for more about ignoring files. htdocs - +.idea backend/target # dependencies diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 2a6534ddc..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,212 +0,0 @@ -# Gitlab-CI Workflow -# stages: -# build: -# - Runs on commits on master or tags that match the pattern "v[0-9]+\.[0-9]+.*$". (e.g. 1.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: - # Build Variables (Mandatory) - CONTAINER_REPO: "" - DOCKERFILE_DIRECTORY: "" - - # Deploy Variables (Mandatory) - HELM_NAMESPACE: "substrate-telemetry" - HELM_RELEASE_NAME: "substrate-telemetry" - HELM_CHART: "parity/substrate-telemetry" - - # Deploy Variables (Optional) - HELM_REPO_NAME: "parity" - HELM_REPO_URL: "https://paritytech.github.io/helm-charts/" - HELM_CONFIGMAP_NAME: "helm-custom-values" - HELM_CONFIGMAP_KEYNAME: "values-parity.yaml" - - # Manual Variables (Optional) - ## Could be used in the webconsole when triggering the pipeline manually - ## DO NOT SET THEM IN THIS FILE!! They've been mentioned here only for documentation purposes! - FORCE_DEPLOY: "" # boolean: true or false - triggers the deploy-production stage - FORCE_DOCKER_TAG: "" # choose an existing docker tag to be deployed (e.g. v1.2.3) - -default: - before_script: - - |- - echo defining DOCKER_IMAGE_TAG variable - if [[ $FORCE_DOCKER_TAG ]]; then - export DOCKER_IMAGE_TAG="${FORCE_DOCKER_TAG}" - elif [[ $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 - retry: - max: 2 - when: - - runner_system_failure - - unknown_failure - - api_failure - -stages: - - build - - deploy-commit-to-staging - - deploy-master-to-staging - - deploy-production - - -# Pipeline Job Templates: -.dockerize: &dockerize - stage: build - image: quay.io/buildah/stable:v1.27 - script: - - |- - echo building "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" - if [[ $BUILD_LATEST_IMAGE ]]; then - buildah bud \ - --format=docker \ - --tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" \ - --tag "$CONTAINER_REPO:latest" "$DOCKERFILE_DIRECTORY" - else - buildah bud \ - --format=docker \ - --tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" "$DOCKERFILE_DIRECTORY" - fi - - 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 push --format=v2s2 "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" - buildah push --format=v2s2 "$CONTAINER_REPO:latest" - else - buildah push --format=v2s2 "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" - fi - rules: - - if: '$FORCE_DOCKER_TAG' - when: never - - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1 - when: always - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - when: always - tags: - - kubernetes-parity-build - -.publish-docker-image-description: - stage: build - image: paritytech/dockerhub-description - before_script: - - echo - variables: - DOCKERHUB_REPOSITORY: parity/substrate-telemetry-$PRODUCT - DOCKER_USERNAME: $Docker_Hub_User_Parity - DOCKER_PASSWORD: $Docker_Hub_Pass_Parity - README_FILEPATH: $CI_PROJECT_DIR/$PRODUCT/Dockerfile.README.md - rules: - - if: $CI_COMMIT_REF_NAME == "master" - changes: - - $PRODUCT/Dockerfile.README.md - script: - - cd / && sh entrypoint.sh - tags: - - kubernetes-parity-build - -.deploy: &deploy - image: paritytech/kubetools:3.5.3 - script: - - |- - echo generating an empty custom-values.yaml file - touch custom-values.yaml - - |- - echo fetching the custom values file from the configmap if HELM_CONFIGMAP_NAME is specified - if [[ $HELM_CONFIGMAP_NAME ]]; then - # escape dot characters - HELM_CONFIGMAP_KEYNAME=`echo $HELM_CONFIGMAP_KEYNAME | sed 's/\./\\\./g'` - kubectl get cm $HELM_CONFIGMAP_NAME -n $HELM_NAMESPACE -o jsonpath="{.data.$HELM_CONFIGMAP_KEYNAME}" \ - > custom-values.yaml - fi - - |- - echo adding the helm repository if HELM_REPO_URL is specified - if [[ $HELM_REPO_URL ]]; then - helm repo add $HELM_REPO_NAME $HELM_REPO_URL - helm repo update - fi - - echo installing the helm chart - - helm upgrade - --install - --atomic - --timeout 300s - --namespace $HELM_NAMESPACE - --values custom-values.yaml - --set image.backend.repository="${CONTAINER_REPO_BACKEND}" - --set image.backend.tag="${DOCKER_IMAGE_TAG}" - --set image.frontend.repository="${CONTAINER_REPO_FRONTEND}" - --set image.frontend.tag="${DOCKER_IMAGE_TAG}" - ${HELM_RELEASE_NAME} ${HELM_CHART} - tags: - - kubernetes-parity-build - - -# Pipeline Jobs: -build-backend: - variables: - CONTAINER_REPO: "docker.io/parity/substrate-telemetry-backend" - DOCKERFILE_DIRECTORY: "./backend/" - <<: *dockerize - -build-frontend: - variables: - CONTAINER_REPO: "docker.io/parity/substrate-telemetry-frontend" - DOCKERFILE_DIRECTORY: "./frontend/" - <<: *dockerize - -publish-backend-docker-image-description: - extends: .publish-docker-image-description - variables: - PRODUCT: backend - SHORT_DESCRIPTION: "substrate-backend Docker Image." - -publish-frontend-docker-image-description: - extends: .publish-docker-image-description - variables: - PRODUCT: frontend - SHORT_DESCRIPTION: "substrate-frontend Docker Image." - -# Manually build the docker images and deploy some commit to staging. -deploy-commit-to-staging: - variables: - CONTAINER_REPO_BACKEND: "docker.io/parity/substrate-telemetry-backend" - CONTAINER_REPO_FRONTEND: "docker.io/parity/substrate-telemetry-frontend" - stage: deploy-commit-to-staging - <<: *deploy - environment: - name: parity-stg - when: manual - -# Autoamtically deploy `master` branch or tag like `v1.0` to staging -deploy-master-to-staging: - variables: - CONTAINER_REPO_BACKEND: "docker.io/parity/substrate-telemetry-backend" - CONTAINER_REPO_FRONTEND: "docker.io/parity/substrate-telemetry-frontend" - stage: deploy-master-to-staging - <<: *deploy - environment: - name: parity-stg - rules: - - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1 - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - -# Manually deploy a tag like `v1.0` to production -deploy-production: - variables: - CONTAINER_REPO_BACKEND: "docker.io/parity/substrate-telemetry-backend" - CONTAINER_REPO_FRONTEND: "docker.io/parity/substrate-telemetry-frontend" - stage: deploy-production - <<: *deploy - environment: - name: parity-prod - rules: - - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1 - when: manual - - if: '$FORCE_DEPLOY == "true"' - when: manual diff --git a/README.md b/README.md index 7bcb8d429..5f895b48e 100644 --- a/README.md +++ b/README.md @@ -193,9 +193,9 @@ This section covers the internal deployment of Substrate Telemetry to our stagin Every time new code is merged to `master`, a new version of telemetry will be automatically built and deployed to our staging environment, so there is nothing that you need to do. Roughly what will happen is: -- An image tag will be generated that looks like `$CI_COMMIT_SHORT_SHA-beta`, for example `224b1fae-beta`. +- An image tag will be generated that looks like `master-$CI_COMMIT_SHORT_SHA`, for example `master-224b1fae`. - Docker images for the frontend and backend will be pushed to the docker repo (see https://hub.docker.com/r/parity/substrate-telemetry-backend/tags?page=1&ordering=last_updated and https://hub.docker.com/r/parity/substrate-telemetry-frontend/tags?page=1&ordering=last_updated). -- A deployment to the staging environment will be performed using these images. Go to https://gitlab.parity.io/parity/substrate-telemetry/-/pipelines to inspect the progress of such deployments. +- A deployment to the staging environment will be performed using these images. Go to https://github.com/paritytech/substrate-telemetry/actions to inspect the progress of such deployments. ### Deployment to live @@ -205,18 +205,19 @@ Once we're happy with things in staging, we can do a deployment to live as follo 2. Tag the commit on `master` that you'd like to deploy with the form `v1.0-a1b2c3d`. - The version number (`1.0` here) should just be incremented from whatever the latest version found using `git tag` is. We don't use semantic versioning or anything like that; this is just a dumb "increment version number" approach so that we can see clearly what we've deployed to live and in what order. - The suffix is a short git commit hash (which can be generated with `git rev-parse --short HEAD`), just so that it's really easy to relate the built docker images back to the corresponding code. -3. Pushing the tag (eg `git push origin v1.0-a1b2c3d`) will kick off the deployment process, which in this case will also lead to new docker images being built. You can view the progress at https://gitlab.parity.io/parity/substrate-telemetry/-/pipelines. +3. Pushing the tag (eg `git push origin v1.0-a1b2c3d`) will kick off the deployment process, which in this case will also lead to new docker images being built. You can view the progress at https://github.com/paritytech/substrate-telemetry/actions. + +> [!WARNING] +> After the tag is pushed the deploy will be done to both environments (staging and production) automatically. + 4. Once a deployment to staging has been successful, run whatever tests you need against the staging deployment to convince yourself that you're happy with it. -5. Visit the CI/CD pipelines page again (URl above) and click the "play" button on the "Deploy-production" stage to perform the deployment to live. -6. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/. +5. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/. ### Rolling back to a previous deployment If something goes wrong running the above, we can roll back the deployment to live as follows. -1. Decide what image tag you'd like to roll back to. Go to https://hub.docker.com/r/parity/substrate-telemetry-backend/tags?page=1&ordering=last_updated and have a look at the available tags (eg `v1.0-a1b2c3d`) to select one you'd like. You can cross reference this with the tags available using `git tag` in the repository to help see which tags correspond to which code changes. -2. Navigate to https://gitlab.parity.io/parity/substrate-telemetry/-/pipelines/new. -3. Add a variable called `FORCE_DEPLOY` with the value `true`. -4. Add a variable called `FORCE_DOCKER_TAG` with a value corresponding to the tag you want to deploy, eg `v1.0-a1b2c3d`. Images must exist already for this tag. -5. Hit 'Run Pipeline'. As above, a deployment to staging will be carried out, and if you're happy with that, you can hit the "play" button on the "Deploy-production" stage to perform the deployment to live. -6. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/. +1. Decide what image tag you'd like to roll back to. Push the tag to the commit you want to revert to. +2. Navigate to https://github.com/paritytech/substrate-telemetry/actions and check that the pipeline is successful. +3. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/. +4. In case of issues contact devops team. diff --git a/backend/.dockerignore b/backend/.dockerignore index af65baafb..0fb67fbfe 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -1,3 +1,4 @@ target *.Dockerfile .git +.idea \ No newline at end of file diff --git a/backend/Cargo.lock b/backend/Cargo.lock index a7eb7d824..12547a77d 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -626,9 +626,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" dependencies = [ "bytes", "fnv", @@ -1040,9 +1040,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.48" +version = "0.10.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518915b97df115dd36109bfa429a48b8f737bd05508cf9588977b599648926d2" +checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" dependencies = [ "bitflags", "cfg-if", @@ -1072,11 +1072,10 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.83" +version = "0.9.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666416d899cf077260dac8698d60a60b435a46d57e82acb1be3d0dad87284e5b" +checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" dependencies = [ - "autocfg", "cc", "libc", "pkg-config", @@ -2214,9 +2213,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.0" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" dependencies = [ "ring", "untrusted", diff --git a/backend/common/src/rolling_total.rs b/backend/common/src/rolling_total.rs index b9caf9f5a..3fc7bce49 100644 --- a/backend/common/src/rolling_total.rs +++ b/backend/common/src/rolling_total.rs @@ -50,14 +50,14 @@ impl RollingTotalBuilder { /// Set the size of the window of time that we'll look back on /// to sum up values over to give us the current total. The size - /// is set as a multiple of the granularity; a granulatiry of 1s + /// is set as a multiple of the granularity; a granularity of 1s /// and a size of 10 means the window size will be 10 seconds. pub fn window_size_multiple(mut self, val: usize) -> Self { self.window_size_multiple = val; self } - /// What is the granulatiry of our windows of time. For example, a + /// What is the granularity of our windows of time. For example, a /// granularity of 5 seconds means that every 5 seconds the window /// that we look at shifts forward to the next 5 seconds worth of data. /// A larger granularity is more efficient but less accurate than a @@ -69,7 +69,7 @@ impl RollingTotalBuilder { } impl RollingTotalBuilder