Merge pull request #305 from SkyeBeFreeman/2021/update_action

Update GitHub Actions workflow
pull/321/head
VOPEN.XYZ 2 years ago committed by GitHub
commit 3ce460869c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,24 +5,47 @@ name: Test with Junit
on: on:
push: push:
branches: [ 2021.0 ] branches:
- main
- 2021.0
- 2020.0
- greenwich
pull_request: pull_request:
branches: [ 2021.0 ] branches:
- main
- 2021.0
- 2020.0
- greenwich
jobs: jobs:
build: build:
strategy:
matrix:
java: [ 8, 11, 17 ]
os: [ 'windows-latest', 'macos-latest', 'ubuntu-latest' ]
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout codes - name: Checkout codes
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up JDK 8 - name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2 uses: actions/setup-java@v3
with: with:
java-version: '8' distribution: 'temurin'
distribution: 'adopt' java-version: ${{ matrix.java }}
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# - name: Build with Maven # - name: Build with Maven
# run: mvn -B package --file pom.xml # run: mvn -B package --file pom.xml
- name: Test with Maven - name: Test with Maven
run: mvn -B test --file pom.xml run: mvn -B test --file pom.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: '**/target/site/jacoco/jacoco.xml'

@ -8,3 +8,4 @@
- [Feature: Add config change listener feature support](https://github.com/Tencent/spring-cloud-tencent/pull/299) - [Feature: Add config change listener feature support](https://github.com/Tencent/spring-cloud-tencent/pull/299)
- [Feature: Add config module unit test](https://github.com/Tencent/spring-cloud-tencent/pull/301) - [Feature: Add config module unit test](https://github.com/Tencent/spring-cloud-tencent/pull/301)
- [Feature:add restTemplate Report Polaris](https://github.com/Tencent/spring-cloud-tencent/pull/304) - [Feature:add restTemplate Report Polaris](https://github.com/Tencent/spring-cloud-tencent/pull/304)
- [Update GitHub Actions workflow](https://github.com/Tencent/spring-cloud-tencent/pull/305)

@ -95,7 +95,7 @@
<spring.framework.version>5.3.21</spring.framework.version> <spring.framework.version>5.3.21</spring.framework.version>
<!-- Maven Plugin Versions --> <!-- Maven Plugin Versions -->
<jacoco.version>0.8.3</jacoco.version> <jacoco.version>0.8.8</jacoco.version>
<maven-source-plugin.version>3.2.0</maven-source-plugin.version> <maven-source-plugin.version>3.2.0</maven-source-plugin.version>
<flatten-maven-plugin.version>1.2.7</flatten-maven-plugin.version> <flatten-maven-plugin.version>1.2.7</flatten-maven-plugin.version>
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version> <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>

@ -66,7 +66,7 @@ public class ConfigChangeListenerTest {
Sets.newHashSet("timeout")); Sets.newHashSet("timeout"));
applicationEventPublisher.publishEvent(event); applicationEventPublisher.publishEvent(event);
Thread.sleep(200);
//after change //after change
Assert.assertEquals(2, testConfig.getChangeCnt()); Assert.assertEquals(2, testConfig.getChangeCnt());
Assert.assertEquals(2000, testConfig.getTimeout()); Assert.assertEquals(2000, testConfig.getTimeout());

@ -23,6 +23,7 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StreamUtils;
/** /**
* Read file content from classpath resource. * Read file content from classpath resource.
@ -35,20 +36,15 @@ public final class ResourceFileUtils {
} }
public static String readFile(String path) throws IOException { public static String readFile(String path) throws IOException {
StringBuilder sb = new StringBuilder();
ClassPathResource classPathResource = new ClassPathResource(path); ClassPathResource classPathResource = new ClassPathResource(path);
if (classPathResource.exists() && classPathResource.isReadable()) { if (classPathResource.exists() && classPathResource.isReadable()) {
try (InputStream inputStream = classPathResource.getInputStream()) { try (InputStream inputStream = classPathResource.getInputStream()) {
byte[] buffer = new byte[1024 * 10]; return StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
int len;
while ((len = inputStream.read(buffer)) != -1) {
sb.append(new String(buffer, 0, len, StandardCharsets.UTF_8));
} }
} }
} return "";
return sb.toString();
} }
} }

@ -35,7 +35,7 @@ public class ResourceFileUtilsTest {
@Test @Test
public void testReadExistedFile() throws IOException { public void testReadExistedFile() throws IOException {
String content = ResourceFileUtils.readFile("test.txt"); String content = ResourceFileUtils.readFile("test.txt");
Assert.assertEquals("just for test\n", content); Assert.assertEquals("just for test", content);
} }
@Test @Test

Loading…
Cancel
Save