Skip to content

Commit 9d8ba21

Browse files
[infra] Fix OneCollector Dangerous-Workflow v2 (#3256)
Co-authored-by: Martin Costello <[email protected]>
1 parent 6b9de01 commit 9d8ba21

File tree

6 files changed

+91
-24
lines changed

6 files changed

+91
-24
lines changed

.github/codeql/codeql-config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "CodeQL config"
2+
3+
queries:
4+
- uses: security-extended
5+
6+
# Disable specific queries
7+
query-filters:
8+
- exclude:
9+
id:
10+
- actions/untrusted-checkout
11+
- actions/untrusted-checkout/high
12+
- actions/untrusted-checkout/medium

.github/workflows/ci-Exporter.OneCollector-Integration.yml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,21 @@ jobs:
2424

2525
build-integration-test:
2626
needs: authorize
27-
2827
strategy:
29-
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
28+
fail-fast: false
3029
matrix:
3130
os: [ windows-latest, ubuntu-24.04 ]
3231
version: [ net462, net8.0 ]
3332
exclude:
3433
- os: ubuntu-24.04
3534
version: net462
36-
37-
runs-on: ${{ matrix.os }}
38-
steps:
39-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
40-
with:
41-
ref: refs/pull/${{ github.event.pull_request.number }}/merge # Run on the merge commit once approved
42-
43-
- name: Setup dotnet
44-
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
45-
46-
- name: dotnet restore Component.proj for OpenTelemetry.Exporter.OneCollector
47-
run: dotnet restore build/Projects/Component.proj -p:BUILD_COMPONENT=OpenTelemetry.Exporter.OneCollector
48-
49-
- name: dotnet build Component.proj for OpenTelemetry.Exporter.OneCollector
50-
run: dotnet build build/Projects/Component.proj --configuration Release --no-restore -p:BUILD_COMPONENT=OpenTelemetry.Exporter.OneCollector
51-
52-
- name: dotnet test Component.proj for OpenTelemetry.Exporter.OneCollector
53-
run: dotnet test build/Projects/Component.proj --filter CategoryName=OneCollectorIntegrationTests --framework ${{ matrix.version }} --configuration Release --no-restore --no-build -p:BUILD_COMPONENT=OpenTelemetry.Exporter.OneCollector --logger:"console;verbosity=detailed"
54-
env:
55-
OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY: ${{ secrets.OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY }}
35+
uses: ./.github/workflows/integration-test-reusable.yml
36+
with:
37+
component: OpenTelemetry.Exporter.OneCollector
38+
os: ${{ matrix.os }}
39+
version: ${{ matrix.version }}
40+
test-filter: OneCollectorIntegrationTests
41+
env-var-name: OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY
42+
checkout-ref: refs/pull/${{ github.event.pull_request.number }}/merge
43+
secrets:
44+
instrumentation-key: ${{ secrets.OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY }}

.github/workflows/codeql-analysis-steps.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
with:
4040
build-mode: none
4141
languages: ${{ matrix.language }}
42+
config-file: ./.github/codeql/codeql-config.yml
4243

4344
- name: Perform CodeQL Analysis
4445
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Reusable Integration Test
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
component:
10+
description: 'Component to build and test'
11+
required: true
12+
type: string
13+
os:
14+
description: 'Operating system to run on'
15+
required: true
16+
type: string
17+
version:
18+
description: 'Framework version to test'
19+
required: true
20+
type: string
21+
test-filter:
22+
description: 'Test filter category'
23+
required: true
24+
type: string
25+
env-var-name:
26+
description: 'Environment variable name for instrumentation key'
27+
required: false
28+
type: string
29+
default: 'INSTRUMENTATION_KEY'
30+
checkout-ref:
31+
description: 'Git ref to checkout'
32+
required: false
33+
type: string
34+
default: ''
35+
secrets:
36+
instrumentation-key:
37+
description: 'Instrumentation key for testing'
38+
required: false
39+
40+
jobs:
41+
build-and-test:
42+
runs-on: ${{ inputs.os }}
43+
steps:
44+
# Security: When called from pull_request_target with untrusted PR code,
45+
# this checkout requires prior approval via the 'authorize' job environment.
46+
# The workflow has limited permissions (contents: read) and uses persist-credentials: false
47+
# to prevent credential theft.
48+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49+
with:
50+
persist-credentials: false
51+
ref: ${{ inputs.checkout-ref }}
52+
53+
- name: Setup dotnet
54+
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
55+
56+
- name: dotnet restore Component.proj
57+
run: dotnet restore build/Projects/Component.proj -p:BUILD_COMPONENT=${{ inputs.component }}
58+
59+
- name: dotnet build Component.proj
60+
run: dotnet build build/Projects/Component.proj --configuration Release --no-restore -p:BUILD_COMPONENT=${{ inputs.component }}
61+
62+
- name: dotnet test Component.proj
63+
run: dotnet test build/Projects/Component.proj --filter CategoryName=${{ inputs.test-filter }} --framework ${{ inputs.version }} --configuration Release --no-restore --no-build -p:BUILD_COMPONENT=${{ inputs.component }} --logger:"console;verbosity=detailed"
64+
env:
65+
${{ inputs.env-var-name }}: ${{ secrets.instrumentation-key }}

test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public enum SqlClientLibrary
2020
[Collection("SqlClient")]
2121
public class SqlClientTests : IDisposable
2222
{
23-
private const string TestConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;Database=master";
23+
private const string TestConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;Database=master;Encrypt=True;TrustServerCertificate=True";
2424

2525
public static IEnumerable<object[]> TestData => SqlClientTestCases.GetTestCases();
2626

test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTraceInstrumentationOptionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace OpenTelemetry.Instrumentation.SqlClient.Tests;
1717
[Collection("SqlClient")]
1818
public class SqlClientTraceInstrumentationOptionsTests
1919
{
20-
private const string TestConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;Database=master";
20+
private const string TestConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;Database=master;Encrypt=True;TrustServerCertificate=True";
2121

2222
[Fact]
2323
public void ShouldEmitOldAttributesWhenStabilityOptInIsDatabaseDup()

0 commit comments

Comments
 (0)