Skip to content

Commit f29afa3

Browse files
committed
switch to module
1 parent ae68958 commit f29afa3

30 files changed

+355
-5
lines changed

.github/codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ flags:
204204
unittests-Resources.OperatingSystem:
205205
carryforward: true
206206
paths:
207-
- src/OpenTelemetry.Resources.OperatingSystem
207+
- modules/Resources.OperatingSystem/src/OpenTelemetry.Resources.OperatingSystem
208208

209209
unittests-Resources.Process:
210210
carryforward: true

.github/workflows/Dotnet.Init.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build Component [Pre]
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
module-name:
7+
required: true
8+
type: string
9+
module-directory:
10+
required: false
11+
default: '.'
12+
type: string
13+
14+
jobs:
15+
run-dotnet-format:
16+
runs-on: windows-latest
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
working-directory: '${{ inputs.module-directory }}'
22+
23+
steps:
24+
- name: check out code
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
27+
- name: Setup dotnet
28+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
29+
30+
- name: dotnet restore ${{ inputs.module-name }}
31+
run: dotnet restore
32+
33+
- name: dotnet format ${{ inputs.module-name }}
34+
run: dotnet format --no-restore --verify-no-changes
35+
36+
- name: dotnet build ${{ inputs.module-name }}
37+
run: dotnet build --configuration Release --no-restore
38+
39+
- name: Archive build artifacts
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: build-output
43+
path: |
44+
**/bin
45+
**/obj
46+
retention-days: 1

.github/workflows/Dotnet.Main.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Build Component [Main]
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
module-name:
7+
required: true
8+
type: string
9+
module-directory:
10+
required: false
11+
default: '.'
12+
type: string
13+
run-tests:
14+
required: false
15+
default: true
16+
type: boolean
17+
code-cov-prefix:
18+
default: 'unittests'
19+
required: false
20+
type: string
21+
os-list:
22+
default: '[ "windows-latest", "ubuntu-22.04" ]'
23+
required: false
24+
type: string
25+
tfm-list:
26+
default: '[ "net462", "net8.0", "net9.0" ]'
27+
required: false
28+
type: string
29+
test-case-filter:
30+
required: false
31+
type: string
32+
test-require-elevated:
33+
default: false
34+
required: false
35+
type: boolean
36+
37+
jobs:
38+
component-build-test:
39+
40+
strategy:
41+
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
42+
matrix:
43+
os: ${{ fromJSON(inputs.os-list) }}
44+
version: ${{ fromJSON(inputs.tfm-list) }}
45+
exclude:
46+
- os: ubuntu-22.04
47+
version: net462
48+
- os: macos-latest
49+
version: net462
50+
51+
runs-on: ${{ matrix.os }}
52+
53+
defaults:
54+
run:
55+
shell: bash
56+
working-directory: '${{ inputs.module-directory }}'
57+
58+
steps:
59+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
60+
with:
61+
# Note: By default GitHub only fetches 1 commit. MinVer needs to find
62+
# the version tag which is typically NOT on the first commit so we
63+
# retrieve them all.
64+
fetch-depth: 0
65+
66+
- name: Setup previous .NET runtimes
67+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
68+
with:
69+
dotnet-version: |
70+
8.0.x
71+
72+
- name: Setup .NET
73+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
74+
75+
- name: dotnet restore ${{ inputs.module-name }}
76+
run: dotnet restore -p:EnablePackageValidation=true
77+
78+
- name: dotnet build ${{ inputs.module-name }}
79+
if: ${{ matrix.os != 'windows-latest' }}
80+
run: dotnet build --configuration Release --no-restore
81+
82+
- name: Download build artifacts
83+
if: ${{ matrix.os == 'windows-latest' }}
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: build-output
87+
88+
- name: dotnet test ${{ inputs.module-name }}
89+
if: ${{ inputs.run-tests }}
90+
run: >
91+
dotnet test
92+
--collect:"Code Coverage;Format=cobertura"
93+
--results-directory:TestResults
94+
--framework ${{ matrix.version }}
95+
--configuration Release
96+
--no-restore
97+
--no-build
98+
--logger:"console;verbosity=detailed"
99+
--logger:"GitHubActions;report-warnings=false"
100+
--logger:"junit;LogFilePath=../../TestResults/junit.xml"
101+
--filter "${{ inputs.test-case-filter }}"
102+
-- RunConfiguration.DisableAppDomain=true
103+
104+
- name: Upload code coverage ${{ inputs.code-cov-prefix }}-${{ inputs.module-name }}
105+
if: ${{ inputs.run-tests }}
106+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
107+
continue-on-error: true # Note: Don't fail for upload failures
108+
env:
109+
OS: ${{ matrix.os }}
110+
TFM: ${{ matrix.version }}
111+
FILTER: ${{ inputs.test-case-filter }}
112+
token: ${{ secrets.CODECOV_TOKEN }}
113+
with:
114+
files: TestResults/**/*Cobertura.xml
115+
env_vars: OS,TFM,FILTER
116+
flags: ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }}
117+
name: Code Coverage for ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} on [${{ matrix.os }}.${{ matrix.version }}]
118+
codecov_yml_path: .github/codecov.yml
119+
120+
- name: Upload test results ${{ inputs.code-cov-prefix }}-${{ inputs.module-name }}
121+
if: ${{ inputs.run-tests }}
122+
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1
123+
with:
124+
files: TestResults/junit.xml
125+
env_vars: OS,TFM,FILTER
126+
flags: ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }}
127+
name: Test results for ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} on [${{ matrix.os }}.${{ matrix.version }}]
128+
token: ${{ secrets.CODECOV_TOKEN }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build Component [Post]
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
module-name:
7+
required: true
8+
type: string
9+
module-directory:
10+
required: false
11+
default: '.'
12+
type: string
13+
pack:
14+
default: true
15+
required: false
16+
type: boolean
17+
18+
jobs:
19+
run-dotnet-pack:
20+
runs-on: windows-latest
21+
22+
defaults:
23+
run:
24+
shell: bash
25+
working-directory: '${{ inputs.module-directory }}'
26+
27+
steps:
28+
- name: check out code
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
31+
- name: Setup dotnet
32+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
33+
34+
- name: dotnet restore ${{ inputs.module-name }}
35+
run: dotnet restore
36+
37+
- name: Download build artifacts
38+
uses: actions/download-artifact@v4
39+
with:
40+
name: build-output
41+
42+
- name: dotnet pack ${{ inputs.module-name }}
43+
if: ${{ inputs.pack }}
44+
run: dotnet pack --configuration Release --no-restore --no-build -p:EnablePackageValidation=true
45+
46+
- name: Publish ${{ inputs.module-name }} NuGet packages to Artifacts
47+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
48+
# Only publish packages from the first job
49+
if: ${{ inputs.pack && strategy.job-index == 0 }}
50+
with:
51+
name: ${{ inputs.inputs }}-packages
52+
path: '.\modules\**\src\**\*.*nupkg'
53+
if-no-files-found: error

.github/workflows/build-module.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
module-name:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
initialization:
12+
uses: ./.github/workflows/Dotnet.Init.yml
13+
with:
14+
module-name: ${{ inputs.module-name }}
15+
module-directory: './modules/${{ inputs.module-name }}'
16+
17+
build-test:
18+
needs: initialization
19+
uses: ./.github/workflows/Dotnet.Main.yml
20+
with:
21+
module-name: ${{ inputs.module-name }}
22+
module-directory: './modules/${{ inputs.module-name }}'
23+
os-list: '[ "windows-latest", "ubuntu-22.04", "macos-latest" ]'
24+
25+
verify:
26+
needs: build-test
27+
uses: ./.github/workflows/verifyaotcompat.yml
28+
29+
wrap-up:
30+
needs: build-test
31+
uses: ./.github/workflows/Dotnet.WrapUp.yml
32+
with:
33+
module-name: ${{ inputs.module-name }}
34+
module-directory: './modules/${{ inputs.module-name }}'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Verify Markdown
2+
3+
on:
4+
pull_request:
5+
branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ]
6+
paths:
7+
- '**/*.md'
8+
9+
jobs:
10+
misspell-sanitycheck:
11+
uses: ./.github/workflows/sanitycheck.yml
12+
13+
lint:
14+
uses: ./.github/workflows/markdownlint.yml
15+

.github/workflows/ci-Docs.yaml.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Verify Yaml
2+
3+
on:
4+
pull_request:
5+
branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ]
6+
paths:
7+
- '**/*.yml'
8+
- '**/*.yaml'
9+
10+
jobs:
11+
misspell-sanitycheck:
12+
- uses: ./.github/workflows/sanitycheck.yml
13+
14+
lint:
15+
uses: ./.github/workflows/yamllint.yml
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ]
6+
paths:
7+
- 'modules/Resources.OperatingSystem/**'
8+
9+
jobs:
10+
resources-operatingsystem:
11+
uses: ./.github/workflows/build-module.yml
12+
with:
13+
module-name: Resources.OperatingSystem

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build
22

33
on:
44
pull_request:
5-
branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ]
5+
branches: [ 'main2*', 'instrumentation*', 'exporter*', 'extensions*' ]
66

77
jobs:
88
lint-misspell-sanitycheck:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"solution": {
3+
"path": "..\\..\\opentelemetry-dotnet-contrib.sln",
4+
"projects": [
5+
"modules\\Resources.OperatingSystem\\src\\OpenTelemetry.Resources.OperatingSystem\\OpenTelemetry.Resources.OperatingSystem.csproj",
6+
"modules\\Resources.OperatingSystem\\test\\OpenTelemetry.Resources.OperatingSystem.Tests\\OpenTelemetry.Resources.OperatingSystem.Tests.csproj"
7+
]
8+
}
9+
}

0 commit comments

Comments
 (0)