Commit 52aed8e7 authored by Marek Veselý's avatar Marek Veselý
Browse files

Resolve "Check if backend is compatible"

parent 5cda17d8
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -105,23 +105,27 @@ create-tag:
    - if: $CI_COMMIT_TAG
      when: never
  before_script:
    - apt-get update && apt-get install -y jq
    - git config user.email "$GITLAB_USER_EMAIL"
    - git config user.name "$GITLAB_USER_NAME"
  script:
    - old_version=$(sed -n "s/^export const version = '\(.*\)'/\1/p" frontend/src/constants.ts)
    - old_version=$(jq -r '.version' package.json)
    - new_version=$(python tagging.py "$old_version" "$VERSION_TYPE")
    - >
      if [[ $? -ne 0 ]]; then
        exit 1
      fi
    - sed "s/^export const version = .*/export const version = '$new_version'/" frontend/src/constants.ts --in-place
    - git add frontend/src/constants.ts
    - |
      for file in ./shared/package.json ./frontend/package.json ./package.json ./graphql/package.json ./tests/package.json ./codegen/package.json; do
        jq --arg new_version "$new_version" '.version = $new_version' "$file" > tmp.$$.json && mv tmp.$$.json "$file"
        git add "$file"
      done
    - git commit -m "update version and create new tag"
    - git tag -f "$new_version" -m "frontend version $new_version"
    - git tag -f "v$new_version" -m "frontend version $new_version"
    # push the new commit
    - git push https://tagger:$TAGGER_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH HEAD:$CI_COMMIT_REF_NAME -o ci.skip
    # push the newly created tag, must be separated because the CI repo contains old deleted tags
    - git push https://tagger:$TAGGER_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH refs/tags/$new_version -o ci.skip
    - git push https://tagger:$TAGGER_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH refs/tags/v$new_version -o ci.skip

include:
  - template: Security/Dependency-Scanning.gitlab-ci.yml
+6 −2
Original line number Diff line number Diff line
@@ -113,8 +113,12 @@ sh update.sh
## How to update the backend version

1. Update the [backend Git submodule](#sub-repositories) to the desired commit
2. [Update GraphQL calls using Codegen](#how-to-update-graphql-calls-using-codegen)
3. Make sure to address all changes and new features
2. Update the version fields in package.json files to match the backend version

   - either manually or through the create-tag [CI/CD pipeline](./.gitlab-ci.yml)

3. [Update GraphQL calls using Codegen](#how-to-update-graphql-calls-using-codegen)
4. Make sure to address all changes and new features

## How to test the Monorepo

+1 −1
Original line number Diff line number Diff line
{
  "name": "@inject/codegen",
  "version": "0.3.0",
  "version": "2.8.0",
  "description": "GraphQL API Codegen Setup for the Inject Backend",
  "main": "index.js",
  "license": "MIT",
+1 −1
Original line number Diff line number Diff line
{
  "name": "@inject/frontend",
  "version": "0.3.0",
  "version": "2.8.0",
  "description": "Main wrapper for rendering INJECT Frontend",
  "main": "index.js",
  "license": "MIT",
+16 −15
Original line number Diff line number Diff line
import { version } from '@/constants'
import { Callout, Spinner, SpinnerSize } from '@blueprintjs/core'
import { css } from '@emotion/css'
import { useHost } from '@inject/graphql/connection/host'
import { httpHello } from '@inject/shared/config'
import { useEffect, useState } from 'react'
import useBackendVersion from '@inject/graphql/utils/useBackendVersion'
import { version } from '../../../package.json'

const spinner = css`
  /* causes ever-changing overflows without the padding */
@@ -12,25 +10,28 @@ const spinner = css`
  display: inline-block;
`

const GitVersion = () => {
  const [data, setData] = useState<null | string>(null)
  const host = useHost()
const callout = css`
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  useEffect(() => {
    fetch(httpHello(host || '')).then(async e => {
      setData(JSON.parse(await e.text())['version'])
    })
  }, [setData, host])
  p {
    margin: 0;
  }
`

const GitVersion = () => {
  const backendVersion = useBackendVersion()

  return (
    <Callout intent='none'>
    <Callout intent='none' className={callout}>
      <p>
        Frontend version: <code>{version}</code>
      </p>
      <p>
        Backend version:{' '}
        {data ? (
          <code>{data}</code>
        {backendVersion ? (
          <code>{backendVersion}</code>
        ) : (
          <Spinner size={SpinnerSize.SMALL} className={spinner} />
        )}
Loading