Skip to content

Commit b9c71b9

Browse files
psandanacijothomas
andauthored
ci: windows support (#185)
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
1 parent b70e1c3 commit b9c71b9

File tree

6 files changed

+164
-35
lines changed

6 files changed

+164
-35
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,29 @@ on:
88
- main
99
paths-ignore:
1010
- '**.md'
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
1114
jobs:
1215
test:
1316
strategy:
1417
matrix:
18+
# test both stable and beta versions of Rust on ubuntu-latest
19+
os: [ubuntu-latest]
1520
rust: [stable, beta]
16-
runs-on: ubuntu-latest
21+
# test only stable version of Rust on Windows and MacOS
22+
include:
23+
- rust: stable
24+
os: windows-latest
25+
- rust: stable
26+
os: macos-latest
27+
- rust: stable
28+
os: ubuntu-22.04-arm
29+
runs-on: ${{ matrix.os }}
30+
continue-on-error: ${{ matrix.rust == 'beta' }}
1731
steps:
1832
- name: Free disk space
33+
if: ${{ matrix.os == 'ubuntu-latest'}}
1934
run: |
2035
df -h
2136
sudo rm -rf /usr/local/lib/android
@@ -31,34 +46,51 @@ jobs:
3146
profile: minimal
3247
- uses: arduino/setup-protoc@v3
3348
with:
34-
repo-token: ${{ secrets.GITHUB_TOKEN }}
35-
- name: Test
36-
run: ./scripts/test.sh
49+
repo-token: ${{ secrets.GITHUB_TOKEN }}
50+
- name: Test (Windows)
51+
if: ${{ matrix.os == 'windows-latest'}}
52+
run: ./scripts/test.ps1
53+
shell: pwsh
54+
- name: Test (Unix)
55+
if: ${{ matrix.os != 'windows-latest'}}
56+
run: bash ./scripts/test.sh
3757
lint:
38-
runs-on: ubuntu-latest
58+
strategy:
59+
matrix:
60+
# clippy must be run in every OS to lint platform-specific code
61+
os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-22.04-arm]
62+
runs-on: ${{ matrix.os }}
3963
steps:
4064
- uses: actions/checkout@v4
4165
with:
4266
submodules: true
4367
- uses: actions-rs/toolchain@v1
4468
with:
4569
toolchain: stable
46-
components: rustfmt
47-
profile: minimal
70+
components: rustfmt, clippy
4871
- uses: arduino/setup-protoc@v3
4972
with:
5073
repo-token: ${{ secrets.GITHUB_TOKEN }}
5174
- uses: actions-rs/cargo@v1
5275
with:
5376
command: fmt
5477
args: --all -- --check
55-
- name: Lint
78+
- name: Lint (Windows)
79+
if: ${{ matrix.os == 'windows-latest'}}
80+
run: ./scripts/lint.ps1
81+
shell: pwsh
82+
- name: Lint (Unix)
83+
if: ${{ matrix.os != 'windows-latest'}}
5684
run: ./scripts/lint.sh
5785
msrv:
5886
strategy:
5987
matrix:
6088
rust: ["1.75.0"]
61-
runs-on: ubuntu-latest
89+
os: [
90+
ubuntu-latest,
91+
# windows-latest # Disabled due bug in `cargo-msrv` on Windows( https://github.com/foresterre/cargo-msrv/issues/1102 )
92+
]
93+
runs-on: ${{ matrix.os }}
6294
continue-on-error: true
6395
steps:
6496
- uses: actions/checkout@v4
@@ -72,10 +104,15 @@ jobs:
72104
- uses: taiki-e/install-action@v2
73105
with:
74106
tool: cargo-msrv
75-
- name: Patch dependencies versions
107+
- name: Patch dependencies versions (Unix)
108+
if: ${{ matrix.os != 'windows-latest'}}
76109
run: bash ./scripts/patch_dependencies.sh
77-
- name: Check MSRV for all crates
110+
- name: Check MSRV for all crates (Unix)
111+
if: ${{ matrix.os != 'windows-latest'}}
78112
run: bash ./scripts/msrv.sh ${{ matrix.rust }}
113+
- name: Check MSRV for all crates (Windows)
114+
if: ${{ matrix.os == 'windows-latest'}}
115+
run: ./scripts/msrv.ps1 ${{ matrix.rust }}
79116
cargo-deny:
80117
runs-on: ubuntu-latest
81118
continue-on-error: true # Prevent sudden announcement of a new advisory from failing ci

opentelemetry-datadog/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ criterion = "0.5"
5151
rand = "0.9"
5252
hyper = "1"
5353
hyper-util = { version = "0.1.6", features = ["client", "full"] }
54-
hyperlocal = "0.9.1"
5554
http-body-util = "0.1.2"
5655
temp-env = "0.3"
5756

57+
[target.'cfg(unix)'.dev-dependencies]
58+
hyperlocal = "0.9.1"
59+
5860
[[bench]]
5961
name = "datadog_exporter"
6062
harness = false

scripts/lint.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$ErrorActionPreference = "Stop"
2+
$PSNativeCommandUseErrorActionPreference = $True
3+
4+
function cargo_feature {
5+
param (
6+
$crate,
7+
$features
8+
)
9+
Write-Host "checking '$crate' with features '$features'"
10+
cargo clippy --manifest-path=$crate/Cargo.toml --all-targets --features "$features" --no-default-features -- -Dwarnings
11+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
12+
}
13+
14+
# Exit with a nonzero code if there are clippy warnings
15+
cargo clippy --workspace --all-targets --all-features -- -Dwarnings
16+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
17+
18+
cargo_feature opentelemetry-etw-logs "default"
19+
cargo_feature opentelemetry-etw-logs "logs_level_enabled"
20+
21+
cargo_feature opentelemetry-etw-metrics ""
22+
23+
exit $LASTEXITCODE

scripts/lint.sh

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,33 @@ cargo_feature() {
99
-Dwarnings
1010
}
1111

12-
if rustup component add clippy; then
13-
# Exit with a nonzero code if there are clippy warnings
14-
cargo clippy --workspace --all-targets --all-features -- -Dwarnings
12+
# Exit with a nonzero code if there are clippy warnings
13+
cargo clippy --workspace --all-targets --all-features -- -Dwarnings
1514

16-
cargo_feature opentelemetry-aws "default"
15+
cargo_feature opentelemetry-aws "default"
1716

18-
cargo_feature opentelemetry-datadog "reqwest-blocking-client,intern-std"
19-
cargo_feature opentelemetry-datadog "reqwest-client,intern-std"
17+
cargo_feature opentelemetry-datadog "reqwest-blocking-client,intern-std"
18+
cargo_feature opentelemetry-datadog "reqwest-client,intern-std"
2019
# TODO: Clippy doesn't seem to like surf client.
2120
# cargo_feature opentelemetry-datadog "surf-client,intern-std"
2221

23-
cargo_feature opentelemetry-contrib "default"
24-
cargo_feature opentelemetry-contrib "api"
25-
cargo_feature opentelemetry-contrib "base64_format"
26-
cargo_feature opentelemetry-contrib "binary_propagator"
27-
cargo_feature opentelemetry-contrib "jaeger_json_exporter"
28-
cargo_feature opentelemetry-contrib "rt-tokio"
29-
cargo_feature opentelemetry-contrib "rt-tokio-current-thread"
30-
cargo_feature opentelemetry-contrib "rt-async-std"
22+
cargo_feature opentelemetry-contrib "default"
23+
cargo_feature opentelemetry-contrib "api"
24+
cargo_feature opentelemetry-contrib "base64_format"
25+
cargo_feature opentelemetry-contrib "binary_propagator"
26+
cargo_feature opentelemetry-contrib "jaeger_json_exporter"
27+
cargo_feature opentelemetry-contrib "rt-tokio"
28+
cargo_feature opentelemetry-contrib "rt-tokio-current-thread"
29+
cargo_feature opentelemetry-contrib "rt-async-std"
3130

32-
cargo_feature opentelemetry-stackdriver "default"
33-
cargo_feature opentelemetry-stackdriver "gcp-authorizer"
34-
cargo_feature opentelemetry-stackdriver "tls-native-roots"
35-
cargo_feature opentelemetry-stackdriver "tls-webpki-roots"
31+
cargo_feature opentelemetry-stackdriver "default"
32+
cargo_feature opentelemetry-stackdriver "gcp-authorizer"
33+
cargo_feature opentelemetry-stackdriver "tls-native-roots"
34+
cargo_feature opentelemetry-stackdriver "tls-webpki-roots"
3635

37-
cargo_feature opentelemetry-user-events-logs "default"
38-
cargo_feature opentelemetry-user-events-logs "spec_unstable_logs_enabled"
36+
cargo_feature opentelemetry-user-events-logs "default"
37+
cargo_feature opentelemetry-user-events-logs "spec_unstable_logs_enabled"
3938

40-
cargo_feature opentelemetry-user-events-metrics ""
39+
cargo_feature opentelemetry-user-events-metrics ""
4140

42-
cargo_feature opentelemetry-resource-detectors ""
43-
fi
41+
cargo_feature opentelemetry-resource-detectors ""

scripts/msrv.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[CmdletBinding()]
2+
param(
3+
[Parameter(Mandatory = $true)]
4+
$version
5+
)
6+
7+
$ErrorActionPreference = "Stop"
8+
$PSNativeCommandUseErrorActionPreference = $True
9+
10+
# function to check if specified toolchain is installed
11+
function check_rust_toolchain_installed {
12+
param (
13+
$version
14+
)
15+
16+
if (!(rustup toolchain list | Select-String -Pattern $version -Quiet)) {
17+
Write-Host "Rust toolchain $version is not installed. Please install it using 'rustup toolchain install $version'."
18+
exit 1
19+
}
20+
}
21+
22+
$RUST_VERSION = $version
23+
24+
# Determine the directory containing the script
25+
$SCRIPT_DIR = $PSScriptRoot
26+
27+
# Path to the configuration file
28+
$CONFIG_FILE="$SCRIPT_DIR/msrv_config.json"
29+
30+
if (-not (Test-Path $CONFIG_FILE)) {
31+
Write-Host "Configuration file $CONFIG_FILE not found."
32+
exit 1
33+
}
34+
35+
# check if specified toolchain is installed
36+
check_rust_toolchain_installed "$RUST_VERSION"
37+
if ($LASTEXITCODE -ne 0) {
38+
exit $LASTEXITCODE
39+
}
40+
41+
# Extract the exact installed rust version string
42+
$installed_version = $(rustup toolchain list | Select-String -pattern 1.75.0).ToString().Split(" ")[0]
43+
44+
# Read the configuration file and get the packages for the specified version
45+
$packages = $(Get-Content "$CONFIG_FILE" | ConvertFrom-Json )."$RUST_VERSION"
46+
if (-not $packages) {
47+
Write-Host "No packages found for Rust version $RUST_VERSION in the configuration file."
48+
exit 1
49+
}
50+
51+
# Check MSRV for the packages
52+
foreach ($package in $packages) {
53+
Write-Host "Verifying MSRV version $installed_version for $package"
54+
rustup run $installed_version cargo msrv verify --path $package --output-format json
55+
if ($LASTEXITCODE -ne 0) {
56+
exit $LASTEXITCODE
57+
}
58+
Write-Host "" # just for nicer separation between packages
59+
}

scripts/test.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$ErrorActionPreference = "Stop"
2+
$PSNativeCommandUseErrorActionPreference = $True
3+
4+
cargo test --manifest-path=opentelemetry-etw-logs/Cargo.toml --all-features
5+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
6+
7+
cargo test --manifest-path=opentelemetry-etw-metrics/Cargo.toml --all-features
8+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
9+
10+
exit $LASTEXITCODE

0 commit comments

Comments
 (0)