From 137be850043a0a68649d5ed37f259b6fc16dfa4d Mon Sep 17 00:00:00 2001 From: Nick Frasser <1693461+nfrasser@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:54:50 -0500 Subject: [PATCH] Refactor CI workflow Should work with newest versions? --- .github/workflows/ci.yml | 16 ++++++++++------ test/run.sh | 20 -------------------- test/setup.sh | 16 ---------------- test/spec/linkify-react.test.mjs | 16 ++++++++-------- 4 files changed, 18 insertions(+), 50 deletions(-) delete mode 100755 test/run.sh delete mode 100644 test/setup.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9359e74..26f7b3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,10 +21,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm install - - name: 'Setup tests' - run: bash test/setup.sh - - name: 'Run basic tests' - run: bash test/run.sh + - run: npm test integration: runs-on: ubuntu-latest @@ -38,8 +35,15 @@ jobs: - run: npm install - name: 'Setup dist' run: bash test/setup.sh --dist - - name: 'Run complete test suite' - run: bash test/run.sh --dist + - name: Run coverage + run: | + npm run build + npm run test:coverage + - name: Run browser tests + if: ${{ github.secret_source == 'Actions' }} + run: | + npm run copy + npm run test:ci env: BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} diff --git a/test/run.sh b/test/run.sh deleted file mode 100755 index 88988ef..0000000 --- a/test/run.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -set -e - -# Run complete test suite only these conditions hold -if [[ "$1" == "--dist" ]]; then - echo "Running complete test suite..." - # npm run lint # Causes segfault, pause for now - npm run test:coverage - npm run build:ci - npm run copy - if [[ "${BROWSERSTACK_USERNAME}" != "" ]] && [[ "${BROWSERSTACK_ACCESS_KEY}" != "" ]]; then - npm run test:ci - sleep 3 # Wait for threads to exit? - fi -else - # Run basic tests - echo "Running basic tests..." - npm test - sleep 3 # Wait for threads to exit? -fi diff --git a/test/setup.sh b/test/setup.sh deleted file mode 100644 index 8a6b17d..0000000 --- a/test/setup.sh +++ /dev/null @@ -1,16 +0,0 @@ -REACT_VERSION=15.0.0 -JQUERY_VERSION=1.11.0 - -# If dist mode, install the latest versions -if [ "$1" == "--dist" ]; then - REACT_VERSION=18.0.0 - JQUERY_VERSION=3.0.0 -fi - -echo "Installing jquery ${JQUERY_VERSION} and react ${REACT_VERSION}" -npm install --force jquery@~$JQUERY_VERSION react-dom@~$REACT_VERSION react@~$REACT_VERSION - -echo "Linking Node.js modules" -cd node_modules -ln -f -s ../packages/* . -cd .. diff --git a/test/spec/linkify-react.test.mjs b/test/spec/linkify-react.test.mjs index 2a12482..e9f8d7f 100644 --- a/test/spec/linkify-react.test.mjs +++ b/test/spec/linkify-react.test.mjs @@ -1,5 +1,5 @@ import React from 'react'; -import ReactDOMServer from 'react-dom/server'; +import { renderToStaticMarkup } from 'react-dom/server'; import * as linkify from 'linkifyjs'; import Linkify from 'linkify-react/src/linkify-react.mjs'; import mention from 'linkify-plugin-mention/src/mention.mjs'; @@ -53,7 +53,7 @@ describe('linkify-react', () => { it('Works with default options', function () { tests.map((test) => { var linkified = React.createElement(Linkify, null, test[0]); - var result = ReactDOMServer.renderToStaticMarkup(linkified); + var result = renderToStaticMarkup(linkified); expect(result).to.be.oneOf([test[1], `${test[1]}`]); }); }); @@ -62,7 +62,7 @@ describe('linkify-react', () => { tests.map((test) => { var props = { options, as: 'div', className: 'lambda' }; var linkified = React.createElement(Linkify, props, test[0]); - var result = ReactDOMServer.renderToStaticMarkup(linkified); + var result = renderToStaticMarkup(linkified); expect(result).to.be.eql(test[2]); }); }); @@ -70,7 +70,7 @@ describe('linkify-react', () => { it('Finds links recursively', function () { var strong = React.createElement('strong', null, 'https://facebook.github.io/react/'); var linkified = React.createElement(Linkify, null, 'A great site is google.com AND ', strong); - var result = ReactDOMServer.renderToStaticMarkup(linkified); + var result = renderToStaticMarkup(linkified); var expected = 'A great site is google.com AND https://facebook.github.io/react/'; expect(result).to.be.oneOf([expected, `${expected}`]); @@ -85,7 +85,7 @@ describe('linkify-react', () => { var delta = React.createElement(Delta); var linkified = React.createElement(Linkify, null, 'A great site is google.com AND ', delta); - var result = ReactDOMServer.renderToStaticMarkup(linkified); + var result = renderToStaticMarkup(linkified); var expected = 'A great site is google.com AND https://facebook.github.io/react/'; expect(result).to.be.oneOf([expected, `${expected}`]); @@ -97,7 +97,7 @@ describe('linkify-react', () => { }; var em = React.createElement('em', null, 'https://facebook.github.io/react/'); var linkified = React.createElement(Linkify, { options }, 'A great site is google.com AND ', em); - var result = ReactDOMServer.renderToStaticMarkup(linkified); + var result = renderToStaticMarkup(linkified); var expected = 'A great site is google.com AND https://facebook.github.io/react/'; expect(result).to.be.oneOf([expected, `${expected}`]); @@ -121,7 +121,7 @@ describe('linkify-react', () => { 'For the latest javascript.net\n', React.createElement('strong', { key: 1 }, ['and also\n', 'πŸ₯ΊπŸ‘„.ws']), ); - const result = ReactDOMServer.renderToStaticMarkup(linkified); + const result = renderToStaticMarkup(linkified); const expected = [ 'hello

\t\t ', 'hello

\t\t', @@ -155,7 +155,7 @@ describe('linkify-react', () => { { options }, 'Check out linkify.js.org or contact @nfrasser', ); - const result = ReactDOMServer.renderToStaticMarkup(linkified); + const result = renderToStaticMarkup(linkified); const expected = 'Check out linkify.js.org or contact @nfrasser'; expect(result).to.be.oneOf([expected, `${expected}`]);