Skip to content

Commit

Permalink
Merge branch 'v6' into next-thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Aug 26, 2024
2 parents a244af6 + 23d26a8 commit f6c28b7
Show file tree
Hide file tree
Showing 362 changed files with 129,549 additions and 56,928 deletions.
2 changes: 1 addition & 1 deletion .eslintrc-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rules:
- "error"
prefer-const: 1
no-constant-condition: 0
comma-dangle: 2
comma-dangle: 0
no-debugger: 2
no-dupe-keys: 2
no-empty-character-class: 2
Expand Down
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ body:
attributes:
label: Link to Minimal Reproduction
description: |
If the reproduction does not need a build setup, please provide a link to [JSFiddle](https://jsfiddle.net/plainheart/e46ozpqj/7/), [JSBin](https://jsbin.com/) or [CodePen](https://codepen.io/Ovilia/pen/dyYWXWM). If it requires a build setup, you can use [CodeSandbox](https://codesandbox.io/s/echarts-basic-example-template-mpfz1s) or provide a GitHub repo.
If the reproduction does not need a build setup, please provide a link to [Official Editor](https://echarts.apache.org/examples/editor.html), [JSFiddle](https://jsfiddle.net/plainheart/e46ozpqj/7/), [JSBin](https://jsbin.com/) or [CodePen](https://codepen.io/Ovilia/pen/dyYWXWM). If it requires a build setup, you can use [CodeSandbox](https://codesandbox.io/s/echarts-basic-example-template-mpfz1s) or provide a GitHub repo.
The reproduction should be **minimal** - i.e. it should contain only the bare minimum amount of code needed to show the bug.
Please do not just fill in a random link. The issue will be closed if no valid reproduction is provided. [Why?](https://antfu.me/posts/why-reproductions-are-required)
validations:
required: false
required: true

- type: textarea
attributes:
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/.scripts/update-notice-year.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* @typedef {import('@octokit/rest').Octokit} Octokit
* @typedef {import('@actions/github')['context']} Context
*/

module.exports = async function updateNoticeYear(
/** @type {{ octokit: Octokit, context: Context }} */
{ octokit, context }
) {
const now = new Date()
// Change to UTC+8
now.setHours(now.getHours() + 8)
const newYear = now.getFullYear()
console.log('Prepare to update notice year to', newYear)

const noticeContent = `Apache ECharts
Copyright 2017-${newYear} The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (https://www.apache.org/).`

const repoCtx = context.repo

const repoInfo = (await octokit.rest.repos.get(repoCtx)).data
const defaultBranchName = repoInfo.default_branch
const remoteNoticeFile = (await octokit.rest.repos.getContent({
...repoCtx,
path: 'NOTICE',
ref: defaultBranchName
})).data
const remoteNoticeContent = base64ToUtf8(remoteNoticeFile.content)
if (remoteNoticeContent === noticeContent) {
console.log('NOTICE year is already updated.')
return
}

console.log('Ready to update the NOTICE file:\n' + noticeContent)

const defaultBranch = (await octokit.rest.repos.getBranch({
...repoCtx,
branch: defaultBranchName
})).data

const newBranchName = `bot/update-notice-year/${newYear}`
await octokit.rest.git.createRef({
...repoCtx,
ref: `refs/heads/${newBranchName}`,
sha: defaultBranch.commit.sha
})
console.log('Created a new branch:', newBranchName)

await octokit.rest.repos.createOrUpdateFileContents({
...repoCtx,
path: 'NOTICE',
message: `chore: update NOTICE year to ${newYear}`,
content: utf8ToBase64(noticeContent),
sha: remoteNoticeFile.sha,
branch: newBranchName
})

console.log('Updated the NOTICE file on the new branch')

const pr = (await octokit.rest.pulls.create({
...repoCtx,
head: newBranchName,
base: defaultBranchName,
maintainer_can_modify: true,
title: `chore: update NOTICE year to ${newYear}`,
body: `## Brief Information
This pull request is in the type of:
- [ ] bug fixing
- [ ] new feature
- [x] others
### What does this PR do?
Update notice year to ${newYear}. 💖
Happy new year! 祝大家新年快乐!🎇`
})).data

console.log(`Opened PR #${pr.number} for updating the NOTICE file`)
}

function utf8ToBase64(data) {
return Buffer.from(data, 'utf-8').toString('base64')
}

function base64ToUtf8(data) {
return Buffer.from(data, 'base64').toString('utf-8')
}
60 changes: 49 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ name: Node CI

on:
pull_request:
types: [opened, synchronize]
types: [opened, reopened, synchronize]

concurrency:
# Note that the `teardown-pr-preview` workflow needs the same group name
# to cancel the running `ci` workflows
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- name: Fetch commit count
Expand All @@ -19,18 +25,18 @@ jobs:
run: |
echo "FETCH_DEPTH=$(($PR_COMMIT_COUNT + 1))" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache node modules
id: cache-dep
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down Expand Up @@ -58,19 +64,19 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache node modules
id: cache-dep
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -81,11 +87,43 @@ jobs:
if: steps.cache-dep.outputs.cache-hit != 'true'
run: npm ci

- name: Unit Test
run: npm run test

- name: Build release
run: npm run release

- name: Test generated DTS
run: npm run test:dts

- name: Unit Test
run: npm run test
- name: Pack npm tarball
if: ${{ github.repository_owner == 'apache' }}
id: pack-tarball
run: |
export PR_PREVIEW_DIR='echarts-pr-preview'
mkdir -p $PR_PREVIEW_DIR
npm pack -pack-destination $PR_PREVIEW_DIR
echo "PR_PREVIEW_DIR=$PR_PREVIEW_DIR" >> $GITHUB_ENV
- name: Save PR metadata and dist files
if: ${{ steps.pack-tarball.outcome == 'success' }}
id: save-pr-data
env:
PR_NUMBER: ${{ github.event.number }}
PR_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
PR_PREVIEW_DIR: ${{ env.PR_PREVIEW_DIR }}
run: |
cd $PR_PREVIEW_DIR
echo $PR_NUMBER > ./pr_number
echo $PR_COMMIT_SHA > ./pr_commit_sha
find . -type f -regex ".*\.tgz" -exec tar xvzf {} \;
rm -f *.tgz
echo -e "Dist files: \n$(ls -l)"
- uses: actions/upload-artifact@v4
if: ${{ steps.save-pr-data.outcome == 'success' }}
with:
name: pr_preview
path: ${{ env.PR_PREVIEW_DIR }}
retention-days: 1
if-no-files-found: error
10 changes: 6 additions & 4 deletions .github/workflows/nightly-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish Nightly Next

on:
schedule:
- cron: '0 9 * * *' # After zrender nightly published
- cron: '10 9 * * *' # After zrender nightly published
# committers can manually trigger with workflow_dispatch
workflow_dispatch: {}
repository_dispatch:
Expand All @@ -15,17 +15,19 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: next

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version: ${{ matrix.node-version }}

- name: Setup and publish nightly
run: |
node build/nightly/prepare.js --next
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version: ${{ matrix.node-version }}

- name: Setup and publish nightly
run: |
node build/nightly/prepare.js
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Deploy PR Preview

on:
workflow_run:
workflows: ['Node CI']
types: [completed]

jobs:
on-success:
if: ${{ github.repository_owner == 'apache' }}
runs-on: ubuntu-latest

steps:
- name: Determine if workflow build job is successful
id: check-build-success
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const jobsRes = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id
});
return jobsRes.data.jobs.some((job) => job.name.includes('build') && job.conclusion === 'success');
outputs:
SHOULD_DEPLOY: ${{ steps.check-build-success.outputs.result }}

deploy:
needs: [on-success]
if: ${{ needs.on-success.outputs.SHOULD_DEPLOY == 'true' }}
runs-on: ubuntu-latest

steps:
- name: Install action dependencies
run: |
mkdir .actions
cd .actions
git clone --depth=1 https://github.com/dawidd6/action-download-artifact.git
git clone --depth=1 https://github.com/plainheart/maintain-one-comment.git
- name: Fetch PR dist files
uses: ./.actions/action-download-artifact
with:
workflow: ${{ github.event.workflow.id }}
run_id: ${{ github.event.workflow_run.id }}
name: pr_preview
path: pr-dist
if_no_artifact_found: fail

- name: Output PR metadata
id: pr-metadata
working-directory: pr-dist
run: |
echo "NUMBER=$(cat pr_number)" >> $GITHUB_OUTPUT
echo "COMMIT_SHA=$(cat pr_commit_sha)" >> $GITHUB_OUTPUT
echo "COMMIT_SHA_SHORT=$(cat pr_commit_sha | cut -c 1-7)" >> $GITHUB_OUTPUT
- name: Deploy dist files
env:
PR_NUMBER: ${{ steps.pr-metadata.outputs.NUMBER }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
working-directory: pr-dist
run: |
export SURGE_DOMAIN=https://echarts-pr-$PR_NUMBER.surge.sh
npx surge --project ./package --domain $SURGE_DOMAIN --token $SURGE_TOKEN
- name: Create comment for PR preview
uses: ./.actions/maintain-one-comment
env:
PR_NUMBER: ${{ steps.pr-metadata.outputs.NUMBER }}
COMMIT_SHA_SHORT: ${{ steps.pr-metadata.outputs.COMMIT_SHA_SHORT }}
with:
body: |
The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-${{ env.PR_NUMBER }}@${{ env.COMMIT_SHA_SHORT }}
body-include: '<!-- ECHARTS_PR_PREVIEW -->'
number: ${{ env.PR_NUMBER }}
Loading

0 comments on commit f6c28b7

Please sign in to comment.