From be8809195019288f84679ddcc322126b51101fd7 Mon Sep 17 00:00:00 2001 From: Alexey Date: Wed, 16 Oct 2024 16:28:44 +0800 Subject: [PATCH] dbeaver/dbeaver-devops#1525 update ci workflows (#2998) * dbeaver/dbeaver-devops#1525 update ci workflows * dbeaver/dbeaver-devops#1525 fix frontend lint * dbeaver/dbeaver-devops#1525 move checkstyle config from dbeaver repo * dbeaver/dbeaver-devops#1525 use own maven setup action * dbeaver/dbeaver-devops#1525 reuse workflows * dbeaver/dbeaver-devops#1525 fix concurrency * dbeaver/dbeaver-devops#1525 fix concurrency --- .github/workflows/backend-build.yml | 40 +++++-------- .github/workflows/backend-lint.yml | 40 ------------- .github/workflows/common-cleanup.yml | 57 +++---------------- .github/workflows/frontend-build.yml | 37 ++++-------- .github/workflows/frontend-lint.yml | 38 ++++++------- .../{common.yml => push-pr-devel.yml} | 50 ++++++++-------- .vscode/settings.json | 2 +- 7 files changed, 75 insertions(+), 189 deletions(-) delete mode 100644 .github/workflows/backend-lint.yml rename .github/workflows/{common.yml => push-pr-devel.yml} (58%) diff --git a/.github/workflows/backend-build.yml b/.github/workflows/backend-build.yml index 987763d5a6..de825cddf9 100644 --- a/.github/workflows/backend-build.yml +++ b/.github/workflows/backend-build.yml @@ -1,20 +1,24 @@ name: Backend Build on: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - # Allows you to reuse workflows by referencing their YAML files workflow_call: jobs: build-backend: - name: Backend + name: Build + timeout-minutes: 10 runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + path: cloudbeaver + + - name: Clone Deps Repositories + uses: dbeaver/github-actions/clone-repositories@devel + with: + project_deps_path: './cloudbeaver/project.deps' - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -23,34 +27,16 @@ jobs: java-version: "17" cache: maven - - uses: stCarolas/setup-maven@v5 - with: - maven-version: 3.9.0 - - - name: Give permissions - run: | - sudo chmod 777 ../ - shell: bash - - - name: Determine branches - id: determine-branch - run: | - echo "pr_branch=${{ github.head_ref }}" >> $GITHUB_ENV - echo "base_branch=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV - - - name: Clone dbeaver/dbeaver - id: clone-repo - run: | - git clone -b ${{ env.pr_branch }} https://github.com/dbeaver/dbeaver.git ../dbeaver || git clone -b ${{ env.base_branch }} https://github.com/dbeaver/dbeaver.git ../dbeaver + - uses: dbeaver/github-actions/install-maven@devel - name: Run build script run: ./build-backend.sh shell: bash - working-directory: ./deploy + working-directory: ./cloudbeaver/deploy - name: Archive build artifacts uses: actions/upload-artifact@v4 with: name: backend-build-artifacts - path: deploy/cloudbeaver + path: cloudbeaver/deploy/cloudbeaver if-no-files-found: error diff --git a/.github/workflows/backend-lint.yml b/.github/workflows/backend-lint.yml deleted file mode 100644 index 17bea9c8f1..0000000000 --- a/.github/workflows/backend-lint.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Backend Lint - -on: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - - # Allows you to reuse workflows by referencing their YAML files - workflow_call: - inputs: - skip_cache: - required: false - type: string - -jobs: - lint: - name: Backend - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Checkout checkstyle config repository - uses: actions/checkout@v4 - with: - repository: dbeaver/dbeaver - path: dbeaver-config - - - name: Copy checkstyle config - run: cp dbeaver-config/dbeaver-checkstyle-config.xml ./dbeaver-checkstyle-config.xml - - - name: Remove checkstyle config directory - run: rm -rf dbeaver-config - - - uses: dbelyaev/action-checkstyle@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - reporter: github-pr-review - filter_mode: diff_context - checkstyle_config: ./dbeaver-checkstyle-config.xml - fail_on_error: true diff --git a/.github/workflows/common-cleanup.yml b/.github/workflows/common-cleanup.yml index 8914495aee..9acd34dd17 100644 --- a/.github/workflows/common-cleanup.yml +++ b/.github/workflows/common-cleanup.yml @@ -1,57 +1,14 @@ -name: Cleanup checks +name: Cleanup on: pull_request: types: [closed] + push: + branches: + - devel jobs: delete-caches: - runs-on: ubuntu-latest - steps: - - name: Cleanup - run: | - gh extension install actions/gh-actions-cache - - echo "Fetching list of cache key" - cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) - - ## Setting this to not fail the workflow while deleting cache keys. - set +e - echo "Deleting caches..." - for cacheKey in $cacheKeysForPR - do - gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm - done - echo "Done" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ github.repository }} - BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge - - # delete-docker-image: - # name: Delete Docker Image - # if: github.event.pull_request.merged == true - # runs-on: ubuntu-latest - - # steps: - # - name: Check out the repository - # uses: actions/checkout@v4 - - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - - # - name: Determine Docker Image Tag - # run: | - # REPO_NAME=$(basename ${{ github.repository }}) - # IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/$REPO_NAME - # BRANCH_NAME=${{ github.event.pull_request.head.ref }} - # TAG_NAME=$(echo $BRANCH_NAME | sed 's/[^a-zA-Z0-9._-]/-/g') - # echo "image=$IMAGE_NAME:$TAG_NAME" >> $GITHUB_ENV - - # - name: Log in to GitHub Container Registry - # run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin - - # - name: Delete Docker Image - # run: | - # docker rmi ${{ env.image }} - # echo "Deleted image: ${{ env.image }}" + name: Cleanup + uses: dbeaver/dbeaver-common/.github/workflows/cleanup-caches.yml@devel + secrets: inherit diff --git a/.github/workflows/frontend-build.yml b/.github/workflows/frontend-build.yml index 11822894bb..b5495fe474 100644 --- a/.github/workflows/frontend-build.yml +++ b/.github/workflows/frontend-build.yml @@ -1,9 +1,6 @@ name: Frontend Build on: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - # Allows you to reuse workflows by referencing their YAML files workflow_call: outputs: @@ -20,8 +17,11 @@ on: jobs: frontend-build: - name: Frontend + name: Build runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read outputs: build-status: ${{ steps.build.outcome }} @@ -34,6 +34,7 @@ jobs: steps: - uses: actions/checkout@v4 + - run: corepack enable - uses: actions/setup-node@v4 with: node-version: "20" @@ -58,30 +59,14 @@ jobs: - name: yarn clean if: env.skip_cache == 'true' - uses: borales/actions-yarn@v5 - with: - dir: webapp - cmd: clean - - - name: yarn install --frozen-lockfile - uses: borales/actions-yarn@v5 - with: - dir: webapp - cmd: install + run: yarn clear - - name: build - id: build - uses: borales/actions-yarn@v5 - with: - dir: webapp/packages/product-default - cmd: bundle + - run: yarn install --immutable + + - run: yarn bundle + working-directory: ./webapp/packages/product-default - - name: test - id: test - uses: borales/actions-yarn@v5 - with: - dir: webapp - cmd: test + - run: yarn test - name: Archive build artifacts uses: actions/upload-artifact@v4 diff --git a/.github/workflows/frontend-lint.yml b/.github/workflows/frontend-lint.yml index 3f22b3df53..0d969da4a3 100644 --- a/.github/workflows/frontend-lint.yml +++ b/.github/workflows/frontend-lint.yml @@ -1,20 +1,25 @@ name: Frontend Lint on: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - # Allows you to reuse workflows by referencing their YAML files workflow_call: jobs: lint: - name: Frontend + name: Lint runs-on: ubuntu-latest - + timeout-minutes: 5 + permissions: + contents: read + + defaults: + run: + working-directory: ./webapp + steps: - uses: actions/checkout@v4 + - run: corepack enable - uses: actions/setup-node@v4 with: node-version: "20" @@ -29,17 +34,12 @@ jobs: restore-keys: | ${{ runner.os }}-node_modules- - - name: yarn install --frozen-lockfile - uses: borales/actions-yarn@v5 - with: - dir: webapp - cmd: install - - - name: Lint - uses: reviewdog/action-eslint@v1 - with: - reporter: github-pr-review - filter_mode: file - workdir: webapp - fail_on_error: true - eslint_flags: "--ext .ts,.tsx" + - run: | + yarn install --immutable + git fetch origin "${{ github.base_ref }}" --depth=1 + FILES=$(git diff --name-only 'origin/${{ github.base_ref }}' ${{ github.sha }} -- . | sed 's|^webapp/||') + if [ -n "$FILES" ]; then + yarn lint --pass-on-no-patterns --no-error-on-unmatched-pattern $FILES + else + echo "No files to lint" + fi diff --git a/.github/workflows/common.yml b/.github/workflows/push-pr-devel.yml similarity index 58% rename from .github/workflows/common.yml rename to .github/workflows/push-pr-devel.yml index 2d1ba04acb..ddcc1e14f8 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/push-pr-devel.yml @@ -1,40 +1,38 @@ -name: Check +name: CI on: - push: - branches: - - devel pull_request: - branches: - - devel + types: + - opened + - synchronize + - reopened + push: + branches: [devel] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - inputs: - skip_cache: - description: "Skip cache restoration" - required: false - default: "false" +concurrency: + group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || 'push-pr-devel' }} + cancel-in-progress: true jobs: - call-backend-build: - name: Build + build-server: + name: Server uses: ./.github/workflows/backend-build.yml + secrets: inherit - call-frontend-build: - name: Build + build-frontend: + name: Frontend uses: ./.github/workflows/frontend-build.yml - with: - skip_cache: ${{ github.event.inputs.skip_cache }} + secrets: inherit - call-frontend-lint: - name: Lint - needs: call-frontend-build - uses: ./.github/workflows/frontend-lint.yml + lint-server: + name: Server + uses: dbeaver/dbeaver-common/.github/workflows/java-checkstyle.yml@devel + secrets: inherit - call-backend-lint: - name: Lint - uses: ./.github/workflows/backend-lint.yml + lint-frontend: + name: Frontend + uses: ./.github/workflows/frontend-lint.yml + secrets: inherit # call-frontend-tests: # name: Frontend Unit Tests diff --git a/.vscode/settings.json b/.vscode/settings.json index 21924f722a..a039fe497d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -46,6 +46,6 @@ "*.css": "postcss" }, - "java.checkstyle.configuration": "${workspaceFolder}/../dbeaver/dbeaver-checkstyle-config.xml", + "java.checkstyle.configuration": "${workspaceFolder}/../dbeaver-common/.github/dbeaver-checkstyle-config.xml", "java.checkstyle.version": "10.12.0" }