Create manual workflow to run tests on the production version of BitwiseCmd (#60)

* Simplify BitwiseCmdTests action responsibilities

* Fix build script to avoid hanging server

* Run unit tests in PR workflow
This commit is contained in:
Borys Levytskyi
2025-11-05 20:12:33 -05:00
committed by GitHub
parent 0a7f85c3e4
commit 43d5d7fa44
4 changed files with 118 additions and 29 deletions

View File

@@ -0,0 +1,88 @@
name: Run BitwiseCmdTests
description: Run BitwiseCmdTests end-to-end suites against an externally hosted application.
inputs:
test-command:
description: npm script name to execute inside BitwiseCmdTests
required: true
base-url:
description: Optional BASE_URL for BitwiseCmdTests
required: false
default: ''
upload-artifact:
description: Upload the BitwiseCmdTests log as an artifact
required: false
default: 'false'
artifact-name:
description: Artifact name when uploading logs
required: false
default: bitwisecmdtests-results
node-version:
description: Node.js version to install
required: false
default: '18'
bitwisecmd-tests-token:
description: Personal access token with repo scope for BitwiseCmdTests checkout
required: false
default: ''
runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs['node-version'] }}
- name: Ensure BitwiseCmdTests access token is configured
if: ${{ inputs['bitwisecmd-tests-token'] == '' }}
shell: bash
run: |
echo "::error::Add a personal access token with repo scope as the BITWISECMD_TESTS_TOKEN repository secret so the workflow can clone BitwiseCmdTests."
exit 1
- name: Checkout BitwiseCmdTests repository
if: ${{ inputs['bitwisecmd-tests-token'] != '' }}
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/BitwiseCmdTests
path: BitwiseCmdTests
token: ${{ inputs['bitwisecmd-tests-token'] }}
- name: Install BitwiseCmdTests dependencies
if: ${{ inputs['bitwisecmd-tests-token'] != '' }}
shell: bash
working-directory: BitwiseCmdTests
run: npm install --no-audit --no-fund
- name: Run BitwiseCmdTests
if: ${{ inputs['bitwisecmd-tests-token'] != '' }}
shell: bash
working-directory: BitwiseCmdTests
env:
CHROME_ARGS: --headless=new --disable-gpu --no-sandbox --disable-dev-shm-usage --window-size=1280,720
BASE_URL: ${{ inputs['base-url'] }}
TEST_COMMAND: ${{ inputs['test-command'] }}
SHOULD_UPLOAD: ${{ inputs['upload-artifact'] }}
run: |
if [ -n "$BASE_URL" ]; then
export BASE_URL
else
unset BASE_URL
fi
if [ "$SHOULD_UPLOAD" = 'true' ]; then
set -o pipefail
xvfb-run --auto-servernum -- bash -c "npm run $TEST_COMMAND" | tee bitwisecmdtests-results.log
else
xvfb-run --auto-servernum -- npm run "$TEST_COMMAND"
fi
- name: Upload test results artifact
if: ${{ inputs['upload-artifact'] == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs['artifact-name'] }}
path: BitwiseCmdTests/bitwisecmdtests-results.log
if-no-files-found: warn

View File

@@ -0,0 +1,17 @@
name: Manual BitwiseCmdTests
on:
workflow_dispatch:
jobs:
run-bitwisecmdtests:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Run BitwiseCmdTests
uses: ./.github/actions/bitwisecmdtests
with:
test-command: test-prod
upload-artifact: 'true'
artifact-name: bitwisecmdtests-results
bitwisecmd-tests-token: ${{ secrets.BITWISECMD_TESTS_TOKEN }}

View File

@@ -8,9 +8,6 @@ jobs:
e2e-tests:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
BITWISECMD_TESTS_TOKEN: ${{ secrets.BITWISECMD_TESTS_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -24,9 +21,14 @@ jobs:
run: npm install --no-audit --no-fund
- name: Build application
run: npx react-scripts build
env:
CI: true
run: npm run build
- name: Run unit tests
env:
CI: true
run: npm test -- --watch=false
- name: Start static web server
run: |
@@ -34,31 +36,12 @@ jobs:
echo $! > server.pid
npx --yes wait-on --timeout=120000 http-get://127.0.0.1:3030
- name: Ensure BitwiseCmdTests access token is configured
if: ${{ env.BITWISECMD_TESTS_TOKEN == '' }}
run: |
echo "::error::Add a personal access token with repo scope as the BITWISECMD_TESTS_TOKEN repository secret so the CI job can clone BitwiseCmdTests."
exit 1
- name: Checkout BitwiseCmdTests repository
if: ${{ env.BITWISECMD_TESTS_TOKEN != '' }}
uses: actions/checkout@v4
- name: Run BitwiseCmdTests
uses: ./.github/actions/bitwisecmdtests
with:
repository: ${{ github.repository_owner }}/BitwiseCmdTests
path: BitwiseCmdTests
token: ${{ env.BITWISECMD_TESTS_TOKEN }}
- name: Install BitwiseCmdTests dependencies
working-directory: BitwiseCmdTests
run: npm install --no-audit --no-fund
- name: Run webdriver tests
working-directory: BitwiseCmdTests
env:
BASE_URL: http://localhost:3030
CHROME_ARGS: --headless=new --disable-gpu --no-sandbox --disable-dev-shm-usage --window-size=1280,720
run: |
xvfb-run --auto-servernum -- npm run test-build
test-command: test-build
base-url: http://127.0.0.1:3030
bitwisecmd-tests-token: ${{ secrets.BITWISECMD_TESTS_TOKEN }}
- name: Stop static web server
if: always()
@@ -66,3 +49,4 @@ jobs:
if [ -f server.pid ]; then
kill $(cat server.pid) || true
fi
rm -f server.pid

View File

@@ -26,7 +26,7 @@
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && npx http-server ./build -p 3030",
"build": "react-scripts build",
"release": "react-scripts build && gh-pages -d build --message Release",
"deploy": "gh-pages -d build --message Release",
"test": "react-scripts test",