forked from baron/baron-sso
ci: simplify adminfront runner flow and stabilize e2e auth state
This commit is contained in:
@@ -146,7 +146,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload backend failure report artifact
|
- name: Upload backend failure report artifact
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v3
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
name: backend-test-failure-report
|
name: backend-test-failure-report
|
||||||
@@ -158,7 +158,7 @@ jobs:
|
|||||||
userfront-tests:
|
userfront-tests:
|
||||||
needs: lint
|
needs: lint
|
||||||
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_userfront_tests == true) }}
|
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_userfront_tests == true) }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest-slim
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -235,7 +235,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload userfront failure report artifact
|
- name: Upload userfront failure report artifact
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v3
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
name: userfront-test-failure-report
|
name: userfront-test-failure-report
|
||||||
@@ -247,7 +247,8 @@ jobs:
|
|||||||
adminfront-tests:
|
adminfront-tests:
|
||||||
needs: lint
|
needs: lint
|
||||||
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_adminfront_tests == true) }}
|
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_adminfront_tests == true) }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: playwright
|
||||||
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -259,97 +260,9 @@ jobs:
|
|||||||
cache: "npm"
|
cache: "npm"
|
||||||
cache-dependency-path: adminfront/package-lock.json
|
cache-dependency-path: adminfront/package-lock.json
|
||||||
|
|
||||||
- name: Install adminfront dependencies
|
|
||||||
run: |
|
|
||||||
mkdir -p reports
|
|
||||||
set +e
|
|
||||||
cd adminfront
|
|
||||||
npm ci 2>&1 | tee ../reports/adminfront-install.log
|
|
||||||
install_exit_code=${PIPESTATUS[0]}
|
|
||||||
cd ..
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ "$install_exit_code" -ne 0 ]; then
|
|
||||||
{
|
|
||||||
echo "# Adminfront Test Failure Report"
|
|
||||||
echo
|
|
||||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
|
||||||
echo "- Job: \`adminfront-tests\`"
|
|
||||||
echo "- Reason: \`Dependency install failed\`"
|
|
||||||
echo "- Exit Code: \`$install_exit_code\`"
|
|
||||||
echo
|
|
||||||
echo "## Command"
|
|
||||||
echo "\`cd adminfront && npm ci\`"
|
|
||||||
echo
|
|
||||||
echo "## Install Log Tail (last 200 lines)"
|
|
||||||
echo '```text'
|
|
||||||
tail -n 200 reports/adminfront-install.log
|
|
||||||
echo '```'
|
|
||||||
} > reports/adminfront-test-failure-report.md
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Provision browsers for adminfront tests
|
|
||||||
run: |
|
|
||||||
set +e
|
|
||||||
cd adminfront
|
|
||||||
npx playwright install --with-deps 2>&1 | tee ../reports/adminfront-provision.log
|
|
||||||
provision_exit_code=${PIPESTATUS[0]}
|
|
||||||
cd ..
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ "$provision_exit_code" -ne 0 ]; then
|
|
||||||
{
|
|
||||||
echo "# Adminfront Test Failure Report"
|
|
||||||
echo
|
|
||||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
|
||||||
echo "- Job: \`adminfront-tests\`"
|
|
||||||
echo "- Reason: \`Browser provisioning failed\`"
|
|
||||||
echo "- Exit Code: \`$provision_exit_code\`"
|
|
||||||
echo
|
|
||||||
echo "## Command"
|
|
||||||
echo "\`cd adminfront && npx playwright install --with-deps\`"
|
|
||||||
echo
|
|
||||||
echo "## Provision Log Tail (last 200 lines)"
|
|
||||||
echo '```text'
|
|
||||||
tail -n 200 reports/adminfront-provision.log
|
|
||||||
echo '```'
|
|
||||||
} > reports/adminfront-test-failure-report.md
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run adminfront tests
|
- name: Run adminfront tests
|
||||||
run: |
|
run: |
|
||||||
mkdir -p reports
|
scripts/run_adminfront_ci_tests.sh adminfront-tests
|
||||||
set +e
|
|
||||||
cd adminfront
|
|
||||||
npm test 2>&1 | tee ../reports/adminfront-test.log
|
|
||||||
test_exit_code=${PIPESTATUS[0]}
|
|
||||||
cd ..
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ "$test_exit_code" -ne 0 ]; then
|
|
||||||
{
|
|
||||||
echo "# Adminfront Test Failure Report"
|
|
||||||
echo
|
|
||||||
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
|
||||||
echo "- Job: \`adminfront-tests\`"
|
|
||||||
echo "- Exit Code: \`$test_exit_code\`"
|
|
||||||
echo
|
|
||||||
echo "## Commands"
|
|
||||||
echo "1. \`cd adminfront\`"
|
|
||||||
echo "2. \`npm ci\`"
|
|
||||||
echo "3. \`npx playwright install --with-deps\`"
|
|
||||||
echo "4. \`npm test\`"
|
|
||||||
echo
|
|
||||||
echo "## Log Tail (last 200 lines)"
|
|
||||||
echo '```text'
|
|
||||||
tail -n 200 reports/adminfront-test.log
|
|
||||||
echo '```'
|
|
||||||
} > reports/adminfront-test-failure-report.md
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit "$test_exit_code"
|
|
||||||
|
|
||||||
- name: Ensure adminfront failure report exists
|
- name: Ensure adminfront failure report exists
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
@@ -397,7 +310,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload adminfront failure report artifact
|
- name: Upload adminfront failure report artifact
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v3
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
name: adminfront-test-failure-report
|
name: adminfront-test-failure-report
|
||||||
@@ -413,7 +326,7 @@ jobs:
|
|||||||
devfront-tests:
|
devfront-tests:
|
||||||
needs: lint
|
needs: lint
|
||||||
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_devfront_tests == true) }}
|
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_devfront_tests == true) }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: playwright
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -563,7 +476,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload devfront failure report artifact
|
- name: Upload devfront failure report artifact
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v3
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
name: devfront-test-failure-report
|
name: devfront-test-failure-report
|
||||||
|
|||||||
@@ -23,14 +23,27 @@ type UserCreatePayload = {
|
|||||||
department?: string;
|
department?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test.use({
|
||||||
|
storageState: {
|
||||||
|
cookies: [],
|
||||||
|
origins: [
|
||||||
|
{
|
||||||
|
origin: "http://localhost:5173",
|
||||||
|
localStorage: [
|
||||||
|
{
|
||||||
|
name: "admin_session",
|
||||||
|
value: "playwright-admin-session",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
test("user create and delete flow", async ({ page }) => {
|
test("user create and delete flow", async ({ page }) => {
|
||||||
const users: UserSummary[] = [];
|
const users: UserSummary[] = [];
|
||||||
let idSeq = 1;
|
let idSeq = 1;
|
||||||
|
|
||||||
await page.addInitScript(() => {
|
|
||||||
window.localStorage.setItem("admin_session", "playwright-admin-session");
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.route("**/api/v1/admin/users**", async (route) => {
|
await page.route("**/api/v1/admin/users**", async (route) => {
|
||||||
const request = route.request();
|
const request = route.request();
|
||||||
const url = new URL(request.url());
|
const url = new URL(request.url());
|
||||||
|
|||||||
93
scripts/run_adminfront_ci_tests.sh
Executable file
93
scripts/run_adminfront_ci_tests.sh
Executable file
@@ -0,0 +1,93 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
job_name="${1:-adminfront-tests}"
|
||||||
|
|
||||||
|
mkdir -p reports
|
||||||
|
|
||||||
|
set +e
|
||||||
|
(
|
||||||
|
cd adminfront
|
||||||
|
npm ci
|
||||||
|
) 2>&1 | tee reports/adminfront-install.log
|
||||||
|
install_exit_code=${PIPESTATUS[0]}
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$install_exit_code" -ne 0 ]; then
|
||||||
|
{
|
||||||
|
echo "# Adminfront Test Failure Report"
|
||||||
|
echo
|
||||||
|
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||||
|
echo "- Job: \`${job_name}\`"
|
||||||
|
echo "- Reason: \`Dependency install failed\`"
|
||||||
|
echo "- Exit Code: \`$install_exit_code\`"
|
||||||
|
echo
|
||||||
|
echo "## Command"
|
||||||
|
echo "\`cd adminfront && npm ci\`"
|
||||||
|
echo
|
||||||
|
echo "## Install Log Tail (last 200 lines)"
|
||||||
|
echo '```text'
|
||||||
|
tail -n 200 reports/adminfront-install.log
|
||||||
|
echo '```'
|
||||||
|
} > reports/adminfront-test-failure-report.md
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
|
(
|
||||||
|
cd adminfront
|
||||||
|
npx playwright install --with-deps
|
||||||
|
) 2>&1 | tee reports/adminfront-provision.log
|
||||||
|
provision_exit_code=${PIPESTATUS[0]}
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$provision_exit_code" -ne 0 ]; then
|
||||||
|
{
|
||||||
|
echo "# Adminfront Test Failure Report"
|
||||||
|
echo
|
||||||
|
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||||
|
echo "- Job: \`${job_name}\`"
|
||||||
|
echo "- Reason: \`Browser provisioning failed\`"
|
||||||
|
echo "- Exit Code: \`$provision_exit_code\`"
|
||||||
|
echo
|
||||||
|
echo "## Command"
|
||||||
|
echo "\`cd adminfront && npx playwright install --with-deps\`"
|
||||||
|
echo
|
||||||
|
echo "## Provision Log Tail (last 200 lines)"
|
||||||
|
echo '```text'
|
||||||
|
tail -n 200 reports/adminfront-provision.log
|
||||||
|
echo '```'
|
||||||
|
} > reports/adminfront-test-failure-report.md
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
|
(
|
||||||
|
cd adminfront
|
||||||
|
npm test
|
||||||
|
) 2>&1 | tee reports/adminfront-test.log
|
||||||
|
test_exit_code=${PIPESTATUS[0]}
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$test_exit_code" -ne 0 ]; then
|
||||||
|
{
|
||||||
|
echo "# Adminfront Test Failure Report"
|
||||||
|
echo
|
||||||
|
echo "- Workflow: \`${GITHUB_WORKFLOW:-Code Check}\`"
|
||||||
|
echo "- Job: \`${job_name}\`"
|
||||||
|
echo "- Exit Code: \`$test_exit_code\`"
|
||||||
|
echo
|
||||||
|
echo "## Commands"
|
||||||
|
echo "1. \`cd adminfront\`"
|
||||||
|
echo "2. \`npm ci\`"
|
||||||
|
echo "3. \`npx playwright install --with-deps\`"
|
||||||
|
echo "4. \`npm test\`"
|
||||||
|
echo
|
||||||
|
echo "## Log Tail (last 200 lines)"
|
||||||
|
echo '```text'
|
||||||
|
tail -n 200 reports/adminfront-test.log
|
||||||
|
echo '```'
|
||||||
|
} > reports/adminfront-test-failure-report.md
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit "$test_exit_code"
|
||||||
Reference in New Issue
Block a user