Skip to content

Commit

Permalink
Merge branch 'line:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhee17 authored Jul 25, 2023
2 parents 527e2d6 + 94fc3ff commit 44ae490
Show file tree
Hide file tree
Showing 335 changed files with 3,125 additions and 1,587 deletions.
801 changes: 801 additions & 0 deletions .github/actions/package-lock.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .github/actions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"scripts": {
"post-release": "ts-node post-release.ts"
},
"dependencies": {
"octokit": "^2.1.0",
"ts-node": "^10.9.1"
}
}
79 changes: 79 additions & 0 deletions .github/actions/post-release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Octokit } from 'octokit';

// A GitHub access token that has the write permission for both Armeria and Central Dogma is required.
const octokit = new Octokit({ auth: process.env.GITHUB_ACCESS_TOKEN });

main();

/**
* Perform post-release process.
* - Close milestone.
* - Write release notes.
* - Create a pull request to Central Dogma for updating Armeria version.
*/
async function main(): Promise<void> {
const tag: string = process.argv.slice(2).shift();
const releaseVersion = tag.replace("armeria-", "");
const owner = 'line';
const repo = 'armeria';
const milestoneId = await getMilestoneId(owner, repo, releaseVersion);

// Close the milestone
console.log(`🎯 Closing milestone #${milestoneId}...`);
await octokit.rest.issues.updateMilestone({
owner,
repo,
milestone_number: milestoneId,
due_on: new Date().toISOString(),
state: "closed"
})
console.log(`🎯 https://github.com/line/armeria/milestone/${milestoneId} has been closed.`)

// Create a new release
console.log(`📝 Creating release notes ...`);
await octokit.rest.repos.createRelease({
owner,
repo,
name: tag,
tag_name: tag,
body: `See [the release notes](https://armeria.dev/release-notes/${releaseVersion}/) for the complete change list.`

});
console.log(`📝 https://github.com/line/armeria/releases/tag/${tag} has been updated.`)

// Trigger Central Dogma workflow to upgrade Armeria version
console.log(`⛓️ Triggering 'update-armeria-version' workflow in Central Dogma repository...`);
await octokit.rest.actions.createWorkflowDispatch({
owner: owner,
repo: 'centraldogma',
workflow_id: 'update-armeria-version.yml',
ref: 'main',
inputs: {
armeria_version: releaseVersion
},
})
console.log("⛓️ https://github.com/line/centraldogma/actions/workflows/update-armeria-version.yml has been triggered.")
}

/**
* Converts a version into a milestone number in GitHub.
*/
async function getMilestoneId(owner: string, repo: string, version: string): Promise<number> {
const response = await octokit.request(
'GET /repos/{owner}/{repo}/milestones',
{
owner,
repo,
direction: 'desc',
per_page: 100,
state: 'open',
},
);
const found = response.data.find((milestone: any) => milestone.title === version);
if (!found) {
throw new Error(
`Failed to find a milestone from the given version: ${version}.`,
);
}
return found.number;
}
9 changes: 9 additions & 0 deletions .github/actions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
},
"include": [
"./*"
]
}
4 changes: 3 additions & 1 deletion .github/workflows/actions_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ jobs:
${{ matrix.blockhound && '-Pblockhound' || '' }} \
-PnoLint \
-PflakyTests=false \
-Pretry=true \
-PbuildJdkVersion=${{ env.BUILD_JDK_VERSION }} \
-PtestJavaVersion=${{ matrix.java }} \
${{ matrix.min-java && format('-PminimumJavaVersion={0}', matrix.min-java) || '' }} \
Expand Down Expand Up @@ -252,7 +253,8 @@ jobs:

- name: Run flaky tests
run: |
./gradlew --no-daemon --stacktrace --max-workers=2 --parallel check -PnoLint -PflakyTests=true \
./gradlew --no-daemon --stacktrace --max-workers=2 --parallel check \
-PnoLint -PflakyTests=true -Pretry=true \
-PbuildJdkVersion=${{ env.BUILD_JDK_VERSION }} \
-PtestJavaVersion=${{ env.BUILD_JDK_VERSION }} \
-Porg.gradle.java.installations.paths=${{ steps.setup-build-jdk.outputs.path }}
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ jobs:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSWORD }}
shell: bash

- name: Setup Node.js
uses: actions/setup-node@v3

- name: Perform post-release process
working-directory: .github/actions
run: |
npm install
npm run post-release ${{ github.ref_name }}
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
14 changes: 3 additions & 11 deletions .post-release-msg
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@
- Maven Central: https://repo.maven.apache.org/maven2/com/linecorp/armeria/armeria-bom/${releaseVersion}/
- Site job: https://github.com/line/armeria/actions/workflows/publish-site.yml

2. Close the milestone and set its due date with the date of the release at:

https://github.com/line/armeria/milestones

3. Update the release note at:

https://github.com/line/armeria/releases/tag/${tag}

4. Copy the examples to armeria-examples using the script:
2. Copy the examples to armeria-examples using the script:

cd ../armeria-examples && \
./update-examples.sh ${releaseVersion} ../upstream-armeria && \
git add -A . && \
git commit -m 'Update Armeria to ${releaseVersion}' && \
git push

5. Announce the release via Twitter.
3. Announce the release via Twitter.

6. Send an update pull request to https://github.com/TechEmpower/FrameworkBenchmarks
4. Send an update pull request to https://github.com/TechEmpower/FrameworkBenchmarks
if we made performance improvements.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private String loadFile(String fileName) throws IOException {
try (Reader reader = new InputStreamReader(
this.getClass()
.getClassLoader()
.getResourceAsStream("DocumentationProcessor/" + fileName))) {
.getResourceAsStream("testing/DocumentationProcessor/" + fileName))) {
return CharStreams.toString(reader);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@
import com.linecorp.armeria.common.RpcResponse;
import com.linecorp.armeria.common.SessionProtocol;
import com.linecorp.armeria.common.annotation.Nullable;
import com.linecorp.armeria.common.brave.HelloService;
import com.linecorp.armeria.common.brave.RequestContextCurrentTraceContext;
import com.linecorp.armeria.common.brave.SpanCollector;
import com.linecorp.armeria.common.brave.TestSpanCollector;
import com.linecorp.armeria.common.logging.RequestLog;
import com.linecorp.armeria.common.util.SafeCloseable;

Expand All @@ -63,6 +62,7 @@
import brave.propagation.CurrentTraceContext;
import brave.propagation.CurrentTraceContext.ScopeDecorator;
import brave.sampler.Sampler;
import testing.brave.TestService;

class BraveClientTest {

Expand Down Expand Up @@ -90,7 +90,7 @@ void newDecorator_shouldWorkWhenRequestContextCurrentTraceContextConfigured() {

@Test
void shouldSubmitSpanWhenSampled() throws Exception {
final SpanCollector collector = new SpanCollector();
final TestSpanCollector collector = new TestSpanCollector();

final Tracing tracing = Tracing.newBuilder()
.localServiceName(TEST_SERVICE)
Expand Down Expand Up @@ -129,7 +129,7 @@ void shouldSubmitSpanWhenSampled() throws Exception {

@Test
void shouldSubmitSpanWithCustomRemoteName() throws Exception {
final SpanCollector collector = new SpanCollector();
final TestSpanCollector collector = new TestSpanCollector();

final Tracing tracing = Tracing.newBuilder()
.localServiceName(TEST_SERVICE)
Expand Down Expand Up @@ -158,7 +158,7 @@ void shouldSubmitSpanWithCustomRemoteName() throws Exception {

@Test
void scopeDecorator() throws Exception {
final SpanCollector collector = new SpanCollector();
final TestSpanCollector collector = new TestSpanCollector();
final AtomicInteger scopeDecoratorCallingCounter = new AtomicInteger();
final ScopeDecorator scopeDecorator = (currentSpan, scope) -> {
scopeDecoratorCallingCounter.getAndIncrement();
Expand Down Expand Up @@ -191,7 +191,7 @@ void scopeDecorator() throws Exception {

@Test
void shouldNotSubmitSpanWhenNotSampled() throws Exception {
final SpanCollector collector = new SpanCollector();
final TestSpanCollector collector = new TestSpanCollector();
final Tracing tracing = Tracing.newBuilder()
.localServiceName(TEST_SERVICE)
.addSpanHandler(collector)
Expand All @@ -204,7 +204,7 @@ void shouldNotSubmitSpanWhenNotSampled() throws Exception {

@Test
void testEmptyEndpointTags() {
final SpanCollector collector = new SpanCollector();
final TestSpanCollector collector = new TestSpanCollector();
final Tracing tracing = Tracing.newBuilder()
.addSpanHandler(collector)
.currentTraceContext(RequestContextCurrentTraceContext.ofDefault())
Expand Down Expand Up @@ -238,7 +238,7 @@ private static RequestLog testRemoteInvocation(Tracing tracing, @Nullable String
final HttpRequest req = HttpRequest.of(RequestHeaders.of(HttpMethod.POST, "/hello/armeria",
HttpHeaderNames.SCHEME, "http",
HttpHeaderNames.AUTHORITY, "foo.com"));
final RpcRequest rpcReq = RpcRequest.of(HelloService.Iface.class, "hello", "Armeria");
final RpcRequest rpcReq = RpcRequest.of(TestService.Iface.class, "hello", "Armeria");
final HttpResponse res = HttpResponse.of(HttpStatus.OK);
final RpcResponse rpcRes = RpcResponse.of("Hello, Armeria!");
final ClientRequestContext ctx = ClientRequestContext.builder(req).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import brave.handler.SpanHandler;
import brave.propagation.TraceContext;

public final class SpanCollector extends SpanHandler {
public final class TestSpanCollector extends SpanHandler {

private final BlockingQueue<MutableSpan> spans = new LinkedTransferQueue<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
import com.linecorp.armeria.common.HttpStatus;
import com.linecorp.armeria.common.MediaType;
import com.linecorp.armeria.common.RequestContext;
import com.linecorp.armeria.common.brave.HelloService;
import com.linecorp.armeria.common.brave.HelloService.AsyncIface;
import com.linecorp.armeria.common.brave.RequestContextCurrentTraceContext;
import com.linecorp.armeria.common.thrift.ThriftFuture;
import com.linecorp.armeria.common.util.ThreadFactories;
Expand All @@ -85,19 +83,21 @@
import brave.propagation.StrictScopeDecorator;
import brave.propagation.TraceContext;
import brave.sampler.Sampler;
import testing.brave.TestService;
import testing.brave.TestService.AsyncIface;

class BraveIntegrationTest {

private static final SpanHandlerImpl spanHandler = new SpanHandlerImpl();

private static HelloService.Iface fooClient;
private static HelloService.Iface fooClientWithoutTracing;
private static HelloService.Iface timeoutClient;
private static HelloService.Iface timeoutClientClientTimesOut;
private static HelloService.Iface http1TimeoutClientClientTimesOut;
private static HelloService.AsyncIface barClient;
private static HelloService.AsyncIface quxClient;
private static HelloService.Iface zipClient;
private static TestService.Iface fooClient;
private static TestService.Iface fooClientWithoutTracing;
private static TestService.Iface timeoutClient;
private static TestService.Iface timeoutClientClientTimesOut;
private static TestService.Iface http1TimeoutClientClientTimesOut;
private static TestService.AsyncIface barClient;
private static TestService.AsyncIface quxClient;
private static TestService.Iface zipClient;
private static WebClient poolWebClient;

@RegisterExtension
Expand Down Expand Up @@ -203,31 +203,31 @@ void setupClients() {
fooClient = ThriftClients.builder(server.httpUri())
.path("/foo")
.decorator(BraveClient.newDecorator(newTracing("client/foo")))
.build(HelloService.Iface.class);
.build(TestService.Iface.class);
zipClient = ThriftClients.builder(server.httpUri())
.path("/zip")
.decorator(BraveClient.newDecorator(newTracing("client/zip")))
.build(HelloService.Iface.class);
fooClientWithoutTracing = ThriftClients.newClient(server.httpUri() + "/foo", HelloService.Iface.class);
.build(TestService.Iface.class);
fooClientWithoutTracing = ThriftClients.newClient(server.httpUri() + "/foo", TestService.Iface.class);
barClient = newClient("/bar");
quxClient = newClient("/qux");
poolWebClient = WebClient.of(server.httpUri());
timeoutClient = ThriftClients.builder(server.httpUri())
.path("/timeout")
.decorator(BraveClient.newDecorator(newTracing("client/timeout")))
.build(HelloService.Iface.class);
.build(TestService.Iface.class);
timeoutClientClientTimesOut =
ThriftClients.builder(server.httpUri())
.path("/timeout")
.decorator(BraveClient.newDecorator(newTracing("client/timeout")))
.responseTimeout(Duration.ofSeconds(3))
.build(HelloService.Iface.class);
.build(TestService.Iface.class);
http1TimeoutClientClientTimesOut =
ThriftClients.builder(server.uri(H1C))
.path("/timeout")
.decorator(BraveClient.newDecorator(newTracing("client/timeout")))
.responseTimeout(Duration.ofSeconds(3))
.build(HelloService.Iface.class);
.build(TestService.Iface.class);
}

@AfterEach
Expand All @@ -244,11 +244,11 @@ private static BraveService decorate(String name, HttpService service) {
return BraveService.newDecorator(newTracing(name)).apply(service);
}

private static HelloService.AsyncIface newClient(String path) {
private static TestService.AsyncIface newClient(String path) {
return ThriftClients.builder(server.httpUri())
.path(path)
.decorator(BraveClient.newDecorator(newTracing("client" + path)))
.build(HelloService.AsyncIface.class);
.build(TestService.AsyncIface.class);
}

private static Tracing newTracing(String name) {
Expand Down Expand Up @@ -473,7 +473,7 @@ void testHttp1ClientTimesOut() throws Exception {
testClientTimesOut(http1TimeoutClientClientTimesOut);
}

private static void testClientTimesOut(HelloService.Iface client) {
private static void testClientTimesOut(TestService.Iface client) {
assertThatThrownBy(() -> client.hello("name"))
.isInstanceOf(TTransportException.class)
.hasCauseInstanceOf(ResponseTimeoutException.class);
Expand Down
Loading

0 comments on commit 44ae490

Please sign in to comment.