Skip to content

Commit

Permalink
added glob pattern (#2)
Browse files Browse the repository at this point in the history
* added glob pattern

* v1.2.0
  • Loading branch information
nikordaris authored Feb 9, 2022
1 parent ee1464a commit d6c92a6
Show file tree
Hide file tree
Showing 10 changed files with 1,543 additions and 95 deletions.
1,324 changes: 1,279 additions & 45 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions dist/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ The above copyright notice and this permission notice shall be included in all c

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@actions/glob
MIT
The MIT License (MIT)

Copyright 2019 GitHub

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@actions/http-client
MIT
Actions Http Client for Node.js
Expand Down
25 changes: 23 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "otel-upload-test-artifact-action",
"version": "1.1.0",
"version": "1.2.0",
"description": "Action that Uploads OTLP log file to GH Artifact",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -34,6 +34,7 @@
"opentelemetry-exporter-trace-otlp-file": "^0.1.1"
},
"devDependencies": {
"@actions/glob": "^0.2.0",
"@octokit/rest": "^18.12.0",
"@tsconfig/node16": "^1.0.2",
"@types/jest": "^27.0.3",
Expand Down
27 changes: 27 additions & 0 deletions src/__assets__/junit-testsuite-failed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="createTracerProvider" errors="0" failures="1" skipped="0" timestamp="2022-02-01T18:37:11" time="2.492" tests="5">
<testcase classname="createTracerProvider test service.name resource is workflow name" name="createTracerProvider test service.name resource is workflow name" time="0.019">
</testcase>
<testcase classname="createTracerProvider test service.name resource is workflow id" name="createTracerProvider test service.name resource is workflow id" time="0.023">
<failure message="Error: expect(received).toEqual(expected) // deep equality">

Expected: 1
Received: &quot;1&quot;
at Object.&lt;anonymous&gt; (/Users/nick/work/otel-export-trace-action/src/tracing/trace.test.ts:51:7)
at Promise.then.completed (/Users/nick/work/otel-export-trace-action/node_modules/jest-circus/build/utils.js:391:28)
at new Promise (&lt;anonymous&gt;)
at callAsyncCircusFn (/Users/nick/work/otel-export-trace-action/node_modules/jest-circus/build/utils.js:316:10)
at _callCircusTest (/Users/nick/work/otel-export-trace-action/node_modules/jest-circus/build/run.js:218:40)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at _runTest (/Users/nick/work/otel-export-trace-action/node_modules/jest-circus/build/run.js:155:3)
at _runTestsForDescribeBlock (/Users/nick/work/otel-export-trace-action/node_modules/jest-circus/build/run.js:66:9)
at _runTestsForDescribeBlock (/Users/nick/work/otel-export-trace-action/node_modules/jest-circus/build/run.js:60:9)
at run (/Users/nick/work/otel-export-trace-action/node_modules/jest-circus/build/run.js:25:3)</failure>
</testcase>
<testcase classname="createTracerProvider test service.instance.id resource" name="createTracerProvider test service.instance.id resource" time="0.002">
</testcase>
<testcase classname="createTracerProvider test service.namespace resource" name="createTracerProvider test service.namespace resource" time="0.002">
</testcase>
<testcase classname="createTracerProvider test active span processor" name="createTracerProvider test active span processor" time="0.002">
</testcase>
</testsuite>
File renamed without changes.
1 change: 1 addition & 0 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export async function run() {
tracer,
path,
startTime,
baseHtmlUrl: `${ghContext.serverUrl}/${ghContext.repo.owner}/${ghContext.repo.repo}`,
});
}

Expand Down
86 changes: 79 additions & 7 deletions src/trace-junit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ describe("traceJunitArtifact", () => {
tracer,
startTime,
path: junitFilePath,
baseHtmlUrl: "https://example.com",
});

const spans = memoryExporter.getFinishedSpans();
expect(spans.length).toEqual(8);
// expect(spans).toMatchSnapshot("trace-junit-testsuites-pass");
expect(spans.length).toEqual(9);

spans.forEach((s) => {
expect(s.attributes).toBeDefined();
expect(Object.keys(s.attributes).length).toBeGreaterThan(0);
Expand All @@ -99,12 +100,13 @@ describe("traceJunitArtifact", () => {
trace,
tracer,
startTime,
baseHtmlUrl: "https://example.com",
path: junitFilePath,
});

const spans = memoryExporter.getFinishedSpans();
expect(spans.length).toEqual(6);
// expect(spans).toMatchSnapshot("trace-junit-testsuite-pass");

spans.forEach((s) => {
expect(s.attributes).toBeDefined();
expect(Object.keys(s.attributes).length).toBeGreaterThan(0);
Expand All @@ -118,20 +120,90 @@ describe("traceJunitArtifact", () => {
});
});

it("test failed junit spans match snapshot", async () => {
const junitFilePath = path.join("src", "__assets__", "junit-failed.xml");
it("test testsuites failed", async () => {
const junitFilePath = path.join(
"src",
"__assets__",
"junit-testsuites-failed.xml"
);
const startTime = new Date("2022-02-01T18:37:11");

await traceJunitArtifact({
trace,
tracer,
startTime,
path: junitFilePath,
baseHtmlUrl: "https://example.com",
});

const spans = memoryExporter.getFinishedSpans();
expect(spans.length).toEqual(14);

spans.forEach((s) => {
expect(s.attributes).toBeDefined();
expect(Object.keys(s.attributes).length).toBeGreaterThan(0);
expect(s.endTime).toBeDefined();
expect(s.startTime).toBeDefined();
expect(s.endTime[0]).toBeGreaterThanOrEqual(s.startTime[0]);
expect(s.endTime[1]).toBeGreaterThanOrEqual(s.startTime[1]);
expect(s.status).toBeDefined();
if (s.status.code === SpanStatusCode.ERROR) {
expect(s.attributes.error).toEqual(true);
} else {
expect(s.attributes.error).toBeFalsy();
}
});
});

it("test testsuite failed", async () => {
const junitFilePath = path.join(
"src",
"__assets__",
"junit-testsuite-failed.xml"
);
const startTime = new Date("2022-02-01T18:37:11");

await traceJunitArtifact({
trace,
tracer,
startTime,
path: junitFilePath,
baseHtmlUrl: "https://example.com",
});

const spans = memoryExporter.getFinishedSpans();
expect(spans.length).toEqual(7);

spans.forEach((s) => {
expect(s.attributes).toBeDefined();
expect(Object.keys(s.attributes).length).toBeGreaterThan(0);
expect(s.endTime).toBeDefined();
expect(s.startTime).toBeDefined();
expect(s.endTime[0]).toBeGreaterThanOrEqual(s.startTime[0]);
expect(s.endTime[1]).toBeGreaterThanOrEqual(s.startTime[1]);
expect(s.status).toBeDefined();
if (s.status.code === SpanStatusCode.ERROR) {
expect(s.attributes.error).toEqual(true);
} else {
expect(s.attributes.error).toBeFalsy();
}
});
});

it("test glob path", async () => {
const junitFilePath = path.join("src", "__assets__", "*.xml");
const startTime = new Date("2022-02-01T18:37:11");

await traceJunitArtifact({
trace,
tracer,
startTime,
path: junitFilePath,
baseHtmlUrl: "https://example.com",
});

const spans = memoryExporter.getFinishedSpans();
expect(spans.length).toEqual(13);
// expect(spans).toMatchSnapshot("trace-junit-error");
expect(spans.length).toEqual(33);

spans.forEach((s) => {
expect(s.attributes).toBeDefined();
Expand Down
Loading

0 comments on commit d6c92a6

Please sign in to comment.