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 8 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
49 changes: 49 additions & 0 deletions .github/workflows/after-approval-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: After Approval 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'],
});
21 changes: 10 additions & 11 deletions .github/workflows/after-approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
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