Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve ci workflows #1247

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 19 additions & 27 deletions .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
name: Build and Publish (Snapshot)

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

on:
Expand All @@ -29,53 +29,45 @@ on:
- cron: "0 0 * * *"

jobs:
checks:
uses: ./.github/workflows/checks.yml

build:
runs-on: ubuntu-latest
needs:
- checks
strategy:
fail-fast: false
matrix:
java-version: [11, 17]
java-version:
- 11
- 17
- 21
etcd:
- gcr.io/etcd-development/etcd:v3.5.9
- gcr.io/etcd-development/etcd:v3.4.26
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Up Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: 'gradle'
- name: Build Project
env:
ETCD_IMAGE: ${{ matrix.etcd }}
run: |
export TC_USER="$(id -u):$(id -g)"
echo "tc user -> $TC_USER"

./gradlew spotlessCheck
./gradlew test
- gcr.io/etcd-development/etcd:v3.4.27
uses: ./.github/workflows/build.yml
with:
javaVersion: "${{ matrix.java-version }}"
etcdImage: "${{ matrix.etcd }}"

publish:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
- name: 'Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Up Java
- name: 'Set Up Java'
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
cache: 'gradle'
- name: Collect Info
- name: 'Collect Info'
run: |
./gradlew currentVersion
- name: Publish Snapshot
- name: 'Publish Snapshot'
if: github.event_name != 'schedule'
env:
NEXUS_USERNAME: ${{ secrets.OSSRH_USERNAME }}
Expand Down
54 changes: 14 additions & 40 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
name: Build PR

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

permissions:
Expand All @@ -30,48 +30,22 @@ on:
workflow_dispatch:

jobs:
precheck:
runs-on: ubuntu-latest
checks:
uses: ./.github/workflows/checks.yml

steps:
- name: Checkout the source
uses: actions/checkout@v4

- name: Run precheck script
run: bash ./.github/workflows/scripts/precheck.sh
shell: bash

deps:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
build:
runs-on: ubuntu-latest
needs:
- checks
strategy:
fail-fast: false
matrix:
java-version: [11, 17]
java-version:
- 11
- 17
- 21
etcd:
- gcr.io/etcd-development/etcd:v3.5.9
- gcr.io/etcd-development/etcd:v3.4.26
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Up Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: 'gradle'
- name: Build Project
env:
ETCD_IMAGE: ${{ matrix.etcd }}
run: |
export TC_USER="$(id -u):$(id -g)"
echo "tc user -> $TC_USER"

./gradlew check -x test
./gradlew test
- gcr.io/etcd-development/etcd:v3.4.27
uses: ./.github/workflows/build.yml
with:
javaVersion: "${{ matrix.java-version }}"
etcdImage: "${{ matrix.etcd }}"
81 changes: 0 additions & 81 deletions .github/workflows/build-tag.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build

on:
workflow_call:
inputs:
javaVersion:
required: true
type: string
etcdImage:
required: true
type: string


jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Set Up Java'
uses: actions/setup-java@v3
with:
java-version: ${{ inputs.javaVersion }}
distribution: 'temurin'
cache: 'gradle'
- name: 'Build Project'
env:
ETCD_IMAGE: ${{ inputs.etcdImage }}
run: |
export TC_USER="$(id -u):$(id -g)"
echo "tc user -> $TC_USER"

./gradlew test --info
36 changes: 36 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Checks

on:
workflow_call:


jobs:
check:
runs-on: ubuntu-latest

steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Set Up Java'
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
cache: 'gradle'
- name: 'Run check task'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it need to setup java 11? same with the publish of main.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

run: |
./gradlew check -x test
- name: 'Run check script'
run: |
bash ./.github/workflows/scripts/precheck.sh
shell: bash

deps:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
10 changes: 9 additions & 1 deletion .github/workflows/scripts/precheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ failed=0
files=$(find . -type f \
-not -path "./.git/*" \
-not -path "*/.gradle/*" \
-not -path "*/.idea/*" \
-not -path "*/.vscode/*" \
-not -path "*/build/*" \
-not -path "*/out/*" \
-not -path "*/bin/*" \
-not -name "*.jar" \
-not -name "*.java" \
-exec egrep -l " +$" {} \;)
-exec grep -E -l " +$" {} \;)

count=0

Expand All @@ -27,7 +31,11 @@ fi
files=$(find . -type f -size +0c \
-not -path "./.git/*" \
-not -path "*/.gradle/*" \
-not -path "*/.idea/*" \
-not -path "*/.vscode/*" \
-not -path "*/build/*" \
-not -path "*/out/*" \
-not -path "*/bin/*" \
-not -name "*.jar" \
-not -name "*.java" \
-exec bash -c 'if [[ $(tail -c1 "$0" | wc -l) -eq 0 ]]; then echo "$0"; fi' {} \;)
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading