mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-15 17:32:17 +01:00
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:
88
.github/actions/bitwisecmdtests/action.yml
vendored
Normal file
88
.github/actions/bitwisecmdtests/action.yml
vendored
Normal 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
|
||||||
17
.github/workflows/manual-bitwisecmdtests.yml
vendored
Normal file
17
.github/workflows/manual-bitwisecmdtests.yml
vendored
Normal 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 }}
|
||||||
40
.github/workflows/pr-ci.yml
vendored
40
.github/workflows/pr-ci.yml
vendored
@@ -8,9 +8,6 @@ jobs:
|
|||||||
e2e-tests:
|
e2e-tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
env:
|
|
||||||
BITWISECMD_TESTS_TOKEN: ${{ secrets.BITWISECMD_TESTS_TOKEN }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -24,9 +21,14 @@ jobs:
|
|||||||
run: npm install --no-audit --no-fund
|
run: npm install --no-audit --no-fund
|
||||||
|
|
||||||
- name: Build application
|
- name: Build application
|
||||||
run: npx react-scripts build
|
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Run unit tests
|
||||||
|
env:
|
||||||
|
CI: true
|
||||||
|
run: npm test -- --watch=false
|
||||||
|
|
||||||
- name: Start static web server
|
- name: Start static web server
|
||||||
run: |
|
run: |
|
||||||
@@ -34,31 +36,12 @@ jobs:
|
|||||||
echo $! > server.pid
|
echo $! > server.pid
|
||||||
npx --yes wait-on --timeout=120000 http-get://127.0.0.1:3030
|
npx --yes wait-on --timeout=120000 http-get://127.0.0.1:3030
|
||||||
|
|
||||||
- name: Ensure BitwiseCmdTests access token is configured
|
- name: Run BitwiseCmdTests
|
||||||
if: ${{ env.BITWISECMD_TESTS_TOKEN == '' }}
|
uses: ./.github/actions/bitwisecmdtests
|
||||||
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
|
|
||||||
with:
|
with:
|
||||||
repository: ${{ github.repository_owner }}/BitwiseCmdTests
|
test-command: test-build
|
||||||
path: BitwiseCmdTests
|
base-url: http://127.0.0.1:3030
|
||||||
token: ${{ env.BITWISECMD_TESTS_TOKEN }}
|
bitwisecmd-tests-token: ${{ secrets.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
|
|
||||||
|
|
||||||
- name: Stop static web server
|
- name: Stop static web server
|
||||||
if: always()
|
if: always()
|
||||||
@@ -66,3 +49,4 @@ jobs:
|
|||||||
if [ -f server.pid ]; then
|
if [ -f server.pid ]; then
|
||||||
kill $(cat server.pid) || true
|
kill $(cat server.pid) || true
|
||||||
fi
|
fi
|
||||||
|
rm -f server.pid
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"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",
|
"release": "react-scripts build && gh-pages -d build --message Release",
|
||||||
"deploy": "gh-pages -d build --message Release",
|
"deploy": "gh-pages -d build --message Release",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
|
|||||||
Reference in New Issue
Block a user