Skip to content

Commit

Permalink
chore(ci): update CI config
Browse files Browse the repository at this point in the history
- add `JDK 20/21-ea` into GitHub CI 🤖
- use GitHub action 🐙 `strong_ci.yaml` instead of `appveyor.yml`
- upgrade `bash-buddy` to `v0.3.3`
- remove invalid `codeclimate` badge
- upgrade dependencies/plugins 🛠️
  • Loading branch information
oldratlee committed Aug 14, 2023
1 parent 2b82722 commit a6fa680
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Quickstart for GitHub Actions
# https://docs.github.com/en/actions/quickstart
name: CI
name: fast CI
on: [ push, pull_request, workflow_dispatch ]

jobs:
Expand All @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
java: [ 8, 11, 17, 19, 20-ea ]
java: [ 8, 11, 17, 20, 21-ea ]
fail-fast: false
max-parallel: 64
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/strong_ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Quickstart for GitHub Actions
# https://docs.github.com/en/actions/quickstart

name: Strong CI
on: [ push, pull_request, workflow_dispatch ]
jobs:
test:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners
runs-on: ubuntu-latest
timeout-minutes: 15
name: test by multiply java versions

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: setup Java 8
uses: actions/setup-java@v3
with:
java-version: 8
distribution: zulu
# only first java setup need enable cache
cache: maven
- name: setup Java 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: microsoft
- name: setup Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: microsoft
- name: setup Java 20
uses: actions/setup-java@v3
with:
java-version: 20
distribution: zulu
- name: setup Java 21
uses: actions/setup-java@v3
with:
java-version: 21-ea
distribution: zulu

- name: run integration test
run: scripts/integration-test.sh
env:
JAVA8_HOME: ${{ env.JAVA_HOME_8_X64 }}
JAVA11_HOME: ${{ env.JAVA_HOME_11_X64 }}
JAVA17_HOME: ${{ env.JAVA_HOME_17_X64 }}
JAVA20_HOME: ${{ env.JAVA_HOME_20_X64 }}
JAVA21_HOME: ${{ env.JAVA_HOME_21_X64 }}

- name: remove self maven install files
run: rm -rf $HOME/.m2/repository/com/alibaba/{transmittable-thread-local,ttl}*

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 1 addition & 2 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<a href="https://github.com/alibaba/transmittable-thread-local/actions/workflows/ci.yaml"><img src="https://img.shields.io/github/actions/workflow/status/alibaba/transmittable-thread-local/ci.yaml?branch=master&logo=github&logoColor=white" alt="Github Workflow Build Status"></a>
<a href="https://ci.appveyor.com/project/oldratlee/transmittable-thread-local"><img src="https://img.shields.io/appveyor/ci/oldratlee/transmittable-thread-local/master?logo=appveyor&logoColor=white" alt="Appveyor Build Status"></a>
<a href="https://codecov.io/gh/alibaba/transmittable-thread-local/branch/master"><img src="https://img.shields.io/codecov/c/github/alibaba/transmittable-thread-local/master?logo=codecov&logoColor=white" alt="Coverage Status"></a>
<a href="https://codeclimate.com/github/alibaba/transmittable-thread-local/maintainability"><img src="https://img.shields.io/codeclimate/maintainability/alibaba/transmittable-thread-local?logo=codeclimate&logoColor=white" alt="Maintainability"></a>
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-6+-green?logo=openjdk&logoColor=white" alt="JDK support"></a>
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/alibaba/transmittable-thread-local?color=4D7A97&logo=apache" alt="License"></a>
<a href="https://alibaba.github.io/transmittable-thread-local/apidocs/"><img src="https://img.shields.io/github/release/alibaba/transmittable-thread-local?label=javadoc&color=3d7c47&logo=microsoft-academic&logoColor=white" alt="Javadocs"></a>
Expand Down Expand Up @@ -57,7 +56,7 @@
# 🔧 Functions

👉 `TransmittableThreadLocal`(`TTL`): The missing Java™ std lib(simple & 0-dependency) for framework/middleware,
provide an enhanced `InheritableThreadLocal` that transmits values between threads even using thread pooling components. Support `Java 6~19`.
provide an enhanced `InheritableThreadLocal` that transmits values between threads even using thread pooling components. Support `Java 6~21`.

Class [`InheritableThreadLocal`](https://docs.oracle.com/javase/10/docs/api/java/lang/InheritableThreadLocal.html) in `JDK`
can transmit value to child thread from parent thread.
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<a href="https://github.com/alibaba/transmittable-thread-local/actions/workflows/ci.yaml"><img src="https://img.shields.io/github/actions/workflow/status/alibaba/transmittable-thread-local/ci.yaml?branch=master&logo=github&logoColor=white" alt="Github Workflow Build Status"></a>
<a href="https://ci.appveyor.com/project/oldratlee/transmittable-thread-local"><img src="https://img.shields.io/appveyor/ci/oldratlee/transmittable-thread-local/master?logo=appveyor&logoColor=white" alt="Appveyor Build Status"></a>
<a href="https://codecov.io/gh/alibaba/transmittable-thread-local/branch/master"><img src="https://img.shields.io/codecov/c/github/alibaba/transmittable-thread-local/master?logo=codecov&logoColor=white" alt="Coverage Status"></a>
<a href="https://codeclimate.com/github/alibaba/transmittable-thread-local/maintainability"><img src="https://img.shields.io/codeclimate/maintainability/alibaba/transmittable-thread-local?logo=codeclimate&logoColor=white" alt="Maintainability"></a>
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-6+-green?logo=openjdk&logoColor=white" alt="JDK support"></a>
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/alibaba/transmittable-thread-local?color=4D7A97&logo=apache" alt="License"></a>
<a href="https://alibaba.github.io/transmittable-thread-local/apidocs/"><img src="https://img.shields.io/github/release/alibaba/transmittable-thread-local?label=javadoc&color=3d7c47&logo=microsoft-academic&logoColor=white" alt="Javadocs"></a>
Expand Down Expand Up @@ -60,7 +59,7 @@

# 🔧 功能

👉 `TransmittableThreadLocal`(`TTL`):在使用线程池等会池化复用线程的执行组件情况下,提供`ThreadLocal`值的传递功能,解决异步执行时上下文传递的问题。一个`Java`标准库本应为框架/中间件设施开发提供的标配能力,本库功能聚焦 & 0依赖,支持`Java 6~20`
👉 `TransmittableThreadLocal`(`TTL`):在使用线程池等会池化复用线程的执行组件情况下,提供`ThreadLocal`值的传递功能,解决异步执行时上下文传递的问题。一个`Java`标准库本应为框架/中间件设施开发提供的标配能力,本库功能聚焦 & 0依赖,支持`Java 6~21`

`JDK`[`InheritableThreadLocal`](https://docs.oracle.com/javase/10/docs/api/java/lang/InheritableThreadLocal.html)类可以完成父线程到子线程的值传递。但对于使用线程池等会池化复用线程的执行组件的情况,线程由线程池创建好,并且线程是池化起来反复使用的;这时父子线程关系的`ThreadLocal`值传递已经没有意义,应用需要的实际上是把 **任务提交给线程池时**`ThreadLocal`值传递到 **任务执行时**

Expand Down
48 changes: 0 additions & 48 deletions appveyor.yml

This file was deleted.

15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@
<jsr305.version>3.0.2</jsr305.version>
<jetbrains.annotations.version>24.0.1</jetbrains.annotations.version>

<kotlin.version>1.8.22</kotlin.version>
<kotlin.version>1.9.0</kotlin.version>
<kotlin.compiler.jvmTarget>${maven.compiler.source}</kotlin.compiler.jvmTarget>
<kotlin.coroutine.version>1.7.2</kotlin.coroutine.version>
<kotlin.coroutine.version>1.7.3</kotlin.coroutine.version>
<!-- https://kotlin.github.io/dokka/1.7.10/user_guide/maven/usage/ -->
<dokka.version>1.8.20</dokka.version>
<dokka.link.jdk.version>8</dokka.link.jdk.version>

<slf4j.version>2.0.3</slf4j.version>
<slf4j.version>2.0.7</slf4j.version>

<!-- testing dependencies versions -->
<junit5.version>5.9.3</junit5.version>
<junit5.version>5.10.0</junit5.version>
<kotest.version>5.6.2</kotest.version>

<!--
Expand Down Expand Up @@ -807,6 +807,13 @@
</profile>
<profile>
<id>gen-code-cov</id>
<activation>
<property>
<!-- https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables -->
<name>env.CI</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
Expand Down
76 changes: 44 additions & 32 deletions scripts/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,85 +4,97 @@ cd "$(dirname "$(readlink -f "$0")")"

BASH_BUDDY_ROOT="$(readlink -f bash-buddy)"
readonly BASH_BUDDY_ROOT

source "$BASH_BUDDY_ROOT/lib/trap_error_info.sh"
source "$BASH_BUDDY_ROOT/lib/common_utils.sh"
source "$BASH_BUDDY_ROOT/lib/java_utils.sh"
source "$BASH_BUDDY_ROOT/lib/maven_utils.sh"

################################################################################
# prepare
# ci build logic
################################################################################

readonly default_build_jdk_version=11
# shellcheck disable=SC2034
readonly PREPARE_JDKS_INSTALL_BY_SDKMAN=(
readonly JDK_VERSIONS=(
8
"$default_build_jdk_version"
17
20
21
)

source "$BASH_BUDDY_ROOT/lib/prepare_jdks.sh"

source "$BASH_BUDDY_ROOT/lib/java_build_utils.sh"

# here use `install` and `-D performRelease` intended
# to check release operations.
#
# De-activate a maven profile from command line
# https://stackoverflow.com/questions/25201430
#
# shellcheck disable=SC2034
JVB_MVN_OPTS=(
"${JVB_DEFAULT_MVN_OPTS[@]}"
readonly MVU_MVN_OPTS=(
"${MVU_DEFAULT_MVN_OPTS[@]}"
-DperformRelease -P'!gen-sign'
# Maven Plugin Validation
# https://maven.apache.org/guides/plugins/validation/index.html
-Dmaven.plugin.validation=NONE
${CI_MORE_MVN_OPTS:+${CI_MORE_MVN_OPTS}}
)

################################################################################
# ci build logic
################################################################################

PROJECT_ROOT_DIR="$(readlink -f ..)"
readonly PROJECT_ROOT_DIR
cd "$PROJECT_ROOT_DIR"
cd ..

########################################
# do build and test by default version jdk
# build and test by default version jdk
########################################

prepare_jdks::switch_to_jdk "$default_build_jdk_version"
jvu::switch_to_jdk "$default_build_jdk_version"

cu::head_line_echo "build and test with Java: $JAVA_HOME"
jvb::mvn_cmd clean install
cu::head_line_echo "build and test with Java $default_build_jdk_version: $JAVA_HOME"
mvu::mvn_cmd clean install

########################################
# test by multi-version jdk
########################################
for jdk in "${PREPARE_JDKS_INSTALL_BY_SDKMAN[@]}"; do
prepare_jdks::switch_to_jdk "$jdk"

# just test without build
# about CI env var
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if [ "${CI:-}" = true ]; then
readonly CI_MORE_BEGIN_OPTS=jacoco:prepare-agent CI_MORE_END_OPTS=jacoco:report
fi

# default jdk already tested above
if [ "$jdk" != "$default_build_jdk_version" ]; then
for jdk_version in "${JDK_VERSIONS[@]}"; do
jvu::switch_to_jdk "$jdk_version"

# just test without build
if [ "$jdk_version" = "$default_build_jdk_version" ]; then
# default jdk already tested above
cu::head_line_echo "test with Java: $JAVA_HOME"
jvb::mvn_cmd surefire:test -Denforcer.skip
mvu::mvn_cmd ${CI_MORE_BEGIN_OPTS:-} surefire:test -Denforcer.skip ${CI_MORE_END_OPTS:-}
fi

(
cd ttl2-compatible
cu::head_line_echo "test with TTL Agent and Java: $JAVA_HOME"

cu::blue_echo 'Run unit test under ttl agent, include check for ExecutorService, ForkJoinPool, Timer/TimerTask'
jvb::mvn_cmd -Penable-ttl-agent-for-test surefire:test -Denforcer.skip \
-Dttl.agent.extra.d.options='-Drun-ttl-test-under-agent-with-enable-timer-task=true'
mvu::mvn_cmd ${CI_MORE_BEGIN_OPTS:-} \
surefire:test -Denforcer.skip \
-Penable-ttl-agent-for-test \
-Dttl.agent.extra.d.options='-Drun-ttl-test-under-agent-with-enable-timer-task=true' \
${CI_MORE_END_OPTS:-}

cu::blue_echo 'Run unit test under ttl agent, and turn on the disable inheritable for thread pool enhancement'
jvb::mvn_cmd -Penable-ttl-agent-for-test surefire:test -Denforcer.skip \
mvu::mvn_cmd ${CI_MORE_BEGIN_OPTS:-} \
surefire:test -Denforcer.skip \
-Penable-ttl-agent-for-test \
-Dttl.agent.extra.args='ttl.agent.disable.inheritable.for.thread.pool:true' \
-Dttl.agent.extra.d.options='-Drun-ttl-test-under-agent-with-disable-inheritable=true'
-Dttl.agent.extra.d.options='-Drun-ttl-test-under-agent-with-disable-inheritable=true' \
${CI_MORE_END_OPTS:-}

cu::blue_echo 'Run agent check for Timer/TimerTask, explicit "ttl.agent.enable.timer.task"'
jvb::mvn_cmd -Penable-ttl-agent-for-test surefire:test -Denforcer.skip \
mvu::mvn_cmd ${CI_MORE_BEGIN_OPTS:-} \
surefire:test -Denforcer.skip \
-Penable-ttl-agent-for-test \
-Dttl.agent.extra.args='ttl.agent.enable.timer.task:true' \
-Dttl.agent.extra.d.options='-Drun-ttl-test-under-agent-with-enable-timer-task=true'
-Dttl.agent.extra.d.options='-Drun-ttl-test-under-agent-with-enable-timer-task=true' \
${CI_MORE_END_OPTS:-}
)
done
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@
</profile>
<profile>
<id>gen-code-cov</id>
<activation>
<property>
<!-- https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables -->
<name>env.CI</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
Expand Down
7 changes: 7 additions & 0 deletions ttl2-compatible/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@
</profile>
<profile>
<id>gen-code-cov</id>
<activation>
<property>
<!-- https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables -->
<name>env.CI</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
Expand Down

0 comments on commit a6fa680

Please sign in to comment.