1
0
forked from baron/baron-sso

ci: simplify adminfront runner flow and stabilize e2e auth state

This commit is contained in:
Lectom C Han
2026-02-20 10:14:53 +09:00
parent cee5bf13af
commit a14c67f189
3 changed files with 119 additions and 100 deletions

View File

@@ -146,7 +146,7 @@ jobs:
- name: Upload backend failure report artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: backend-test-failure-report
@@ -158,7 +158,7 @@ jobs:
userfront-tests:
needs: lint
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_userfront_tests == true) }}
runs-on: ubuntu-latest
runs-on: ubuntu-latest-slim
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -235,7 +235,7 @@ jobs:
- name: Upload userfront failure report artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: userfront-test-failure-report
@@ -247,7 +247,8 @@ jobs:
adminfront-tests:
needs: lint
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_adminfront_tests == true) }}
runs-on: ubuntu-latest
runs-on: playwright
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -259,97 +260,9 @@ jobs:
cache: "npm"
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
run: |
mkdir -p reports
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"
scripts/run_adminfront_ci_tests.sh adminfront-tests
- name: Ensure adminfront failure report exists
if: ${{ failure() }}
@@ -397,7 +310,7 @@ jobs:
- name: Upload adminfront failure report artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: adminfront-test-failure-report
@@ -413,7 +326,7 @@ jobs:
devfront-tests:
needs: lint
if: ${{ always() && (github.event_name != 'workflow_dispatch' || inputs.run_devfront_tests == true) }}
runs-on: ubuntu-latest
runs-on: playwright
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -563,7 +476,7 @@ jobs:
- name: Upload devfront failure report artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: devfront-test-failure-report

View File

@@ -23,14 +23,27 @@ type UserCreatePayload = {
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 }) => {
const users: UserSummary[] = [];
let idSeq = 1;
await page.addInitScript(() => {
window.localStorage.setItem("admin_session", "playwright-admin-session");
});
await page.route("**/api/v1/admin/users**", async (route) => {
const request = route.request();
const url = new URL(request.url());

View 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"