Skip to content

Commit

Permalink
dbeaver/dbeaver-devops#1525 reuse workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed Oct 14, 2024
1 parent 3c843fe commit 4c37185
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 55 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/build.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
name: Cleanup checks
name: Cleanup caches

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

jobs:
delete-caches:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Cleanup
- name: Cleanup caches
run: |
gh extension install actions/gh-actions-cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ 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
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/mvn-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: MVN Package

on:
workflow_call:
inputs:
project-directory:
required: false
type: string
default: '.'
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
if: ${{ inputs.project-deps != null }}
run: echo "CHECKOUT_PATH=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV

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

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

- uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6

- name: Set up JDK 17
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 }}

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
20 changes: 8 additions & 12 deletions .github/workflows/push-pr-devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@ name: CI

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

concurrency:
group: |
# For pull requests, group by the pull request ID
${{ github.event_name == 'pull_request' && format('pr-{0}', 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' }}
cancel-in-progress: true

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

lint:
uses: ./.github/workflows/lint.yml
uses: ./.github/workflows/java-checkstyle.yml
name: Check
secrets: inherit

0 comments on commit 4c37185

Please sign in to comment.