forked from chshersh/tool-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (178 loc) · 6.53 KB
/
ci.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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: CI
on:
pull_request:
types: [synchronize, opened, reopened]
push:
branches: [main]
schedule:
# additionally run once per week (At 00:00 on Sunday) to maintain cache
- cron: '0 0 * * 0'
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Cache cargo
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target
key: ${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Build
run: cargo build --verbose
- name: Unit tests
run: cargo test --verbose
- if: matrix.os != 'windows-latest'
name: "Integration test: [unix] [install ripgrep]"
env:
SYNC_DIR: "install-ripgrep"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir $SYNC_DIR
cargo run -- --config=tests/$SYNC_DIR.toml install ripgrep
ls -l $SYNC_DIR
if [[ ! -x $SYNC_DIR/rg ]]; then echo "error on: rg"; false; fi
- if: matrix.os == 'ubuntu-latest'
name: "Integration test: [ubuntu-latest] [check bash completion]"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo run -- completion bash --rename test-name > /dev/null 2> log
cat log | tail -n +5 > logg
diff logg tests/bash-completion
if [[ $? == 1 ]]; then logg test/bash-completion; false; fi
- if: matrix.os == 'macos-latest'
name: "Integration test: [macos-latest] [check zsh completion]"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo run -- completion zsh --rename test-name > /dev/null 2> log
cat log | tail -n +5 > logg
diff logg tests/zsh-completion
if [[ $? == 1 ]]; then logg test/zsh-completion; false; fi
- if: matrix.os != 'windows-latest'
name: "Integration test: [unix] [sync-ripgrep]"
env:
SYNC_DIR: "sync-ripgrep"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir $SYNC_DIR
cargo run -- --config=tests/$SYNC_DIR.toml sync
ls -l $SYNC_DIR
if [[ ! -x $SYNC_DIR/rg ]]; then echo "error on: rg"; false; fi
- if: matrix.os == 'windows-latest'
name: "Integration test: [windows] [sync-ripgrep]"
env:
SYNC_DIR: "sync-ripgrep"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir $env:SYNC_DIR
cargo run -- --config="tests\$env:SYNC_DIR.toml" sync
ls -l $env:SYNC_DIR
if (!(Test-Path $env:SYNC_DIR\rg.exe)) {
throw 'error on rg.exe'
}
- if: matrix.os != 'windows-latest'
name: "Integration test: [unix] [sync-full]"
env:
SYNC_DIR: "sync-full"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir $SYNC_DIR
cargo run -- --config=tests/$SYNC_DIR.toml sync
ls -l $SYNC_DIR
if [[ ! -x $SYNC_DIR/bat ]]; then echo "error on: bat"; false; fi
if [[ ! -x $SYNC_DIR/difft ]]; then echo "error on: difft"; false; fi
if [[ ! -x $SYNC_DIR/exa ]]; then echo "error on: exa"; false; fi
if [[ ! -x $SYNC_DIR/fd ]]; then echo "error on: fd"; false; fi
if [[ ! -x $SYNC_DIR/rg ]]; then echo "error on: rg"; false; fi
if [[ ! -x $SYNC_DIR/tool ]]; then echo "error on: tool"; false; fi
if [[ ! -x $SYNC_DIR/gh ]]; then echo "error on: gh"; false; fi
if [[ ! -x $SYNC_DIR/hyperfine ]]; then echo "error on: hyperfine"; false; fi
if [[ ! -x $SYNC_DIR/just ]]; then echo "error on: just"; false; fi
if [[ ! -x $SYNC_DIR/k9s ]]; then echo "error on: k9s"; false; fi
if [[ ! -x $SYNC_DIR/procs ]]; then echo "error on: procs"; false; fi
# disabled because of: https://github.com/alexcrichton/tar-rs/issues/295
# if [[ ! -x $SYNC_DIR/tokei ]]; then echo "error on: tokei"; false; fi
- if: matrix.os != 'windows-latest'
name: "Characterization test: [unix] [default-config]"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo run -- default-config > tools.toml
diff tools.toml tests/default-config.toml
if [[ $? == 1 ]]; then diff tools.toml tests/default-config.toml; false; fi
- if: matrix.os == 'windows-latest'
name: "Integration test: [windows] [full-database]"
env:
SYNC_DIR: "sync-full"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir $env:SYNC_DIR
cargo run -- --config="tests\$env:SYNC_DIR.toml" sync
ls -l $env:SYNC_DIR
if (!(Test-Path $env:SYNC_DIR\bat.exe)) {
throw 'error on bat.exe'
}
if (!(Test-Path $env:SYNC_DIR\difft.exe)) {
throw 'error on difft.exe'
}
if (!(Test-Path $env:SYNC_DIR\fd.exe)) {
throw 'error on fd.exe'
}
if (!(Test-Path $env:SYNC_DIR\rg.exe)) {
throw 'error on rg.exe'
}
if (!(Test-Path $env:SYNC_DIR\tool.exe)) {
throw 'error on tool.exe'
}
if (!(Test-Path $env:SYNC_DIR\gh.exe)) {
throw 'error on gh.exe'
}
if (!(Test-Path $env:SYNC_DIR\hyperfine.exe)) {
throw 'error on hyperfine.exe'
}
if (!(Test-Path $env:SYNC_DIR\just.exe)) {
throw 'error on just.exe'
}
if (!(Test-Path $env:SYNC_DIR\k9s.exe)) {
throw 'error on k9s.exe'
}
if (!(Test-Path $env:SYNC_DIR\procs.exe)) {
throw 'error on procs.exe'
}
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
override: true
- name: Check formatting
run: |
cargo fmt --all -- --check
clippy_check:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features