Skip to content

Commit

Permalink
Merge pull request #11 from fhlavac/cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
fhlavac authored Apr 5, 2024
2 parents e5b10b9 + f7ad7e3 commit f8b4bde
Show file tree
Hide file tree
Showing 30 changed files with 2,161 additions and 104 deletions.
120 changes: 100 additions & 20 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ jobs:
env:
GH_PR_NUM: ${{ github.event.number }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: |
if [[ ! -z "${GH_PR_NUM}" ]]; then
echo "Checking out PR"
git fetch origin pull/$GH_PR_NUM/head:tmp
git checkout tmp
fi
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/cache@v2
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Cache npm deps
with:
Expand All @@ -27,7 +27,7 @@ jobs:
key: ${{ runner.os }}-npm-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- run: npm install --frozen-lockfile
if: steps.npm-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
- uses: actions/cache@v4
id: dist
name: Cache dist
with:
Expand All @@ -43,17 +43,17 @@ jobs:
GH_PR_NUM: ${{ github.event.number }}
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: |
if [[ ! -z "${GH_PR_NUM}" ]]; then
echo "Checking out PR"
git fetch origin pull/$GH_PR_NUM/head:tmp
git checkout tmp
fi
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/cache@v2
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Cache npm deps
with:
Expand All @@ -63,7 +63,7 @@ jobs:
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- run: npm install --frozen-lockfile
if: steps.npm-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
- uses: actions/cache@v4
id: lint-cache
name: Load lint cache
with:
Expand All @@ -79,18 +79,18 @@ jobs:
GH_PR_NUM: ${{ github.event.number }}
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
# Yes, we really want to checkout the PR
- run: |
if [[ ! -z "${GH_PR_NUM}" ]]; then
echo "Checking out PR"
git fetch origin pull/$GH_PR_NUM/head:tmp
git checkout tmp
fi
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/cache@v2
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Cache npm deps
with:
Expand All @@ -101,7 +101,7 @@ jobs:
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- run: npm install --frozen-lockfile
if: steps.npm-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
- uses: actions/cache@v4
id: dist
name: Cache dist
with:
Expand All @@ -120,18 +120,18 @@ jobs:
GH_PR_NUM: ${{ github.event.number }}
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
# Yes, we really want to checkout the PR
- run: |
if [[ ! -z "${GH_PR_NUM}" ]]; then
echo "Checking out PR"
git fetch origin pull/$GH_PR_NUM/head:tmp
git checkout tmp
fi
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/cache@v2
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Cache npm deps
with:
Expand All @@ -142,7 +142,7 @@ jobs:
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- run: npm install --frozen-lockfile
if: steps.npm-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
- uses: actions/cache@v4
id: dist
name: Cache dist
with:
Expand All @@ -157,3 +157,83 @@ jobs:
run: npm run build:docs
- name: A11y tests
run: npm run serve:docs & npm run test:a11y
test_component:
runs-on: ubuntu-latest
env:
GH_PR_NUM: ${{ github.event.number }}
needs: build
steps:
- uses: actions/checkout@v4
# Yes, we really want to checkout the PR
- run: |
if [[ ! -z "${GH_PR_NUM}" ]]; then
echo "Checking out PR"
git fetch origin pull/$GH_PR_NUM/head:tmp
git checkout tmp
fi
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Cache npm deps
with:
path: |
node_modules
**/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- run: npm install --frozen-lockfile
if: steps.npm-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v4
id: dist
name: Cache dist
with:
path: |
packages/*/dist
packages/react-styles/css
key: ${{ runner.os }}-dist-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json', 'package.json', 'packages/*/*', '!packages/*/dist', '!packages/*/node_modules') }}
- name: Build dist
run: npm run build
- name: Run component tests
run: npm run cypress:run:ci:cp
test_e2e:
runs-on: ubuntu-latest
env:
GH_PR_NUM: ${{ github.event.number }}
needs: build
steps:
- uses: actions/checkout@v4
# Yes, we really want to checkout the PR
- run: |
if [[ ! -z "${GH_PR_NUM}" ]]; then
echo "Checking out PR"
git fetch origin pull/$GH_PR_NUM/head:tmp
git checkout tmp
fi
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Cache npm deps
with:
path: |
node_modules
**/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- run: npm install --frozen-lockfile
if: steps.npm-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v4
id: dist
name: Cache dist
with:
path: |
packages/*/dist
packages/react-styles/css
key: ${{ runner.os }}-dist-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json', 'package.json', 'packages/*/*', '!packages/*/dist', '!packages/*/node_modules') }}
- name: Build dist
run: npm run build
- name: Run component tests
run: npm run cypress:run:ci:e2e
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
env:
GH_PR_NUM: ${{ github.event.number }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: |
if [[ ! -z "${GH_PR_NUM}" ]]; then
echo "Checking out PR"
git fetch origin pull/$GH_PR_NUM/head:tmp
git checkout tmp
fi
- uses: actions/cache@v2
- uses: actions/cache@v4
id: setup-cache
name: Cache setup
with:
Expand All @@ -30,10 +30,10 @@ jobs:
run: ./devSetup.sh
shell: bash
if: steps.setup-cache.outputs.cache-hit != 'true'
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/cache@v2
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Cache npm deps
with:
Expand All @@ -43,7 +43,7 @@ jobs:
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- run: npm install --frozen-lockfile
if: steps.npm-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
- uses: actions/cache@v4
id: dist
name: Cache dist
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }}
GH_PR_NUM: ${{ github.event.number }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
# Yes, we really want to checkout the PR
- run: |
git fetch origin pull/$GH_PR_NUM/head:tmp
Expand All @@ -24,10 +24,10 @@ jobs:
# Yes, we really want to checkout the PR
# Injected by generate-workflows.js
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/cache@v2
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Load npm deps from cache
with:
Expand All @@ -37,7 +37,7 @@ jobs:
if: steps.yarn-cache.outputs.cache-hit != 'true'
- run: npm run build
name: Build virtual assistant
- uses: actions/cache@v2
- uses: actions/cache@v4
id: docs-cache
name: Load webpack cache
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build for promotion
run: yarn install --frozen-lockfile && yarn build
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: GitHub Tag Name example
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/cache@v2
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Cache npm deps
with:
Expand All @@ -29,7 +29,7 @@ jobs:
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- run: npm install --frozen-lockfile
if: steps.npm-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
- uses: actions/cache@v4
id: dist
name: Cache dist
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ tsc_out
.DS_Store
coverage
.cache
.cypress-cache
results
.tmp
.eslintcache
generated
Expand Down
67 changes: 67 additions & 0 deletions config/webpack.cy.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

/** @type { import("webpack").Configuration } */
const JSConfig = {
module: {
rules: [
{
test: /\.(js|ts)x?$/,
exclude: /node_modules/,
use: {
loader: 'swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
},
},
},
},
{
test: /\.s?[ac]ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.(jpe?g|svg|png|gif|ico|eot|ttf|woff2?)(\?v=\d+\.\d+\.\d+)?$/i,
type: 'asset/resource',
},
],
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
},
output: {
filename: 'bundle.js',
hashFunction: 'xxhash64',
path: path.resolve(__dirname, 'dist'),
},
cache: {
type: 'filesystem',
buildDependencies: {
config: [ __filename ],
},
cacheDirectory: path.resolve(__dirname, '../.cypress-cache'),
},
stats: {
errorDetails: true,
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css',
}),
],
};

module.exports = JSConfig;
Loading

0 comments on commit f8b4bde

Please sign in to comment.