From 3977f89c5b8be125bf549155b3f348e35bbef842 Mon Sep 17 00:00:00 2001 From: mrdrivingduck Date: Tue, 3 Sep 2024 15:07:25 +0800 Subject: [PATCH] ci: support precheck and stylecheck for v15 --- .github/ISSUE_TEMPLATE/bug_report.md | 30 +++++++++++++ .github/ISSUE_TEMPLATE/question.md | 12 +++++ .github/workflows/precheck.yml | 66 ++++++++++++++++++++++++++++ .github/workflows/stylecheck.yml | 58 ++++++++++++++++++++++++ .github/workflows/sync-postgres.yml | 42 ++++++++++++++++++ 5 files changed, 208 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/question.md create mode 100644 .github/workflows/precheck.yml create mode 100644 .github/workflows/stylecheck.yml create mode 100644 .github/workflows/sync-postgres.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000..3a89c17ecfb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,30 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[Bug]" +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. xxx +2. xxx +3. xxx + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Environment (please complete the following information):** + - OS: [e.g. CentOS 7] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 00000000000..f223c068ca0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,12 @@ +--- +name: Question +about: Ask question about anything here. +title: "[Question]" +labels: question +assignees: '' + +--- + +**Describe the problem** + +... diff --git a/.github/workflows/precheck.yml b/.github/workflows/precheck.yml new file mode 100644 index 00000000000..deff9ab6d6c --- /dev/null +++ b/.github/workflows/precheck.yml @@ -0,0 +1,66 @@ +name: precheck + +on: + push: + branches: [ POLARDB_15_STABLE ] + paths: + - '.github/workflows/precheck.yml' + - 'config/**' + - 'contrib/**' + - 'external/**' + - 'src/**' + - 'configure*' + - 'build.sh' + pull_request: + branches: [ POLARDB_15_STABLE ] + paths: + - '.github/workflows/precheck.yml' + - 'config/**' + - 'contrib/**' + - 'external/**' + - 'src/**' + - 'configure*' + - 'build.sh' + # trigger testing manually + workflow_dispatch: + +jobs: + build_normal: + runs-on: ubuntu-latest + strategy: + matrix: + container_image: [ ubuntu20.04, ubuntu22.04, ubuntu24.04, anolis8, rocky8, rocky9 ] + debug_mode: [ on, off ] + steps: + - name: fetch source code + uses: actions/checkout@v4 + + - name: create and start the container + run: | + docker create \ + -t \ + --name polardb_${{ matrix.container_image }} \ + -v `pwd`:/home/postgres/PolarDB-for-PostgreSQL \ + polardb/polardb_pg_devel:${{ matrix.container_image }} \ + bash && \ + docker start polardb_${{ matrix.container_image }} + + - name: change ownership of the source code + run: | + docker exec \ + polardb_${{ matrix.container_image }} \ + bash -c "cd /home/postgres/PolarDB-for-PostgreSQL && \ + sudo chown -R postgres:postgres ./" + + - name: build and run precheck + run: | + docker exec \ + polardb_${{ matrix.container_image }} \ + bash -c "cd /home/postgres/PolarDB-for-PostgreSQL && \ + if [ -f /etc/bashrc ]; then source /etc/bashrc; fi && \ + ./build.sh --ws=1 --wr=2 --debug=${{ matrix.debug_mode }} --jobs=$jobs --ec='--enable-tap-tests' && \ + make precheck -j$jobs" + + - name: change ownership of the source code back + run: | + sudo chown -R runner:runner `pwd` diff --git a/.github/workflows/stylecheck.yml b/.github/workflows/stylecheck.yml new file mode 100644 index 00000000000..8697be37dd3 --- /dev/null +++ b/.github/workflows/stylecheck.yml @@ -0,0 +1,58 @@ +name: stylecheck + +on: + push: + branches: [ POLARDB_15_STABLE ] + pull_request: + branches: [ POLARDB_15_STABLE ] + # trigger testing manually + workflow_dispatch: + +jobs: + build_normal: + runs-on: ubuntu-latest + strategy: + matrix: + container_image: [ ubuntu24.04 ] + steps: + - name: fetch PolarDB source code + uses: actions/checkout@v4 + # for copyright check + with: + fetch-depth: 2 + + - name: create and start the container + run: | + docker create \ + -t \ + --name polardb_${{ matrix.container_image }} \ + -v `pwd`:/home/postgres/PolarDB-for-PostgreSQL \ + polardb/polardb_pg_devel:${{ matrix.container_image }} \ + bash && \ + docker start polardb_${{ matrix.container_image }} + + - name: change ownership of the source code + run: | + docker exec \ + polardb_${{ matrix.container_image }} \ + bash -c "cd /home/postgres/PolarDB-for-PostgreSQL && \ + sudo chown -R postgres:postgres ./" + + - name: stylecheck + run: | + docker exec \ + polardb_${{ matrix.container_image }} \ + bash -c "cd /home/postgres/PolarDB-for-PostgreSQL && \ + ./configure && make stylecheck" + + - name: change ownership of the source code + run: | + sudo chown -R runner:runner `pwd` + + - name: check diff + run: | + if [[ $(git diff --stat) != '' ]]; then \ + git diff >> style.diff; \ + cat style.diff; \ + exit 1; \ + fi diff --git a/.github/workflows/sync-postgres.yml b/.github/workflows/sync-postgres.yml new file mode 100644 index 00000000000..d56e3132af8 --- /dev/null +++ b/.github/workflows/sync-postgres.yml @@ -0,0 +1,42 @@ +name: sync with postgres upstream + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +jobs: + repo-sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: repo-sync-master + uses: repo-sync/github-sync@v2 + with: + source_repo: https://github.com/postgres/postgres.git + source_branch: master + destination_branch: master + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: repo-sync-17 + uses: repo-sync/github-sync@v2 + with: + source_repo: https://github.com/postgres/postgres.git + source_branch: REL_17_STABLE + destination_branch: REL_17_STABLE + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: repo-sync-16 + uses: repo-sync/github-sync@v2 + with: + source_repo: https://github.com/postgres/postgres.git + source_branch: REL_16_STABLE + destination_branch: REL_16_STABLE + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: repo-sync-15 + uses: repo-sync/github-sync@v2 + with: + source_repo: https://github.com/postgres/postgres.git + source_branch: REL_15_STABLE + destination_branch: REL_15_STABLE + github_token: ${{ secrets.GITHUB_TOKEN }}