Skip to content

Commit

Permalink
dbeaver/dbeaver-devops#1525 add github checks (#42)
Browse files Browse the repository at this point in the history
* dbeaver/dbeaver-devops#1525 add github checks

* chore: rename jobs

* dbeaver/dbeaver-devops#1525 remove pull-repositories action

* dbeaver/dbeaver-devops#1525 rename steps

* dbeaver/dbeaver-devops#1525 reuse workflows

* dbeaver/dbeaver-devops#1525 always pull to subfolder

* dbeaver/dbeaver-devops#1525 try to use mvn from setup-java action

* Revert "dbeaver/dbeaver-devops#1525 try to use mvn from setup-java action"

This reverts commit 1238c10.

* dbeaver/dbeaver-devops#1525 try to use custom mvn install action

* dbeaver/dbeaver-devops#1525 try to use custom mvn install action 2

* dbeaver/dbeaver-devops#1525 try to use custom mvn install action 3

* dbeaver/dbeaver-devops#1525 try to different OS

* dbeaver/dbeaver-devops#1525 try to different OS 2

* dbeaver/dbeaver-devops#1525 try to different OS 3

* dbeaver/dbeaver-devops#1525 try checkstyle

* dbeaver/dbeaver-devops#1525 try checkstyle 2

* dbeaver/dbeaver-devops#1525 try checkstyle 3

* dbeaver/dbeaver-devops#1525 try checkstyle 4

* dbeaver/dbeaver-devops#1525 try checkstyle 5

* dbeaver/dbeaver-devops#1525 try checkstyle 6

* dbeaver/dbeaver-devops#1525 try checkstyle 7

* dbeaver/dbeaver-devops#1525 try checkstyle 8

* dbeaver/dbeaver-devops#1525 use dbelyaev/action-checkstyle@master

* dbeaver/dbeaver-devops#1525 revert checkstyle trigger

* dbeaver/dbeaver-devops#1525 remove comment

* dbeaver/dbeaver-devops#1525 move checkstyle config from dbeaver repo

* dbeaver/dbeaver-devops#1525 clone dbeaver-common for checkstyle config

* dbeaver/dbeaver-devops#1525 use fork for checkstyle action

* dbeaver/dbeaver-devops#1525 simplify workflow

* dbeaver/dbeaver-devops#1525 move checkstyle file
  • Loading branch information
Wroud authored Oct 15, 2024
1 parent 5beceaf commit 605757e
Show file tree
Hide file tree
Showing 7 changed files with 540 additions and 0 deletions.
363 changes: 363 additions & 0 deletions .github/dbeaver-checkstyle-config.xml

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions .github/workflows/cleanup-caches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Cleanup caches

on:
workflow_call:

jobs:
delete-caches:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Cleanup caches
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache keys"
cacheKeys=$(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 $cacheKeys
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || 'refs/heads/main' }}
41 changes: 41 additions & 0 deletions .github/workflows/java-checkstyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint

on:
# Allows you to reuse workflows by referencing their YAML files
workflow_call:

concurrency:
group: |
# For pull requests, group by the pull request ID
${{ github.event_name == 'pull_request' && format('pr-{0}-java-checkstyle', github.event.pull_request.number) }}
# For pushes to main, group by the branch name (e.g., 'main')
${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'main-branch-java-checkstyle' }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Checkout checkstyle config repository
uses: actions/checkout@v4
with:
repository: dbeaver/dbeaver-common
path: dbeaver-common

- run: |
cp dbeaver-common/.github/dbeaver-checkstyle-config.xml ./dbeaver-checkstyle-config.xml
rm -rf dbeaver-common
- uses: dbeaver/action-java-checkstyle@master
with:
reporter: github-pr-annotations
filter_mode: diff_context
checkstyle_config: ./dbeaver-checkstyle-config.xml
fail_on_error: true
69 changes: 69 additions & 0 deletions .github/workflows/mvn-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: MVN Package

on:
workflow_call:
inputs:
project-directory:
required: false
type: string
timeout-minutes:
required: false
type: number
default: 10
project-deps:
required: false
type: string

outputs:
run-id:
value: ${{ jobs.build-and-test.outputs.run-id }}

secrets:
DEVOPS_ISSUE_RO_TOKEN:
required: false

concurrency:
group: |
# For pull requests, group by the pull request ID
${{ github.event_name == 'pull_request' && format('pr-{0}-mvn-package', github.event.pull_request.number) }}
# For pushes to main, group by the branch name (e.g., 'main')
${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'main-branch-mvn-package' }}
cancel-in-progress: true

jobs:
build-and-test:
name: Build
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
permissions:
contents: read

outputs:
run-id: ${{ github.run_id }}

steps:
- name: Set repository path variable
run: echo "CHECKOUT_PATH=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
path: ${{ env.CHECKOUT_PATH || '.' }}

- uses: dbeaver/github-actions/clone-repositories@devel
if: ${{ inputs.project-deps != null }}
with:
project_deps_path: ${{ inputs.project-deps }}
token: ${{ secrets.DEVOPS_ISSUE_RO_TOKEN }}

- uses: dbeaver/github-actions/install-maven@devel
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
cache: maven

- name: Build
run: mvn -B -T 1C clean package
working-directory: ${{ inputs.project-directory || env.CHECKOUT_PATH || '.' }}

14 changes: 14 additions & 0 deletions .github/workflows/pr-close-push-devel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Cleanup

on:
pull_request:
types: [closed]
push:
branches:
- devel

jobs:
delete-caches:
name: Cleanup
uses: ./.github/workflows/cleanup-caches.yml
secrets: inherit
23 changes: 23 additions & 0 deletions .github/workflows/push-pr-devel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
pull_request:
types:
- opened
- synchronize
- reopened
push:
branches: [devel]

jobs:
build:
uses: ./.github/workflows/mvn-package.yml
name: Check
secrets: inherit
with:
timeout-minutes: 5

lint:
uses: ./.github/workflows/java-checkstyle.yml
name: Check
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# java
target/
.project
.classpath
.settings/

0 comments on commit 605757e

Please sign in to comment.