Skip to content

Commit

Permalink
Merge pull request #2082 from Hyperkid123/nx
Browse files Browse the repository at this point in the history
chore: setup gh actions ci workflow
  • Loading branch information
Hyperkid123 authored Oct 25, 2024
2 parents e6a128d + 71eaf72 commit de4c985
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 25 deletions.
16 changes: 16 additions & 0 deletions .github/actions/cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Node modules cache
description: Retrieve and cache project node_modules
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# cache node modules for all jobs to use
- uses: actions/cache@v4
id: node_modules-cache
with:
path: |
**/node_modules
key: install-cache-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
11 changes: 11 additions & 0 deletions .github/actions/cypress-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Cypress runner cache
description: Retrieve and cache the cypress runner
runs:
using: "composite"
steps:
# cache cypress runner
- uses: actions/cache@v4
id: cypress-cache
with:
path: ~/.cache/Cypress
key: cypress-runner-cache-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
86 changes: 86 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Frontend components CI pipeline
on:
pull_request:
branches:
- master
- nx
push:
branches:
- master
- nx

jobs:
install:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v4
- uses: './.github/actions/cache'
- uses: './.github/actions/cypress-cache'
- name: Install dependencies
run: npm i
build:
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- uses: nrwl/nx-set-shas@v4
- uses: './.github/actions/cache'
- name: Build
run: npm run build
unit-test:
runs-on: ubuntu-latest
needs: [install]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- uses: nrwl/nx-set-shas@v4
- uses: './.github/actions/cache'
- name: Run unit tests
run: npm run test:unit
component-test:
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v4
- uses: './.github/actions/cache'
- uses: './.github/actions/cypress-cache'
- name: Install deps
shell: bash
run: npm i
- name: Run component tests
uses: cypress-io/github-action@v6
with:
command: npx nx affected -t test:component --exclude=demo --configuration=ci --parallel=1
lint:
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v4
- uses: './.github/actions/cache'
- name: Lint
run: npx nx affected -t test:lint --exclude=demo
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"cache": true
}
},
"defaultBase": "master",
"defaultBase": "origin/nx",
"plugins": [
{
"plugin": "@nx/eslint/plugin",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"lint": "nx run-many -t lint --exclude=@redhat-cloud-services/frontend-components-pdf-generator,@redhat-cloud-services/frontend-components-charts",
"serve:demo": "nx run demo:serve",
"test:unit": "nx run-many -t test:unit --exclude=demo",
"test:component": "nx run-many -t test:component --exclude=demo ----parallel=1"
"test:component": "nx run-many -t test:component --exclude=demo --parallel=1"
},
"description": "Components for Red Hat Cloud Services",
"repository": {
Expand Down
6 changes: 5 additions & 1 deletion packages/components/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
"types": ["jest", "node"],
"paths": {
"@redhat-cloud-services/frontend-components-utilities": ["packages/utils/src"],
"@redhat-cloud-services/frontend-components-utilities/*": ["packages/utils/src/*"]
}
},
"include": [
"jest.config.ts",
Expand Down
8 changes: 7 additions & 1 deletion packages/notifications/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
"types": ["jest", "node"],
"paths": {
"@redhat-cloud-services/frontend-components-utilities": ["packages/utils/src"],
"@redhat-cloud-services/frontend-components-utilities/*": ["packages/utils/src/*"],
"@redhat-cloud-services/frontend-components": ["packages/components/src"],
"@redhat-cloud-services/frontend-components/*": ["packages/components/src/*"]
}
},
"include": [
"jest.config.ts",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "es5",
"module": "commonjs",
"lib": ["es2020", "dom"],
"allowJs": false,
"allowJs": true,
"jsx": "react-jsx",
"declaration": true,
"sourceMap": true,
Expand Down

0 comments on commit de4c985

Please sign in to comment.