diff --git a/.github/actions/setup-cyborg/action.yml b/.github/actions/setup-cyborg/action.yml new file mode 100644 index 000000000000..7b0bcd6ba13e --- /dev/null +++ b/.github/actions/setup-cyborg/action.yml @@ -0,0 +1,16 @@ +name: Setup cyborg environment +description: Setup cyborg environment +runs: + using: composite + steps: + - uses: actions/setup-node@v4 + with: + node-version: 22 + - uses: pnpm/action-setup@v3 + with: + package_json_file: 'cyborg/package.json' + run_install: true + - name: Describe the Environment + working-directory: cyborg + shell: bash + run: pnpm tsx -v diff --git a/.github/doc-label-config.yml b/.github/doc-label-config.yml deleted file mode 100644 index 60f20533a1d2..000000000000 --- a/.github/doc-label-config.yml +++ /dev/null @@ -1,4 +0,0 @@ -Doc not needed: - - '- \[x\] This PR does not require documentation updates.' -Doc update required: - - '- \[ \] This PR does not require documentation updates.' diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 391792c142de..c50137f87681 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -15,6 +15,6 @@ Please explain IN DETAIL what the changes are in this PR and why they are needed ## Checklist -- [ ] I have written the necessary rustdoc comments. -- [ ] I have added the necessary unit tests and integration tests. -- [x] This PR does not require documentation updates. +- [ ] I have written the necessary rustdoc comments. +- [ ] I have added the necessary unit tests and integration tests. +- [ ] This PR requires documentation updates. diff --git a/.github/workflows/doc-issue.yml b/.github/workflows/doc-issue.yml deleted file mode 100644 index 4b366e217fe6..000000000000 --- a/.github/workflows/doc-issue.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Create Issue in downstream repos - -on: - issues: - types: - - labeled - pull_request_target: - types: - - labeled - -jobs: - doc_issue: - if: github.event.label.name == 'doc update required' - runs-on: ubuntu-20.04 - steps: - - name: create an issue in doc repo - uses: dacbd/create-issue-action@v1.2.1 - with: - owner: GreptimeTeam - repo: docs - token: ${{ secrets.DOCS_REPO_TOKEN }} - title: Update docs for ${{ github.event.issue.title || github.event.pull_request.title }} - body: | - A document change request is generated from - ${{ github.event.issue.html_url || github.event.pull_request.html_url }} - cloud_issue: - if: github.event.label.name == 'cloud followup required' - runs-on: ubuntu-20.04 - steps: - - name: create an issue in cloud repo - uses: dacbd/create-issue-action@v1.2.1 - with: - owner: GreptimeTeam - repo: greptimedb-cloud - token: ${{ secrets.DOCS_REPO_TOKEN }} - title: Followup changes in ${{ github.event.issue.title || github.event.pull_request.title }} - body: | - A followup request is generated from - ${{ github.event.issue.html_url || github.event.pull_request.html_url }} diff --git a/.github/workflows/doc-label.yml b/.github/workflows/doc-label.yml deleted file mode 100644 index 9bea27af196c..000000000000 --- a/.github/workflows/doc-label.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: "PR Doc Labeler" -on: - pull_request_target: - types: [opened, edited, synchronize, ready_for_review, auto_merge_enabled, labeled, unlabeled] - -permissions: - pull-requests: write - contents: read - -jobs: - triage: - if: ${{ github.repository == 'GreptimeTeam/greptimedb' }} - runs-on: ubuntu-latest - steps: - - uses: github/issue-labeler@v3.4 - with: - configuration-path: .github/doc-label-config.yml - enable-versioned-regex: false - repo-token: ${{ secrets.GITHUB_TOKEN }} - sync-labels: 1 - - name: create an issue in doc repo - uses: dacbd/create-issue-action@v1.2.1 - if: ${{ github.event.action == 'opened' && contains(github.event.pull_request.body, '- [ ] This PR does not require documentation updates.') }} - with: - owner: GreptimeTeam - repo: docs - token: ${{ secrets.DOCS_REPO_TOKEN }} - title: Update docs for ${{ github.event.issue.title || github.event.pull_request.title }} - body: | - A document change request is generated from - ${{ github.event.issue.html_url || github.event.pull_request.html_url }} - - name: Check doc labels - uses: docker://agilepathway/pull-request-label-checker:latest - with: - one_of: Doc update required,Doc not needed - repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/docbot.yml b/.github/workflows/docbot.yml new file mode 100644 index 000000000000..bd895c53d184 --- /dev/null +++ b/.github/workflows/docbot.yml @@ -0,0 +1,22 @@ +name: Follow Up Docs +on: + pull_request_target: + types: [opened, edited] + +permissions: + pull-requests: write + contents: read + +jobs: + docbot: + runs-on: ubuntu-20.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-cyborg + - name: Maybe Follow Up Docs Issue + working-directory: cyborg + run: pnpm tsx bin/follow-up-docs-issue.ts + env: + DOCS_REPO_TOKEN: ${{ secrets.DOCS_REPO_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index b8b2dfe418e2..608e56ec0abd 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -16,16 +16,7 @@ jobs: if: ${{ github.repository == 'GreptimeTeam/greptimedb' }} steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 22 - - uses: pnpm/action-setup@v3 - with: - package_json_file: 'cyborg/package.json' - run_install: true - - name: Describe the Environment - working-directory: cyborg - run: pnpm tsx -v + - uses: ./.github/actions/setup-cyborg - name: Do Maintenance working-directory: cyborg run: pnpm tsx bin/schedule.ts diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml index f67fb1d4072a..3dae57ff7683 100644 --- a/.github/workflows/semantic-pull-request.yml +++ b/.github/workflows/semantic-pull-request.yml @@ -13,16 +13,7 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 22 - - uses: pnpm/action-setup@v3 - with: - package_json_file: 'cyborg/package.json' - run_install: true - - name: Describe the Environment - working-directory: cyborg - run: pnpm tsx -v + - uses: ./.github/actions/setup-cyborg - name: Check Pull Request working-directory: cyborg run: pnpm tsx bin/check-pull-request.ts diff --git a/cyborg/bin/follow-up-docs-issue.ts b/cyborg/bin/follow-up-docs-issue.ts new file mode 100644 index 000000000000..e08bfee0834a --- /dev/null +++ b/cyborg/bin/follow-up-docs-issue.ts @@ -0,0 +1,106 @@ +/* + * Copyright 2023 Greptime Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as core from '@actions/core' +import {handleError, obtainClient} from "@/common"; +import {context} from "@actions/github"; +import {PullRequestEditedEvent, PullRequestEvent, PullRequestOpenedEvent} from "@octokit/webhooks-types"; +// @ts-expect-error moduleResolution:nodenext issue 54523 +import {RequestError} from "@octokit/request-error"; + +const needFollowUpDocs = "[x] This PR requires documentation updates." +const labelDocsNotRequired = "docs-not-required" +const labelDocsRequired = "docs-required" + +async function main() { + if (!context.payload.pull_request) { + throw new Error(`Only pull request event supported. ${context.eventName} is unsupported.`) + } + + const client = obtainClient("GITHUB_TOKEN") + const docsClient = obtainClient("DOCS_REPO_TOKEN") + const payload = context.payload as PullRequestEvent + const { owner, repo, number, actor, title, html_url } = { + owner: payload.pull_request.base.user.login, + repo: payload.pull_request.base.repo.name, + number: payload.pull_request.number, + title: payload.pull_request.title, + html_url: payload.pull_request.html_url, + actor: payload.pull_request.user.login, + } + const followUpDocs = checkPullRequestEvent(payload) + if (followUpDocs) { + core.info("Follow up docs.") + await client.rest.issues.removeLabel({ + owner, repo, issue_number: number, name: labelDocsNotRequired, + }).catch((e: RequestError) => { + if (e.status != 404) { + throw e; + } + core.debug(`Label ${labelDocsNotRequired} not exist.`) + }) + await client.rest.issues.addLabels({ + owner, repo, issue_number: number, labels: [labelDocsRequired], + }) + await docsClient.rest.issues.create({ + owner: 'GreptimeTeam', + repo: 'docs', + title: `Update docs for ${title}`, + body: `A document change request is generated from ${html_url}`, + assignee: actor, + }).then((res) => { + core.info(`Created issue ${res.data}`) + }) + } else { + core.info("No need to follow up docs.") + await client.rest.issues.removeLabel({ + owner, repo, issue_number: number, name: labelDocsRequired + }).catch((e: RequestError) => { + if (e.status != 404) { + throw e; + } + core.debug(`Label ${labelDocsRequired} not exist.`) + }) + await client.rest.issues.addLabels({ + owner, repo, issue_number: number, labels: [labelDocsNotRequired], + }) + } +} + +function checkPullRequestEvent(payload: PullRequestEvent) { + switch (payload.action) { + case "opened": + return checkPullRequestOpenedEvent(payload as PullRequestOpenedEvent) + case "edited": + return checkPullRequestEditedEvent(payload as PullRequestEditedEvent) + default: + throw new Error(`${payload.action} is unsupported.`) + } +} + +function checkPullRequestOpenedEvent(event: PullRequestOpenedEvent): boolean { + // @ts-ignore + return event.pull_request.body?.includes(needFollowUpDocs) +} + +function checkPullRequestEditedEvent(event: PullRequestEditedEvent): boolean { + const previous = event.changes.body?.from.includes(needFollowUpDocs) + const current = event.pull_request.body?.includes(needFollowUpDocs) + // from docs-not-need to docs-required + return (!previous) && current +} + +main().catch(handleError) diff --git a/cyborg/package.json b/cyborg/package.json index d340a41d3573..742c6f06bf69 100644 --- a/cyborg/package.json +++ b/cyborg/package.json @@ -7,6 +7,7 @@ "dependencies": { "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", + "@octokit/request-error": "^6.1.1", "@octokit/webhooks-types": "^7.5.1", "conventional-commit-types": "^3.0.0", "conventional-commits-parser": "^5.0.0", diff --git a/cyborg/pnpm-lock.yaml b/cyborg/pnpm-lock.yaml index 651a3bcbd3d8..5ac1962cedc6 100644 --- a/cyborg/pnpm-lock.yaml +++ b/cyborg/pnpm-lock.yaml @@ -11,6 +11,9 @@ dependencies: '@actions/github': specifier: ^6.0.0 version: 6.0.0 + '@octokit/request-error': + specifier: ^6.1.1 + version: 6.1.1 '@octokit/webhooks-types': specifier: ^7.5.1 version: 7.5.1 @@ -359,6 +362,13 @@ packages: once: 1.4.0 dev: false + /@octokit/request-error@6.1.1: + resolution: {integrity: sha512-1mw1gqT3fR/WFvnoVpY/zUM2o/XkMs/2AszUUG9I69xn0JFLv6PGkPhNk5lbfvROs79wiS0bqiJNxfCZcRJJdg==} + engines: {node: '>= 18'} + dependencies: + '@octokit/types': 13.5.0 + dev: false + /@octokit/request@8.4.0: resolution: {integrity: sha512-9Bb014e+m2TgBeEJGEbdplMVWwPmL1FPtggHQRkV+WVsMggPtEkLKPlcVYm/o8xKLkpJ7B+6N8WfQMtDLX2Dpw==} engines: {node: '>= 18'} diff --git a/src/datatypes/src/data_type.rs b/src/datatypes/src/data_type.rs index a73c7df86698..f74a94c7a14f 100644 --- a/src/datatypes/src/data_type.rs +++ b/src/datatypes/src/data_type.rs @@ -23,6 +23,7 @@ use arrow_schema::DECIMAL_DEFAULT_SCALE; use common_decimal::decimal128::DECIMAL128_MAX_PRECISION; use common_time::interval::IntervalUnit; use common_time::timestamp::TimeUnit; +use enum_dispatch::enum_dispatch; use paste::paste; use serde::{Deserialize, Serialize}; @@ -41,7 +42,7 @@ use crate::value::Value; use crate::vectors::MutableVector; #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] -#[enum_dispatch::enum_dispatch(DataType)] +#[enum_dispatch(DataType)] pub enum ConcreteDataType { Null(NullType), Boolean(BooleanType),