Skip to content

Commit 0422260

Browse files
feat: Introduce GitHub Actions workflow for automated Playwright E2E documentation updates. (#25545)
* feat: Introduce GitHub Actions workflow for automated Playwright E2E documentation updates and update README. * feat: refine Playwright E2E docs workflow and documentation * addressing review comment
1 parent 34a7f5e commit 0422260

File tree

2 files changed

+111
-15
lines changed

2 files changed

+111
-15
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright 2021 Collate
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
12+
name: Update Playwright E2E Documentation
13+
on:
14+
workflow_dispatch:
15+
16+
jobs:
17+
update-docs:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
steps:
23+
- name: Validate Branch
24+
run: |
25+
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
26+
echo "This workflow can only be run on the main branch."
27+
exit 1
28+
fi
29+
30+
- name: Checkout Repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version-file: "openmetadata-ui/src/main/resources/ui/.nvmrc"
39+
cache: "yarn"
40+
cache-dependency-path: openmetadata-ui/src/main/resources/ui/yarn.lock
41+
42+
- name: Install Yarn
43+
run: npm install -g yarn
44+
45+
- name: Install Dependencies
46+
working-directory: openmetadata-ui/src/main/resources/ui
47+
run: yarn install --frozen-lockfile --ignore-scripts
48+
49+
- name: Install Playwright Browsers
50+
working-directory: openmetadata-ui/src/main/resources/ui
51+
run: npx playwright install --with-deps
52+
53+
- name: Generate E2E Docs
54+
working-directory: openmetadata-ui/src/main/resources/ui
55+
run: yarn generate:e2e-docs
56+
57+
- name: Detect Changes
58+
id: git-check
59+
run: |
60+
if [ -z "$(git status --porcelain openmetadata-ui/src/main/resources/ui/playwright/docs)" ]; then
61+
echo "No changes detected."
62+
echo "changed=false" >> $GITHUB_OUTPUT
63+
else
64+
echo "Changes detected."
65+
echo "changed=true" >> $GITHUB_OUTPUT
66+
fi
67+
68+
- name: Create Pull Request
69+
if: steps.git-check.outputs.changed == 'true'
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
BRANCH_NAME="chore/update-playwright-docs"
74+
git config user.name "github-actions[bot]"
75+
git config user.email "github-actions[bot]@users.noreply.github.com"
76+
77+
git checkout -B $BRANCH_NAME
78+
git add openmetadata-ui/src/main/resources/ui/playwright/docs
79+
git commit -m "chore: update Playwright E2E documentation"
80+
git push origin $BRANCH_NAME --force
81+
82+
gh pr create \
83+
--title "chore: update Playwright E2E documentation" \
84+
--body "This is an automated PR to update the Playwright E2E documentation. Generated by the \`Update Playwright E2E Documentation\` workflow." \
85+
--base main \
86+
--head $BRANCH_NAME || {
87+
if gh pr list --head $BRANCH_NAME --state open --json number -jq '.[0].number' | grep -q .; then
88+
echo "PR already exists"
89+
else
90+
echo "Failed to create PR"
91+
exit 1
92+
fi
93+
}

openmetadata-ui/src/main/resources/ui/playwright/doc-generator/README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,24 @@ yarn generate:e2e-docs
4545

4646
## 🔄 Workflow Integration
4747

48-
**⚠️ Note: CI integration is currently Work In Progress.**
49-
Please run the generator manually before pushing changes.
50-
51-
### Manual Generation (Required)
52-
See the [Usage](#-usage) section above.
53-
Run: `yarn generate:e2e-docs`
54-
55-
### GitHub Actions (In Progress)
56-
Defined in `.github/workflows/playwright-docs-check.yml`.
57-
* **Trigger**: Pull Requests to `main`.
58-
* **Action**: Checks if the documentation matches the code.
59-
* **Auto-Fix**: If docs are outdated (e.g., if the pre-commit hook was bypassed), the CI job will:
60-
1. Fail the initial check.
61-
2. Regenerate the documentation.
62-
3. **Automatically commit and push** the fixes to your PR branch.
48+
### Automation
49+
A GitHub Actions workflow is available to automate the documentation update process and ensure the `main` branch always has the latest E2E docs.
50+
51+
* **Workflow Name**: `Update Playwright E2E Documentation`
52+
* **File**: `.github/workflows/update-playwright-e2e-docs.yml`
53+
* **Trigger**: Manual trigger via `workflow_dispatch`.
54+
* **Logic**:
55+
1. Runs against the `main` branch.
56+
2. Installs dependencies using `yarn install --frozen-lockfile`.
57+
3. Executes documentation generation via `yarn generate:e2e-docs`.
58+
4. **Detection**: Uses `git status` to detect if any documentation files were modified.
59+
5. **Auto PR**: If changes are found, it creates/updates the `chore/update-playwright-docs` branch and automatically opens a Pull Request to `main`.
60+
61+
### Manual Generation
62+
You can still run the generator manually in your local environment before pushing:
63+
```bash
64+
yarn generate:e2e-docs
65+
```
6366

6467
## 🏷️ Classification & Tagging Guide
6568

0 commit comments

Comments
 (0)