-
Notifications
You must be signed in to change notification settings - Fork 7
167 lines (137 loc) · 4.96 KB
/
ci.yml
File metadata and controls
167 lines (137 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: CI
on:
push:
branches:
- "**"
tags-ignore:
- "v*"
pull_request:
permissions:
contents: read
jobs:
lint:
name: Lint (Ubuntu)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install multi-pwsh bootstrap
run: bash ./tools/install-multi-pwsh.sh
- name: Add multi-pwsh bin to PATH
shell: bash
run: |
multi_pwsh_home="${MULTI_PWSH_HOME:-$HOME/.pwsh}"
multi_pwsh_bin="${MULTI_PWSH_BIN_DIR:-${multi_pwsh_home}/bin}"
echo "$multi_pwsh_bin" >> "$GITHUB_PATH"
- name: Cache multi-pwsh downloads
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/multi-pwsh-cache
key: multi-pwsh-cache-${{ runner.os }}-${{ hashFiles('crates/multi-pwsh/Cargo.toml', '.github/workflows/ci.yml') }}
restore-keys: |
multi-pwsh-cache-${{ runner.os }}-
- name: Install PowerShell aliases
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
MULTI_PWSH_CACHE_KEEP: '1'
run: |
multi-pwsh install 7.4
multi-pwsh install 7.5
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Install Rust toolchain
shell: pwsh
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup component add rustfmt clippy --toolchain stable
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2.8.2
- name: Check formatting
run: cargo fmt --all --check
- name: Run clippy
run: cargo clippy --workspace --all-targets
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install multi-pwsh bootstrap (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: ./tools/install-multi-pwsh.ps1
- name: Install multi-pwsh bootstrap (Unix)
if: matrix.os != 'windows-latest'
run: bash ./tools/install-multi-pwsh.sh
- name: Add multi-pwsh bin to PATH (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$multiPwshHome = if ($env:MULTI_PWSH_HOME) { $env:MULTI_PWSH_HOME } else { Join-Path $HOME '.pwsh' }
$multiPwshBin = if ($env:MULTI_PWSH_BIN_DIR) { $env:MULTI_PWSH_BIN_DIR } else { Join-Path $multiPwshHome 'bin' }
$multiPwshBin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Add multi-pwsh bin to PATH (Unix)
if: matrix.os != 'windows-latest'
shell: bash
run: |
multi_pwsh_home="${MULTI_PWSH_HOME:-$HOME/.pwsh}"
multi_pwsh_bin="${MULTI_PWSH_BIN_DIR:-${multi_pwsh_home}/bin}"
echo "$multi_pwsh_bin" >> "$GITHUB_PATH"
- name: Cache multi-pwsh downloads
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/multi-pwsh-cache
key: multi-pwsh-cache-${{ runner.os }}-${{ hashFiles('crates/multi-pwsh/Cargo.toml', '.github/workflows/ci.yml') }}
restore-keys: |
multi-pwsh-cache-${{ runner.os }}-
- name: Install PowerShell aliases
shell: pwsh
env:
GITHUB_TOKEN: ${{ github.token }}
MULTI_PWSH_CACHE_KEEP: '1'
run: |
multi-pwsh install 7.4
multi-pwsh install 7.5
pwsh-7.4 -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
pwsh-7.5 -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Install Rust toolchain
shell: pwsh
run: |
rustup toolchain install stable --profile minimal
rustup default stable
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2.8.2
- name: Configure static MSVC runtime
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
"RUSTFLAGS=-C target-feature=+crt-static" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Build Rust targets
run: cargo build --all-targets
- name: Run Rust tests
run: cargo test --all-targets
- name: Run multi-pwsh venv integration tests
shell: pwsh
run: cargo test -p multi-pwsh --test cli_args venv
- name: Build .NET project
shell: pwsh
run: dotnet build dotnet/bindings/Devolutions.PowerShell.SDK.Bindings.csproj -p:PwshExePath="pwsh-7.4"
- name: Run .NET tests
shell: pwsh
run: dotnet test dotnet/bindings/Devolutions.PowerShell.SDK.Bindings.csproj --no-build -p:PwshExePath="pwsh-7.4"