Repository navigation
97 lines (87 loc) · 3 KB
/
Copy pathpr-linux-cli-test.yml
File metadata and controls
97 lines (87 loc) · 3 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
on:
workflow_call:
inputs:
rustup_toolchain:
type: string
required: true
cli_affected:
description: Whether the pull request can affect the CLI crate, whose job is skipped when false
type: boolean
default: true
copilot_shim_affected:
description: Whether the pull request can affect the Copilot shim crate, whose job is skipped when false
type: boolean
default: true
env:
RUSTUP_TOOLCHAIN: ${{ inputs.rustup_toolchain }}
# Each job reports as "Linux / <job name>", for example "Linux / CLI", whether it runs or not: the
# names are fixed, as GitHub does not evaluate the expressions in the name of a skipped job. The jobs
# run the steps of the first one (steps: &steps) on the crate in their CRATE_DIRECTORY, and their env
# selects how (a flag is on when it is 'true'):
# - CHECK_FORMATTING: check the formatting of the crate
# - CARGO_LOCKED: pass --locked to cargo
# - CARGO_ALL_TARGETS: lint all the targets of the crate
jobs:
cli:
name: CLI
if: ${{ inputs.cli_affected }}
runs-on: vscode-large-runners-ubuntu-8-core
env:
CRATE_DIRECTORY: cli
steps: &steps
- name: Checkout microsoft/vscode
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust
run: |
set -e
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain $RUSTUP_TOOLCHAIN
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Set Rust version
run: |
set -e
rustup default $RUSTUP_TOOLCHAIN
rustup update $RUSTUP_TOOLCHAIN
rustup component add clippy
- name: Install Rust formatting component
if: ${{ env.CHECK_FORMATTING == 'true' }}
run: rustup component add rustfmt
- name: Check Rust versions
run: |
set -e
rustc --version
cargo --version
- name: Check formatting
if: ${{ env.CHECK_FORMATTING == 'true' }}
run: cargo fmt --check
working-directory: ${{ env.CRATE_DIRECTORY }}
- name: Clippy lint
run: |
set -e
args=()
if [[ "$CARGO_ALL_TARGETS" == "true" ]]; then
args+=(--all-targets)
fi
if [[ "$CARGO_LOCKED" == "true" ]]; then
args+=(--locked)
fi
cargo clippy "${args[@]}" -- -D warnings
working-directory: ${{ env.CRATE_DIRECTORY }}
- name: 🧪 Run unit tests
run: |
set -e
args=()
if [[ "$CARGO_LOCKED" == "true" ]]; then
args+=(--locked)
fi
cargo test "${args[@]}"
working-directory: ${{ env.CRATE_DIRECTORY }}
copilot-shim:
name: Copilot Shim
if: ${{ inputs.copilot_shim_affected }}
runs-on: vscode-large-runners-ubuntu-8-core
env:
CRATE_DIRECTORY: copilot_shim
CHECK_FORMATTING: 'true'
CARGO_LOCKED: 'true'
CARGO_ALL_TARGETS: 'true'
steps: *steps