From eb665d92e818b3a302272a2db93f290c9cad4aaa Mon Sep 17 00:00:00 2001 From: Montse Ortega Date: Wed, 28 Feb 2024 14:04:51 +0100 Subject: [PATCH] Add new workflow actions --- .github/workflows/pull-request.yaml | 58 +++++++++++++++++++++++++++++ .github/workflows/push-to-main.yaml | 57 ++++++++++++++++++++++++++++ package.json | 2 +- src/bootstrap.ts | 8 ++-- 4 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pull-request.yaml create mode 100644 .github/workflows/push-to-main.yaml diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml new file mode 100644 index 0000000..98b9f46 --- /dev/null +++ b/.github/workflows/pull-request.yaml @@ -0,0 +1,58 @@ +name: Pull request + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + branches: + - main + - releases/* + +env: + NODE_OPTIONS: '--max-old-space-size=8192' +jobs: + preflight-check: + # Prevents running the workflow when a PR is marked as draft. + runs-on: ubuntu-latest + outputs: + skip: ${{ steps.check.outputs.skip }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check if PR is draft + id: check + run: | + if [[ "${{ github.event.pull_request.draft }}" == "true" ]]; then + skip=true + else + skip=false + fi + echo "skip=${skip}" >> $GITHUB_OUTPUT + echo "skip=${skip}" + lint-and-test: + needs: preflight-check + if: needs.preflight-check.outputs.skip == 'false' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ vars.NODEJS_VERSION }} + - run: npm install --immutable + - run: npm run lint + - run: npm run test --passWithNoTests + build: + needs: preflight-check + if: needs.preflight-check.outputs.skip == 'false' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ vars.NODEJS_VERSION }} + - run: npm install --immutable + - run: npm run build \ No newline at end of file diff --git a/.github/workflows/push-to-main.yaml b/.github/workflows/push-to-main.yaml new file mode 100644 index 0000000..08b2f43 --- /dev/null +++ b/.github/workflows/push-to-main.yaml @@ -0,0 +1,57 @@ +name: Push to main or release tag + +on: + push: + branches: + - main + tags: + - 'v*' + +env: + QUAY_ORG: quay.io/edge-infrastructure + QUAY_REPO: assisted-installer-ui + +jobs: + preflight-check: + # Prevents running the workflow when a brand-new tag points to the same commit as the main branch + runs-on: ubuntu-latest + outputs: + skip: ${{ steps.check.outputs.skip }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check if a tag points to the same commit as the main branch + id: check + run: | + if [[ "${GITHUB_REF_TYPE}" == "tag" ]] && [[ "${GITHUB_SHA}" == "$(git rev-parse origin/main)" ]]; then + skip=true + else + skip=false + fi + echo "skip=${skip}" >> $GITHUB_OUTPUT + echo "skip=${skip}" + lint-and-test: + needs: preflight-check + if: needs.preflight-check.outputs.skip == 'false' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ vars.NODEJS_VERSION }} + - run: npm install --immutable + - run: npm run lint + - run: npm run test --passWithNoTests + build: + needs: preflight-check + if: needs.preflight-check.outputs.skip == 'false' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ vars.NODEJS_VERSION }} + - run: npm install --immutable + - run: npm run build \ No newline at end of file diff --git a/package.json b/package.json index 79260db..1eea801 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "patch:hosts": "fec patch-etc-hosts", "start": "HOT=true fec dev --clouddotEnv=stage --uiEnv=stable", "start:federated": "fec static", - "test": "TZ=UTC jest --verbose --no-cache", + "test": "TZ=UTC jest --verbose --no-cache --passWithNoTests", "postinstall": "ts-patch install && rimraf .cache", "verify": "npm-run-all build lint test", "prettier": "prettier --write src" diff --git a/src/bootstrap.ts b/src/bootstrap.ts index 62d3971..67ad9a7 100644 --- a/src/bootstrap.ts +++ b/src/bootstrap.ts @@ -1,12 +1,10 @@ import React from 'react'; -import { render } from 'react-dom'; +import { createRoot } from 'react-dom/client'; import RootApp from './components/RootApp'; function bootstrap() { - const rootElement = document.getElementById('root'); - render(React.createElement(RootApp), rootElement, () => - rootElement?.setAttribute('data-ouia-safe', 'true'), - ); + const root = createRoot(document.getElementById('root') as HTMLElement); + root.render(React.createElement(RootApp)); } bootstrap();