diff --git a/.circleci/config.yml b/.circleci/config.yml index 7e497d755a..338f7b566b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,6 +31,14 @@ jobs: parallelism: 1 steps: - checkout + - run: if [[ "$CIRCLE_PULL_REQUEST" == "" && "$CIRCLE_BRANCH" != "main" && "$CIRCLE_BRANCH" != *-release ]]; then echo "Not a PR, not the main branch and not a release branch, skip test!"; circleci-agent step halt; fi + - run: 'curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/${CIRCLE_PULL_REQUEST##*/} >> github.txt' + - run: cat github.txt + - run: (python3 -c 'import json; from datetime import datetime; fp = open("github.txt"); data = json.load(fp); fp.close(); f = "%Y-%m-%dT%H:%M:%SZ"; created = datetime.strptime(data["created_at"], f); updated = datetime.strptime(data["updated_at"], f); s = (updated - created).total_seconds(); print(int(s))' || true) > elapsed.txt + - run: if [ "$(cat elapsed.txt)" == "" ]; then echo 60 > elapsed.txt; fi + - run: cat elapsed.txt + - run: if [ "$(cat elapsed.txt)" -lt "30" ]; then echo "PR is just opened, wait some actions from GitHub"; sleep 30; fi + - run: 'if grep -q "\"draft\": true," github.txt; then echo "draft mode, skip test!"; circleci-agent step halt; fi' - run: uv pip install -U -e . - run: echo 'export "GIT_COMMIT_MESSAGE=$(git show -s --format=%s)"' >> "$BASH_ENV" && source "$BASH_ENV" - run: mkdir -p test_preparation diff --git a/.github/workflows/change_pr_to_draft.yml b/.github/workflows/change_pr_to_draft.yml new file mode 100644 index 0000000000..c70ffba759 --- /dev/null +++ b/.github/workflows/change_pr_to_draft.yml @@ -0,0 +1,22 @@ +name: Change PR to draft + +on: + pull_request_target: + types: [opened, reopened] + +jobs: + convert_pr_to_draft: + runs-on: ubuntu-22.04 + name: Convert PR to draft + if: github.event.pull_request.draft == false + steps: + - name: Convert PR to draft + shell: bash + env: + PR_NUMBER: ${{ github.event.number }} + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + run: | + echo $PR_NUMBER + gh pr ready $PR_NUMBER --repo $REPO --undo + gh pr comment $PR_NUMBER --repo $REPO --body "Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the \`Ready for review\` button (at the bottom of the PR page)."