Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[testing] Fix after approval workflow #6196

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/after-approval-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: After Approval Add Label Workflow

on:
workflow_run:
workflows:
- AFTER_APPROVAL
types:
- completed

jobs:
download:
runs-on: ubuntu-latest
steps:
- name: 'Download artifact'
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr_number"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));

- name: 'Unzip artifact'
run: unzip pr_number.zip

- name: 'Comment on PR'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.LEXICAL_BOT_TOKEN }}
script: |
let fs = require('fs');
let issue_number = Number(fs.readFileSync('./pr_number'));
await github.rest.issues.addLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
labels: ['extended-tests'],
});
23 changes: 11 additions & 12 deletions .github/workflows/after-approval.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: After Approval
name: AFTER_APPROVAL

on:
pull_request_review:
Expand All @@ -9,18 +9,17 @@ concurrency:
cancel-in-progress: true

jobs:
label-pr:
if: github.event.review.state == 'approved' && !contains(github.event.pull_request.labels.*.name, 'extended-tests')
upload-pr-number:
if: github.event.review.state == 'commented' && !contains(github.event.pull_request.labels.*.name, 'extended-tests')
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Add label for extended tests
- name: Save PR number
env:
GH_TOKEN: ${{ secrets.LEXICAL_BOT_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
echo "Adding label 'extended-tests' to PR $NUMBER"
gh pr edit "$NUMBER" --add-label "extended-tests" || (echo "Failed to add label" && exit 1)
mkdir -p ./pr
echo $PR_NUMBER > ./pr/pr_number
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr/
96 changes: 48 additions & 48 deletions .github/workflows/call-core-tests.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
name: Lexical Core Tests
# name: Lexical Core Tests

on:
workflow_call:
# on:
# workflow_call:

jobs:
integrity:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.11.0]
env:
CI: true
GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run ci-check
- run: npm run build
- run: npm run build-www
# jobs:
# integrity:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [20.11.0]
# env:
# CI: true
# GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
# steps:
# - uses: actions/checkout@v4
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
# cache: npm
# - name: Install dependencies
# run: npm ci
# - run: npm run ci-check
# - run: npm run build
# - run: npm run build-www

unit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.18.0]
override-react-version: ['', 'beta']
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Install React ${{ matrix.override-react-version }}
if: matrix.override-react-version != ''
# This should be safe since we are caching ~/.npm and not node_modules
run: |
node ./scripts/override-react.js --version=${{ matrix.override-react-version }}
grep version node_modules/{react,react-dom}/package.json
- run: npm run test-unit
# unit:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [18.18.0]
# override-react-version: ['', 'beta']
# env:
# CI: true
# steps:
# - uses: actions/checkout@v4
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
# cache: npm
# - name: Install dependencies
# run: npm ci
# - name: Install React ${{ matrix.override-react-version }}
# if: matrix.override-react-version != ''
# # This should be safe since we are caching ~/.npm and not node_modules
# run: |
# node ./scripts/override-react.js --version=${{ matrix.override-react-version }}
# grep version node_modules/{react,react-dom}/package.json
# - run: npm run test-unit
132 changes: 66 additions & 66 deletions .github/workflows/call-e2e-test.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
name: Lexical e2e test runner
# name: Lexical e2e test runner

on:
workflow_call:
inputs:
os: {required: true, type: string}
node-version: {required: true, type: string}
browser: {required: true, type: string}
editor-mode: {required: true, type: string}
events-mode: {required: true, type: string}
prod: {required: false, type: boolean}
override-react-version: {required: false, type: string}
# on:
# workflow_call:
# inputs:
# os: {required: true, type: string}
# node-version: {required: true, type: string}
# browser: {required: true, type: string}
# editor-mode: {required: true, type: string}
# events-mode: {required: true, type: string}
# prod: {required: false, type: boolean}
# override-react-version: {required: false, type: string}

jobs:
e2e-test:
runs-on: ${{ inputs.os }}
if: (inputs.browser != 'webkit' || inputs.os == 'macos-latest') && (inputs.editor-mode != 'rich-text-with-collab' || inputs.events-mode != 'legacy-events')
env:
CI: true
E2E_EDITOR_MODE: ${{ inputs.editor-mode }}
E2E_EVENTS_MODE: ${{ inputs.events-mode }}
OVERRIDE_REACT_VERSION: ${{ inputs.override-react-version }}
cache_playwright_path: ${{ inputs.os == 'macos-latest' && '~/Library/Caches/ms-playwright' || inputs.os == 'windows-latest' && 'C:\Users\runneradmin\AppData\Local\ms-playwright' || '~/.cache/ms-playwright' }}
test_results_path: ${{ inputs.os == 'windows-latest' && '~/.npm/_logs/' || 'test-results/' }}
test_script: test-e2e-${{ inputs.editor-mode == 'rich-text-with-collab' && 'collab-' || '' }}${{ inputs.prod && 'prod-' || '' }}ci-${{ inputs.browser }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: npm
- name: Install required ubuntu-latest packages
if: inputs.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install xvfb
- name: Install dependencies
run: npm ci
- name: Install React ${{ inputs.override-react-version }}
if: inputs.override-react-version != ''
# This should be safe since we are caching ~/.npm and not node_modules
run: |
node ./scripts/override-react.js --version=${{ inputs.override-react-version }}
grep version node_modules/{react,react-dom}/package.json
- name: Restore playwright from cache
uses: actions/cache/restore@v4
id: playwright-cache
with:
path: ${{ env.cache_playwright_path }}
key: playwright-${{ inputs.node-version }}-${{ runner.os }}-${{ runner.arch }}-v${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
- name: Install playwright
run: npx playwright install
- name: Save playwright to cache
uses: actions/cache/save@v4
if: steps.playwright-cache.outputs.cache-hit != 'true'
with:
path: ${{ env.cache_playwright_path }}
key: ${{ steps.playwright-cache.outputs.cache-primary-key }}
- name: Run tests
run: npm run ${{ env.test_script }}
- name: Upload Artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: Test Results ${{ inputs.os }}-${{ inputs.browser }}-${{ inputs.editor-mode }}-${{ inputs.events-mode }}-${{ inputs.prod && 'prod' || 'dev' }}-${{ inputs.node-version }}-${{ inputs.override-react-version }}
path: ${{ env.test_results_path }}
retention-days: 7
# jobs:
# e2e-test:
# runs-on: ${{ inputs.os }}
# if: (inputs.browser != 'webkit' || inputs.os == 'macos-latest') && (inputs.editor-mode != 'rich-text-with-collab' || inputs.events-mode != 'legacy-events')
# env:
# CI: true
# E2E_EDITOR_MODE: ${{ inputs.editor-mode }}
# E2E_EVENTS_MODE: ${{ inputs.events-mode }}
# OVERRIDE_REACT_VERSION: ${{ inputs.override-react-version }}
# cache_playwright_path: ${{ inputs.os == 'macos-latest' && '~/Library/Caches/ms-playwright' || inputs.os == 'windows-latest' && 'C:\Users\runneradmin\AppData\Local\ms-playwright' || '~/.cache/ms-playwright' }}
# test_results_path: ${{ inputs.os == 'windows-latest' && '~/.npm/_logs/' || 'test-results/' }}
# test_script: test-e2e-${{ inputs.editor-mode == 'rich-text-with-collab' && 'collab-' || '' }}${{ inputs.prod && 'prod-' || '' }}ci-${{ inputs.browser }}
# steps:
# - uses: actions/checkout@v4
# - name: Use Node.js ${{ inputs.node-version }}
# uses: actions/setup-node@v4
# with:
# node-version: ${{ inputs.node-version }}
# cache: npm
# - name: Install required ubuntu-latest packages
# if: inputs.os == 'ubuntu-latest'
# run: |
# sudo apt-get update
# sudo apt-get install xvfb
# - name: Install dependencies
# run: npm ci
# - name: Install React ${{ inputs.override-react-version }}
# if: inputs.override-react-version != ''
# # This should be safe since we are caching ~/.npm and not node_modules
# run: |
# node ./scripts/override-react.js --version=${{ inputs.override-react-version }}
# grep version node_modules/{react,react-dom}/package.json
# - name: Restore playwright from cache
# uses: actions/cache/restore@v4
# id: playwright-cache
# with:
# path: ${{ env.cache_playwright_path }}
# key: playwright-${{ inputs.node-version }}-${{ runner.os }}-${{ runner.arch }}-v${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
# - name: Install playwright
# run: npx playwright install
# - name: Save playwright to cache
# uses: actions/cache/save@v4
# if: steps.playwright-cache.outputs.cache-hit != 'true'
# with:
# path: ${{ env.cache_playwright_path }}
# key: ${{ steps.playwright-cache.outputs.cache-primary-key }}
# - name: Run tests
# run: npm run ${{ env.test_script }}
# - name: Upload Artifacts
# if: failure()
# uses: actions/upload-artifact@v4
# with:
# name: Test Results ${{ inputs.os }}-${{ inputs.browser }}-${{ inputs.editor-mode }}-${{ inputs.events-mode }}-${{ inputs.prod && 'prod' || 'dev' }}-${{ inputs.node-version }}-${{ inputs.override-react-version }}
# path: ${{ env.test_results_path }}
# retention-days: 7
34 changes: 17 additions & 17 deletions .github/workflows/tests-extended.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: Lexical Tests (Extended)
# name: Lexical Tests (Extended)

on:
pull_request:
types: [labeled, synchronize, reopened]
paths-ignore:
- 'packages/lexical-website/**'
- 'packages/*/README.md'
# on:
# pull_request:
# types: [labeled, synchronize, reopened]
# paths-ignore:
# - 'packages/lexical-website/**'
# - 'packages/*/README.md'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true

jobs:
e2e-tests:
if: github.repository_owner == 'facebook' && contains(github.event.pull_request.labels.*.name, 'extended-tests')
uses: ./.github/workflows/call-e2e-all-tests.yml
# jobs:
# e2e-tests:
# if: github.repository_owner == 'facebook' && contains(github.event.pull_request.labels.*.name, 'extended-tests')
# uses: ./.github/workflows/call-e2e-all-tests.yml

integration-tests:
if: github.repository_owner == 'facebook' && contains(github.event.pull_request.labels.*.name, 'extended-tests')
uses: ./.github/workflows/call-integration-tests.yml
# integration-tests:
# if: github.repository_owner == 'facebook' && contains(github.event.pull_request.labels.*.name, 'extended-tests')
# uses: ./.github/workflows/call-integration-tests.yml
Loading