diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 000000000..edecda542 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,48 @@ +name: Build +on: + push: + branches: [ main, stable, stage, dev** ] + tags: + - "*" + pull_request: +env: + COV_NODE_VERSION: 18 + BRANCH: ${{ github.base_ref }} + +jobs: + Integration-checks: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x] + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: yarn + - name: Node.js modules cache + uses: actions/cache@v3 + id: modules-cache + with: + path: ${{ github.workspace }}/node_modules + key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.node-version }}-modules + - name: Install Node.js packages + if: ${{ steps.modules-cache.outputs.cache-hit != 'true' }} + run: yarn install + - name: Lint and test + run: yarn test + - name: Code coverage + if: ${{ success() && contains(matrix.node-version, env.COV_NODE_VERSION) }} + uses: codecov/codecov-action@v3.1.4 + - name: Confirm preview integration + if: ${{ success() }} + run: yarn build + env: + BETA: true + - name: Confirm stable integration + if: ${{ success() }} + run: yarn build diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml deleted file mode 100644 index 50ff5e64b..000000000 --- a/.github/workflows/pull_request.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Pull request -on: - pull_request: - branches: [ master, main, prod, stable, stage, test**, qa**, dev**, ci** ] -env: - BRANCH: ${{ github.base_ref }} - -jobs: - Integration-checks: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x, 20.x] - steps: - - uses: actions/checkout@v4 - - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: yarn - - name: Node.js modules cache - uses: actions/cache@v3 - id: modules-cache - with: - path: ${{ github.workspace }}/node_modules - key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.node-version }}-modules - - name: Install Node.js packages - if: ${{ steps.modules-cache.outputs.cache-hit != 'true' }} - run: yarn install - - name: Lint and test - uses: actions/github-script@v6 - with: - script: | - const { execSync } = require('child_process'); - try { - console.log(`${execSync('yarn test', { stdio: 'pipe' })}`); - } catch ({ stdout, stderr }) { - core.setFailed(`${stdout}\n${stderr}`); - } - - name: Code coverage - if: ${{ success() }} - uses: codecov/codecov-action@v3.1.4 - - name: Confirm beta integration - if: ${{ success() }} - uses: actions/github-script@v6 - with: - script: | - const { execSync } = require('child_process'); - try { - console.log(`${execSync('yarn build', { stdio: 'pipe' })}`); - } catch ({ stdout, stderr }) { - core.setFailed(`${stdout}\n${stderr}`); - } - env: - BUILD_STAGE: Beta - - name: Confirm stable integration - if: ${{ success() }} - uses: actions/github-script@v6 - with: - script: | - const { execSync } = require('child_process'); - try { - console.log(`${execSync('yarn build', { stdio: 'pipe' })}`); - } catch ({ stdout, stderr }) { - core.setFailed(`${stdout}\n${stderr}`); - } - env: - BUILD_STAGE: Stable diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3b9dfde61..000000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: node_js -dist: jammy -notifications: - email: false - slack: - - rooms: - - secure: juuizlfiQolXbqy4L2nfODB1K8xiSGvUrzsT3XeXIsQqX7yCYVvnRUssKLbqgLM9m85kgXJk1ef0qwjJoliNqGcrALTZLHPTkxWwTnV7tPEVS/4uQPSyy+DDHDwrTzCrF3qhCqyKJ6vB18z22qm3qLgStmNj4p1ZLznsdJR/u7U3spJ+WLL70QSNHCQy/5QjRDDiR3oqWdXjhVcUCeV+v/2CtfqK3dqYtzCL/b7z8lm/YbV6w1Rd8mwzTgLstbzjrvR/gq2IPALzzJTq1S8lXtV7ZtbYz4bjB8RNCRZFJrjBUH4CqD1oUskit4RRe+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-jobs: - include: - - stage: Test - if: NOT branch =~ /^(dependabot\/)/ - before_script: yarn global add codecov - script: yarn test - after_success: codecov - - stage: Beta Deploy - if: branch IN (stable, main) OR tag IS present - script: yarn build && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh - | bash -s - - stage: Stable Deploy - if: branch IN (stable) OR tag IS present - script: yarn build && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh - | bash -s -env: - global: - - REPO="git@github.com:RedHatInsights/curiosity-frontend-build" - - REPO_DIR="curiosity-frontend-build" - - BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH} - - IS_PR=${TRAVIS_PULL_REQUEST} - - BUILD_STAGE="${TRAVIS_BUILD_STAGE_NAME}" - - NODE_OPTIONS="--max-old-space-size=4096 --max_old_space_size=4096" - - APP_BUILD_DIR="dist" diff --git a/.travis/custom_release.sh b/.travis/custom_release.sh deleted file mode 100755 index 8452702f8..000000000 --- a/.travis/custom_release.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# -# Release a branch. APP_BUILD_DIR should be updated at the Travis configuration level. -release() -{ - local DEPLOY_BRANCH=$1 - local BUILD_DIR=$APP_BUILD_DIR - - printf "${YELLOW}PUSHING ${DEPLOY_BRANCH}${NOCOLOR}\n" - rm -rf "./${BUILD_DIR}/.git" - .travis/release.sh "${DEPLOY_BRANCH}" - printf "${GREEN}COMPLETED ${DEPLOY_BRANCH}${NOCOLOR}\n" -} -# -# -# Dev release when pushing into "dev" and "main"/"master" branches. Beta/stable condition for Travis build stage name. -# -releaseDev() -{ - if [[ "${TRAVIS_BRANCH}" = "main" ]] && [[ $TRAVIS_BUILD_STAGE_NAME == *"Beta"* ]]; then - release "ci-beta" - release "qa-beta" - fi - - if [[ "${TRAVIS_BRANCH}" = "stable" ]] && [[ $TRAVIS_BUILD_STAGE_NAME != *"Beta"* ]]; then - release "ci-stable" - release "qa-stable" - fi -} -# -# -# Prod release for "main" based on commit message, and tags. Sync related lower environments. -# -releaseProd() -{ - local UPDATED_UI_VERSION="$(node -p 'require(`./package.json`).version')"; - - if [[ "${TRAVIS_COMMIT_MESSAGE}" = *"chore(release):"* ]]; then - if [[ "${TRAVIS_BRANCH}" = "v${UPDATED_UI_VERSION}" ]] && [[ $TRAVIS_BUILD_STAGE_NAME != *"Beta"* ]]; then - release "ci-stable" - release "qa-stable" - release "prod-beta" - release "prod-stable" - fi - elif [[ "${TRAVIS_BRANCH}" = *"-alpha"* || "${TRAVIS_BRANCH}" = *"-beta"* || "${TRAVIS_BRANCH}" = *"-rc."* ]] && [[ $TRAVIS_BUILD_STAGE_NAME == *"Beta"* ]]; then - release "prod-beta" - fi - -} -# -# -# main() -# -{ - set -e - set -x - - BLUE="\e[34m" - RED="\e[31m" - GREEN="\e[32m" - YELLOW="\e[33m" - NOCOLOR="\e[39m" - - releaseDev - releaseProd -} diff --git a/.travis/deploy_key.enc b/.travis/deploy_key.enc deleted file mode 100644 index 2229a45a8..000000000 Binary files a/.travis/deploy_key.enc and /dev/null differ diff --git a/README.md b/README.md index 90956d62d..19c9d947f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Curiosity Frontend -[![Build Status](https://app.travis-ci.com/RedHatInsights/curiosity-frontend.svg?branch=main)](https://app.travis-ci.com/RedHatInsights/curiosity-frontend) +[![Build](https://github.com/RedHatInsights/curiosity-frontend/actions/workflows/integration.yml/badge.svg?branch=main)](https://github.com/RedHatInsights/curiosity-frontend/actions/workflows/integration.yml) [![codecov](https://codecov.io/gh/RedHatInsights/curiosity-frontend/branch/main/graph/badge.svg)](https://codecov.io/gh/RedHatInsights/curiosity-frontend) [![License](https://img.shields.io/github/license/RedHatInsights/curiosity-frontend.svg)](https://github.com/RedHatInsights/curiosity-frontend/blob/main/LICENSE) diff --git a/scripts/pre.sh b/scripts/pre.sh index ad87c0540..6028906cc 100644 --- a/scripts/pre.sh +++ b/scripts/pre.sh @@ -6,24 +6,22 @@ deployPaths() { local DEPLOY_BRANCH=$1 - local DEPLOY_BUILD_STAGE=$2 - local CONTAINER_BUILD_ENV=$3 + local CONTAINER_BUILD_ENV=$2 DEPLOY_PATH_PREFIX="" + DEPLOY_STAGE="Stable" - # Note: allow Container build, fallback to Travis build + # Note: allow Container build if [[ $CONTAINER_BUILD_ENV == "true" ]]; then + DEPLOY_STAGE="Preview" DEPLOY_PATH_PREFIX=/preview DEPLOY_PATH_LINK_PREFIX=/preview - elif [[ $DEPLOY_BUILD_STAGE == *"Beta"* ]]; then - DEPLOY_PATH_PREFIX=/beta - DEPLOY_PATH_LINK_PREFIX=/preview fi echo UI_DEPLOY_PATH_PREFIX="$DEPLOY_PATH_PREFIX" >> ./.env.production.local echo UI_DEPLOY_PATH_LINK_PREFIX="$DEPLOY_PATH_LINK_PREFIX" >> ./.env.production.local - echo "\"${DEPLOY_BUILD_STAGE}\" build stage config for branch \"${DEPLOY_BRANCH}\"..." + echo "\"${DEPLOY_STAGE}\" build stage config for branch \"${DEPLOY_BRANCH}\"..." printf "Deploy path prefix ... ${GREEN}UI_DEPLOY_PATH_PREFIX=$DEPLOY_PATH_PREFIX${NOCOLOR}\n" } # @@ -62,8 +60,8 @@ clean() clean version - # Note: See .travis.yml globals, GitHub actions, and Container Build environment variables - # - Travis, GitHub actions: BRANCH, BUILD_STAGE + # Note: See GitHub actions, and Container Build environment variables + # - GitHub actions: BRANCH, BETA # - Container Build: BETA - deployPaths "${BRANCH:-local}" "${BUILD_STAGE:-Local Deploy}" "${BETA:-local env}" + deployPaths "${BRANCH:-local}" "${BETA:-local env}" }