Skip to content

Commit

Permalink
! update ci scripts, prepair for appveyor ci
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Dec 6, 2021
1 parent cdcdcd1 commit 22859e1
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 77 deletions.
3 changes: 1 addition & 2 deletions README-EN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# [![📌 TransmittableThreadLocal(TTL) 📌](docs/logo-blue.png)](#dummy)

[![Build Status](https://img.shields.io/travis/alibaba/transmittable-thread-local/master?logo=travis-ci&logoColor=white)](https://travis-ci.org/alibaba/transmittable-thread-local)
[![Windows Build Status](https://img.shields.io/appveyor/ci/oldratlee/transmittable-thread-local/master?label=windows%20build&logo=appveyor&logoColor=white)](https://ci.appveyor.com/project/oldratlee/transmittable-thread-local)
[![Build Status](https://img.shields.io/appveyor/ci/oldratlee/transmittable-thread-local/master?logo=appveyor&logoColor=white)](https://ci.appveyor.com/project/oldratlee/transmittable-thread-local)
[![Coverage Status](https://img.shields.io/codecov/c/github/alibaba/transmittable-thread-local/master?logo=codecov&logoColor=white)](https://codecov.io/gh/alibaba/transmittable-thread-local/branch/master)
[![Maintainability](https://badgen.net/codeclimate/maintainability/codeclimate/codeclimate?icon=codeclimate)](https://codeclimate.com/github/alibaba/transmittable-thread-local)
[![JDK support](https://img.shields.io/badge/JDK-6+-green?logo=java&logoColor=white)](https://openjdk.java.net/)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# [![📌 TransmittableThreadLocal(TTL) 📌](docs/logo-blue.png)](#dummy)

[![Build Status](https://img.shields.io/travis/alibaba/transmittable-thread-local/master?logo=travis-ci&logoColor=white)](https://travis-ci.org/alibaba/transmittable-thread-local)
[![Windows Build Status](https://img.shields.io/appveyor/ci/oldratlee/transmittable-thread-local/master?label=windows%20build&logo=appveyor&logoColor=white)](https://ci.appveyor.com/project/oldratlee/transmittable-thread-local)
[![Build Status](https://img.shields.io/appveyor/ci/oldratlee/transmittable-thread-local/master?logo=appveyor&logoColor=white)](https://ci.appveyor.com/project/oldratlee/transmittable-thread-local)
[![Coverage Status](https://img.shields.io/codecov/c/github/alibaba/transmittable-thread-local/master?logo=codecov&logoColor=white)](https://codecov.io/gh/alibaba/transmittable-thread-local/branch/master)
[![Maintainability](https://badgen.net/codeclimate/maintainability/codeclimate/codeclimate?icon=codeclimate)](https://codeclimate.com/github/alibaba/transmittable-thread-local)
[![JDK support](https://img.shields.io/badge/JDK-6+-green?logo=java&logoColor=white)](https://openjdk.java.net/)
Expand Down
108 changes: 71 additions & 37 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,77 @@
# How to use AppVeyor to build a multi-arch Docker image for Linux and Windows
# https://stefanscherer.github.io/use-appveyor-to-build-multi-arch-docker-image/
#
# Building ASP.NET Core apps on both Windows and Linux using AppVeyor
# https://andrewlock.net/building-asp-net-core-apps-on-both-windows-and-linux-using-appveyor/
#
# appveyor.yml Example:
# https://github.com/cdcseacave/openMVS/blob/master/.appveyor.yml

version: '{build}'
os: Windows Server 2012
build: off
image:
- Ubuntu2004
- Visual Studio 2017
build: false
clone_depth: 50
branches:
except:
- travis-ci.*
- travis-ci
- gh-pages

environment:
matrix:
- JAVA_HOME: "C:\\Program Files (x86)\\Java\\jdk1.8.0"
- JAVA_HOME: "C:\\Program Files\\Java\\jdk1.8.0"
- JAVA_HOME: "C:\\Program Files\\Java\\jdk9"
- JAVA_HOME: "C:\\Program Files\\Java\\jdk10"
- JAVA_HOME: "C:\\Program Files\\Java\\jdk11"

init:
- ps: "ls 'C:/Program Files/Java/jdk*'"
- ps: "ls 'C:/Program Files (x86)/Java/jdk*'"

install:
- cmd: SET PATH=%JAVA_HOME%\bin;%PATH%
- cmd: SET MAVEN_OPTS=-Xmx768m -XX:MaxPermSize=128m
- cmd: SET JAVA_OPTS=-Xmx768m -XX:MaxPermSize=128m
- "ECHO JAVA_HOME=%JAVA_HOME%, HOMEPATH=%HOMEPATH%, PATH=%PATH%"
- cmd: ./mvnw.cmd --version

test_script:
- ./mvnw.cmd clean install --batch-mode
- ./mvnw.cmd dependency:copy-dependencies -DincludeScope=test -DexcludeArtifactIds=javassist,jsr305
- echo "Run Agent test"
- ps: |
$ttl_jar=Get-ChildItem target\transmittable-thread-local-*.jar -Exclude *-sources.jar | Select-Object -ExpandProperty FullName
$cp=Get-ChildItem target\dependency\*.jar | Select-Object -ExpandProperty FullName
$cp=$cp + 'target\test-classes'
$cp=$cp -join ';'
echo "java -Xmx256m -Xms256m -javaagent:$ttl_jar -cp $cp -ea com.alibaba.ttl.threadpool.agent.AgentCheck"
$output=java -Xmx256m -Xms256m -javaagent:$ttl_jar -cp $cp -ea com.alibaba.ttl.threadpool.agent.AgentCheck 2>&1
$output.CategoryInfo.TargetName | Out-Default
cache:
- C:\maven\
- C:\Users\appveyor\.m2\
APPVEYOR_YML_DISABLE_PS_LINUX: true
MAVEN_OPTS: "-Xmx768m -XX:MaxPermSize=128m -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2"
JAVA_OPTS: "-Xmx768m -XX:MaxPermSize=128m"

for:
-
#------------------
# Ubuntu
#------------------
matrix:
only:
- image: Ubuntu2004

test_script:
- sh: ./scripts/integration-test.sh

after_test:
- sh: ./scripts/codecov.sh
- sh: rm -rf $HOME/.m2/repository/com/alibaba/transmittable-thread-local*
- sh: rm -rf $HOME/.m2/repository/com/alibaba/ttl*
- sh: rm -rf $HOME/.sdkman/archives/*

cache:
# if cache size is exceed appveyor limit:
# Compressed cache item cannot exceed 1,048,576,000 bytes
# skip below maven cache:
- $HOME/.m2/
- $HOME/.sdkman/
-
#------------------
# Windows
#------------------
matrix:
only:
- image: Visual Studio 2017
install:
- ps: "ls 'C:/Program Files/Java/jdk*'"
- ps: "ls 'C:/Program Files (x86)/Java/jdk*'"
- cmd: echo JAVA_HOME=%JAVA_HOME%, HOMEPATH=%HOMEPATH%, PATH=%PATH%

test_script:
# test under java 8
- cmd: set JAVA_HOME=C:\Program Files\Java\jdk1.8.0
- ./mvnw.cmd -V clean install --no-transfer-progress
# test under java 11
- cmd: set JAVA_HOME=C:\Program Files\Java\jdk11
- ./mvnw.cmd -V clean install --no-transfer-progress

after_test:
- ps: Remove-Item -r -fo $home\.m2\repository\com\alibaba\transmittable-thread-local*
- ps: Remove-Item -r -fo $home\.m2\repository\com\alibaba\ttl*

cache:
# https://www.appveyor.com/docs/build-cache/
- '%HOMEDRIVE%%HOMEPATH%\.m2\'

29 changes: 29 additions & 0 deletions clear-appveyor-cache.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env pwsh

# https://stackoverflow.com/questions/24649019/how-to-use-confirm-in-powershell
$confirmation = Read-Host "Are you Sure You Want To Clear cache of appveyor project oldratlee/transmittable-thread-local"
if ($confirmation -ne 'y') {
Write-Output "do nothing and exit"
exit
}

# PowerShell: Run command from script's directory - Stack Overflow
# https://stackoverflow.com/questions/4724290
$script_path = $MyInvocation.MyCommand.Path
$script_dir = Split-Path $script_path

# Equivalent of bash's `source` command in Powershell? - Super User
# https://superuser.com/questions/71446
# Script scope and dot sourcing - PowerShell | Microsoft Docs
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts#script-scope-and-dot-sourcing
. "$script_dir\appveyor_token.ps1"
# file appveyor_token.ps1 provide appveyor token. content sample:
# $appveyor_token = xxx

# https://www.appveyor.com/docs/build-cache/#remove-cache-entry-from-build-config
# https://www.appveyor.com/docs/api/#authentication

$headers = @{}
$headers['Authorization'] = "Bearer $appveyor_token"
$headers["Content-type"] = "application/json"
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/projects/oldratlee/transmittable-thread-local/buildcache' -Headers $headers -Method Delete
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,6 @@
</profile>
<profile>
<id>gen-code-cov</id>
<activation>
<property>
<name>env.TRAVIS</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
Expand Down
6 changes: 0 additions & 6 deletions pom4ide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,6 @@
</profile>
<profile>
<id>gen-code-cov</id>
<activation>
<property>
<name>env.TRAVIS</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion scripts/codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ source ./ttl_build.sh

switch_to_jdk 8
MVN_WITH_BASIC_OPTIONS clean
MVN_WITH_BASIC_OPTIONS cobertura:cobertura
MVN_WITH_BASIC_OPTIONS -Pgen-code-cov cobertura:cobertura

bash <(curl -s https://codecov.io/bash)
8 changes: 8 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ versionLessThan() {
[ "$(printf '%s\n' "$ver" "$destVer" | sort -V | head -n1)" = "$ver" ]
}

loose() {
set +eEuo pipefail
"$@"
local exit_code=$?
set -eEuo pipefail
return $exit_code
}

logAndRun() {
local simple_mode=false
[ "$1" = "-s" ] && {
Expand Down
2 changes: 1 addition & 1 deletion scripts/common_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ __getMvnwExe() {
}

__getJavaVersion() {
"$JAVA_HOME/bin/java" -version 2>&1 | awk -F\" 'NR == 1 {print $2}'
"$JAVA_HOME/bin/java" -version 2>&1 | awk -F\" '/ version "/{print $2}'
}

__getMoreMvnOptionsWhenJdk11() {
Expand Down
4 changes: 4 additions & 0 deletions scripts/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ export TTL_CI_TEST_MODE=true
source ./prepare-jdk.sh
source ./ttl_build.sh "${1:-}"


# default jdk 11, do build and test
switch_to_jdk 11
headInfo "test with Java 11: $JAVA_HOME"
# run junit test in run-agent-test.sh
logAndRun ./scripts/run-agent-test.sh skipClean


# test multi-version java home env
# shellcheck disable=SC2154
for jhm_var_name in "${java_home_var_names[@]}"; do
[ "$jhm_var_name" = "JDK11_HOME" ] && continue

export JAVA_HOME="${!jhm_var_name}"

headInfo "test with $jhm_var_name: $JAVA_HOME"
Expand Down
39 changes: 17 additions & 22 deletions scripts/prepare-jdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,32 @@ __loadSdkman() {
this_time_install_sdk_man=true
fi

set +u
logAndRun cat "$HOME/.sdkman/etc/config"

# shellcheck disable=SC1090
source "$HOME/.sdkman/bin/sdkman-init.sh"
"$this_time_install_sdk_man" && logAndRun sdk ls java
set -u
loose source "$HOME/.sdkman/bin/sdkman-init.sh"

if "$this_time_install_sdk_man"; then
loose logAndRun sdk ls java | sed -n '/^ Vendor/,/^===========/p'
fi
}
__loadSdkman

jdks_install_by_sdkman=(
7.0.302-zulu
8.0.292-zulu

9.0.7-zulu
10.0.2-zulu
11.0.11-zulu

12.0.2-open
13.0.5-zulu
14.0.2-zulu
15.0.2-zulu
16.0.1-open
17.ea.21-open
6.0.119-zulu
7.0.322-zulu
8.312.07.1-amzn

11.0.13-ms

16.0.2.7.1-amzn
17.0.1-ms
)
java_home_var_names=()

__setJdkHomeVarsAndInstallJdk() {
blueEcho "prepared jdks:"

JDK6_HOME="${JDK6_HOME:-/usr/lib/jvm/java-6-openjdk-amd64}"
java_home_var_names=(JDK6_HOME)
printf '%s :\n\t%s\n' "JDK6_HOME" "${JDK6_HOME}"

local jdkNameOfSdkman
for jdkNameOfSdkman in "${jdks_install_by_sdkman[@]}"; do
Expand All @@ -74,12 +69,12 @@ __setJdkHomeVarsAndInstallJdk() {
# install jdk by sdkman
[ ! -d "$jdkHomePath" ] && {
set +u
logAndRun sdk install java "$jdkNameOfSdkman" || die "fail to install jdk $jdkNameOfSdkman by sdkman"
loose logAndRun sdk install java "$jdkNameOfSdkman" || die "fail to install jdk $jdkNameOfSdkman by sdkman"
set -u
}
fi

java_home_var_names=("${java_home_var_names[@]}" "$jdkHomeVarName")
java_home_var_names=(${java_home_var_names[@]:+"${java_home_var_names[@]}"} "$jdkHomeVarName")
printf '%s :\n\t%s\n\tspecified is %s\n' "$jdkHomeVarName" "${!jdkHomeVarName}" "$jdkNameOfSdkman"
done

Expand Down

0 comments on commit 22859e1

Please sign in to comment.