diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 7f635f05f..011787bdb 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -3,33 +3,34 @@ name: Codecov on: push: branches: - - hoxton + - 2022.0 - 2021.0 - 2020.0 + - hoxton - greenwich pull_request: branches: - - hoxton + - 2022.0 - 2021.0 - 2020.0 + - hoxton - greenwich jobs: - build: + codecov: runs-on: ubuntu-latest steps: - name: Checkout codes uses: actions/checkout@v3 - - name: Set up JDK 8 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 8 + java-version: 17 - name: Test with Maven - run: mvn clean test -f pom.xml -B -P sonatype -U + run: mvn clean test -B -U -Psonatype - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} files: ${{ github.workspace }}/target/site/jacoco/jacoco.xml diff --git a/.github/workflows/junit_test.yml b/.github/workflows/junit_test.yml index 13f2c7aeb..c26f1d8be 100644 --- a/.github/workflows/junit_test.yml +++ b/.github/workflows/junit_test.yml @@ -18,7 +18,7 @@ on: - greenwich jobs: - build: + junit: strategy: matrix: java: [ 8, 11, 17 ] @@ -42,4 +42,5 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - name: Test with Maven - run: mvn clean test -f pom.xml -B -P sonatype -U + run: mvn clean test -B -U -Psonatype + diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 000000000..2b2f53701 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,30 @@ +name: Snapshot + +on: + push: + branches: + - 2022.0 + - 2021.0 + - 2020.0 + - hoxton + - greenwich + +jobs: + snapshot: + runs-on: ubuntu-latest + steps: + - name: Checkout codes + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + server-id: nexus-snapshots + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + - name: Publish package + run: mvn clean deploy -B -U -Psonatype + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 397ffecf6..a114cf43b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,3 +8,4 @@ - [fix:fix the error capture of rate limit exception.](https://github.com/Tencent/spring-cloud-tencent/pull/861) - [feat:enable stat reporting as default.](https://github.com/Tencent/spring-cloud-tencent/pull/864) - [refactor:update to junit 5.](https://github.com/Tencent/spring-cloud-tencent/pull/867) +- [docs:support auto snapshot release in GitHub Action.](https://github.com/Tencent/spring-cloud-tencent/pull/870) diff --git a/README-zh.md b/README-zh.md index 71e858f28..14fa83e98 100644 --- a/README-zh.md +++ b/README-zh.md @@ -5,7 +5,7 @@ [![Contributors](https://img.shields.io/github/contributors/Tencent/spring-cloud-tencent)](https://github.com/Tencent/spring-cloud-tencent/graphs/contributors) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) -[![Build Status](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml/badge.svg)](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml) +[![Test with Junit](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml/badge.svg?branch=2020.0)](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml) [![codecov.io](https://codecov.io/gh/Tencent/spring-cloud-tencent/branch/2020.0/graph/badge.svg)](https://codecov.io/gh/Tencent/spring-cloud-tencent?branch=2020.0) [English](./README.md) | 简体中文 diff --git a/README.md b/README.md index cf3630524..79a753de8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Contributors](https://img.shields.io/github/contributors/Tencent/spring-cloud-tencent)](https://github.com/Tencent/spring-cloud-tencent/graphs/contributors) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) -[![Build Status](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml/badge.svg)](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml) +[![Test with Junit](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml/badge.svg?branch=2020.0)](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml) [![codecov.io](https://codecov.io/gh/Tencent/spring-cloud-tencent/branch/2020.0/graph/badge.svg)](https://codecov.io/gh/Tencent/spring-cloud-tencent?branch=2020.0) English | [简体中文](./README-zh.md) diff --git a/pom.xml b/pom.xml index 1072d08bc..7c724e5fd 100644 --- a/pom.xml +++ b/pom.xml @@ -204,6 +204,7 @@ 1 false + ${argLine} @@ -291,17 +292,6 @@ - - - - nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - - nexus-releases - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - sonatype @@ -331,4 +321,14 @@ + + + nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + nexus-releases + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + diff --git a/spring-cloud-tencent-commons/pom.xml b/spring-cloud-tencent-commons/pom.xml index edfcbb7c1..80b08c027 100644 --- a/spring-cloud-tencent-commons/pom.xml +++ b/spring-cloud-tencent-commons/pom.xml @@ -100,6 +100,12 @@ true + + com.tencent.polaris + polaris-test-common + test + + uk.org.webcompere system-stubs-jupiter diff --git a/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/pojo/PolarisServiceInstanceTest.java b/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/pojo/PolarisServiceInstanceTest.java new file mode 100644 index 000000000..afa2eec25 --- /dev/null +++ b/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/pojo/PolarisServiceInstanceTest.java @@ -0,0 +1,63 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.tencent.cloud.common.pojo; + +import com.tencent.polaris.api.pojo.Instance; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +/** + * Test for {@link PolarisServiceInstance}. + * + * @author Haotian Zhang + */ +@ExtendWith(MockitoExtension.class) +public class PolarisServiceInstanceTest { + + @Test + @DisplayName("test getters and setters.") + void test() { + Instance secureInstance = mock(Instance.class); + doReturn("test-ID").when(secureInstance).getId(); + doReturn(SERVICE_PROVIDER).when(secureInstance).getService(); + doReturn("1.1.1.1").when(secureInstance).getHost(); + doReturn(8080).when(secureInstance).getPort(); + doReturn("https").when(secureInstance).getProtocol(); + + PolarisServiceInstance securePolarisServiceInstance = new PolarisServiceInstance(secureInstance); + assertThat(securePolarisServiceInstance.getInstanceId()).isEqualTo("test-ID"); + assertThat(securePolarisServiceInstance.getServiceId()).isEqualTo(SERVICE_PROVIDER); + assertThat(securePolarisServiceInstance.getHost()).isEqualTo("1.1.1.1"); + assertThat(securePolarisServiceInstance.getPort()).isEqualTo(8080); + assertThat(securePolarisServiceInstance.isSecure()).isTrue(); + assertThat(securePolarisServiceInstance.getScheme()).isEqualTo("https"); + + Instance insecureInstance = mock(Instance.class); + doReturn("http").when(insecureInstance).getProtocol(); + PolarisServiceInstance insecurePolarisServiceInstance = new PolarisServiceInstance(insecureInstance); + assertThat(insecurePolarisServiceInstance.isSecure()).isFalse(); + assertThat(insecurePolarisServiceInstance.getScheme()).isEqualTo("http"); + } +} diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index 4e6a7c08f..dd2e31276 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -351,17 +351,17 @@ - - - - nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - - nexus-releases - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + + + nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + nexus-releases + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + +