-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
135 lines (124 loc) · 5.1 KB
/
action.yml
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
name: Build CloudTruth CLI
description: 'Builds cloudtruth-cli from source'
inputs:
buildOptions:
description: Command-line options passed directly to `cargo build`
testOptions:
description: Command-line options passed directly to `cargo test`
ref:
description: Git ref to build from (defaults to the default branch)
path:
description: 'Relative path under $GITHUB_WORKSPACE to place the repository'
default: '.'
components:
description: Rust toolchain components to install (ex rustfmt, clippy)
profile:
description: rust toolchain profile to use
default: minimal
override:
description: Whether to use rustup default or rustup override (default to rustup default). Set to true for override behavior
default: 'false'
cross:
description: Whether to use Cross or Cargo for builds (default to Cargo). Set to true for cross builds.
default: 'false'
cargoBinstall:
description: If true, installs cargo binstall for faster installation of Cargo utilities
default: 'false'
target:
description: Build targets to install with `rustup`. Note you will still need to pass in the `--target` build option with `buildOptions` if you want Cargo to build this target)
skipUnitTests:
description: Skips running unit tests
default: 'false'
skipCache:
description: Skip caching of Cargo registry and dependencies
default: 'false'
skipBuild:
description: Skip the build step. Useful if you just want to run linting or reports.
default: 'false'
cacheKey:
description: A custom string to prefix cache keys with when caching build artifacts
default: v0-cloudtruth-cli
cacheDirectories:
description: "Additional non workspace directories to be cached, separated by newlines."
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
with:
repository: cloudtruth/cloudtruth-cli
ref: ${{ inputs.ref }}
path: ${{ inputs.path }}
- name: Find rust-toolchain file
shell: bash
working-directory: ${{ inputs.path }}
run: |
if test -f rust-toolchain -o -f rust-toolchain.yml -o -f rust.toolchain.yaml; then
echo 'Found rust-toolchain file'
else
echo 'No rust-toolchain file. Assuming legacy cloudtruth-cli'
echo RUST_TOOLCHAIN=1.63.0 >> $GITHUB_ENV
fi
- name: Install Rust
id: rust
uses: cloudtruth/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
working-directory: ${{ inputs.path }}
profile: ${{ inputs.profile }}
default: true
components: ${{ inputs.components }}
target: ${{ inputs.target }}
- uses: Swatinem/rust-cache@v2
if: ${{ !fromJSON(inputs.skipCache) }}
with:
prefix-key: ${{ inputs.cacheKey }}
shared-key: ${{ runner.os }}-${{ inputs.target }}
workspaces: ${{ inputs.path }} -> target
cache-directories: ${{ inputs.cacheDirectories }}
- name: Install cargo-binstall
if: fromJSON(inputs.cargoBinstall)
shell: bash
run: |
BASE_BINSTALL_URL='https://github.com/cargo-bins/cargo-binstall/releases/latest/download/'
case ${{ runner.os }} in
Linux)
BINSTALL_FILE='cargo-binstall-x86_64-unknown-linux-musl.tgz'
BINSTALL_URL="$BASE_BINSTALL_URL/$BINSTALL_FILE"
curl -LSs "$BINSTALL_URL" | tar -C $HOME/.cargo/bin -xvz
;;
macOS)
BINSTALL_FILE='cargo-binstall-universal-apple-darwin.zip'
BINSTALL_URL="$BASE_BINSTALL_URL/$BINSTALL_FILE"
curl -LSs "$BINSTALL_URL" > "/tmp/$BINSTALL_FILE"
unzip -o -d "$HOME/.cargo/bin" "/tmp/$BINSTALL_FILE"
;;
Windows)
BINSTALL_FILE='cargo-binstall-x86_64-pc-windows-msvc.zip'
BINSTALL_URL="$BASE_BINSTALL_URL/$BINSTALL_FILE"
curl -LSs "$BINSTALL_URL" > "/tmp/$BINSTALL_FILE"
unzip -o -d "$HOME/.cargo/bin" "/tmp/$BINSTALL_FILE"
esac;
- run: cargo binstall --no-confirm --force cross
if: ${{ fromJSON(inputs.cargoBinstall) && fromJSON(inputs.cross) }}
working-directory: ${{ inputs.path }}
shell: bash
- run: cargo install cross
if: ${{ !fromJSON(inputs.cargoBinstall) && fromJSON(inputs.cross) }}
working-directory: ${{ inputs.path }}
shell: bash
- run: cargo build ${{ inputs.buildOptions }}
if: ${{ !fromJSON(inputs.skipBuild) && !fromJSON(inputs.cross) }}
working-directory: ${{ inputs.path }}
shell: bash
- run: cross build ${{ inputs.buildOptions }}
if: ${{ !fromJSON(inputs.skipBuild) && fromJSON(inputs.cross) }}
working-directory: ${{ inputs.path }}
shell: bash
- run: cargo test ${{ inputs.testOptions }}
if: ${{ !fromJSON(inputs.skipBuild) && !inputs.skipUnitTests && !fromJSON(inputs.cross) }}
working-directory: ${{ inputs.path }}
shell: bash
- run: cross test ${{ inputs.testOptions }}
if: ${{ !fromJSON(inputs.skipBuild) && !inputs.skipUnitTests && fromJSON(inputs.cross) }}
working-directory: ${{ inputs.path }}
shell: bash