Skip to content

Commit 448029c

Browse files
authored
Improve local testing scripts (#51)
* `run_ci_tests.sh` is refactored and new scripts `start_sshd.sh` and `stop_sshd.sh` is created as a result. Now, instead of starting a new sshd instance on every run to `run_ci_tests.sh`, new sshd instance is started and shared among runs of `run_ci_tests.sh` to speed up the testing cycle. Another important improvements to `run_ci_tests.sh` is that now it uses a different target directory to avoid rebuilding all dependencies. Since IDEs usually do not set RUSTFLAGS='--cfg=ci', `run_ci_tests.sh` would usually rebuild all the dependencies and openssh. This makes run_ci_tests.sh incrediably slow, and it also affects IDEs checking, since now the IDEs also need to rebuild the crate. Changing the target directory to `ci-target` fixed this problem, and it also has the new advantage that `run_ci_tests.sh` can be run concurrently with the IDE checking and other `cargo` commands manually run in terminal and the newly introduced `check.sh`. `check.sh` is introduced to quickly check the syntax with flags `--all-fatures` and run tests. It is much faster than `run_ci_tests.sh`. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix common bash mistakes in scripts Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Add all scripts to `paths-ignore` in workflows Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix `known_hosts` problem in integration test Since the sshd server is ran in a container and every time that container is removed and added again, the key of the server changes and invalidates the `known_hosts`. Previously, we solved this by removing the key from `~/.ssh/known_hosts` and then remove `~/.ssh/known_hosts.old`, which might end up remove the previous `~/.ssh/known_hosts.old` and upon current removal of the keys from `~/.ssh/known_hosts`, there is a race condition and produce UB. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Add new workflow shellcheck Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent 76e2c23 commit 448029c

File tree

15 files changed

+224
-63
lines changed

15 files changed

+224
-63
lines changed

.github/workflows/coverage.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
on:
22
push:
33
branches: [master]
4+
paths-ignore:
5+
- 'build_doc.sh'
6+
- 'check.sh'
7+
- 'run_ci_tests.sh'
8+
- 'start_sshd.sh'
9+
- 'stop_sshd.sh'
410
pull_request:
11+
paths-ignore:
12+
- 'build_doc.sh'
13+
- 'check.sh'
14+
- 'run_ci_tests.sh'
15+
- 'start_sshd.sh'
16+
- 'stop_sshd.sh'
517
name: coverage
618
jobs:
719
test:
@@ -13,7 +25,8 @@ jobs:
1325
- uses: actions/checkout@v2
1426
- run: |
1527
chmod 600 .test-key
16-
ssh -i .test-key -v -p 2222 -l test-user openssh -o StrictHostKeyChecking=accept-new whoami
28+
mkdir /tmp/openssh-rs
29+
ssh -i .test-key -v -p 2222 -l test-user openssh -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/tmp/openssh-rs/known_hosts whoami
1730
name: Test ssh connectivity
1831
- run: |
1932
eval $(ssh-agent)

.github/workflows/features.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
on:
22
push:
33
branches: [master]
4+
paths-ignore:
5+
- 'build_doc.sh'
6+
- 'check.sh'
7+
- 'run_ci_tests.sh'
8+
- 'start_sshd.sh'
9+
- 'stop_sshd.sh'
410
pull_request:
11+
paths-ignore:
12+
- 'build_doc.sh'
13+
- 'check.sh'
14+
- 'run_ci_tests.sh'
15+
- 'start_sshd.sh'
16+
- 'stop_sshd.sh'
517
name: cargo hack
618
jobs:
719
check:

.github/workflows/minimal.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
on:
22
push:
33
branches: [master]
4+
paths-ignore:
5+
- 'build_doc.sh'
6+
- 'check.sh'
7+
- 'run_ci_tests.sh'
8+
- 'start_sshd.sh'
9+
- 'stop_sshd.sh'
410
pull_request:
11+
paths-ignore:
12+
- 'build_doc.sh'
13+
- 'check.sh'
14+
- 'run_ci_tests.sh'
15+
- 'start_sshd.sh'
16+
- 'stop_sshd.sh'
517
name: With dependencies at minimal versions
618
jobs:
719
test:
@@ -18,7 +30,8 @@ jobs:
1830
- uses: actions/checkout@v2
1931
- run: |
2032
chmod 600 .test-key
21-
ssh -i .test-key -v -p 2222 -l test-user 127.0.0.1 -o StrictHostKeyChecking=accept-new whoami
33+
mkdir /tmp/openssh-rs
34+
ssh -i .test-key -v -p 2222 -l test-user 127.0.0.1 -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/tmp/openssh-rs/known_hosts whoami
2235
name: Test ssh connectivity
2336
- run: |
2437
eval $(ssh-agent)

.github/workflows/msrv.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
on:
22
push:
33
branches: [master]
4+
paths-ignore:
5+
- 'build_doc.sh'
6+
- 'check.sh'
7+
- 'run_ci_tests.sh'
8+
- 'start_sshd.sh'
9+
- 'stop_sshd.sh'
410
pull_request:
11+
paths-ignore:
12+
- 'build_doc.sh'
13+
- 'check.sh'
14+
- 'run_ci_tests.sh'
15+
- 'start_sshd.sh'
16+
- 'stop_sshd.sh'
517
name: Minimum Supported Rust Version
618
jobs:
719
check:

.github/workflows/os-check.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
on:
22
push:
33
branches: [master]
4+
paths-ignore:
5+
- 'build_doc.sh'
6+
- 'check.sh'
7+
- 'run_ci_tests.sh'
8+
- 'start_sshd.sh'
9+
- 'stop_sshd.sh'
410
pull_request:
11+
paths-ignore:
12+
- 'build_doc.sh'
13+
- 'check.sh'
14+
- 'run_ci_tests.sh'
15+
- 'start_sshd.sh'
16+
- 'stop_sshd.sh'
517
name: cargo check
618
jobs:
719
os-check:

.github/workflows/shellcheck.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
on:
2+
push:
3+
branches: [master]
4+
pull_request:
5+
name: shellcheck
6+
jobs:
7+
shellcheck:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: shellcheck
12+
run: shellcheck *.sh

.github/workflows/style.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
on:
22
push:
33
branches: [master]
4+
paths-ignore:
5+
- 'build_doc.sh'
6+
- 'check.sh'
7+
- 'run_ci_tests.sh'
8+
- 'start_sshd.sh'
9+
- 'stop_sshd.sh'
410
pull_request:
11+
paths-ignore:
12+
- 'build_doc.sh'
13+
- 'check.sh'
14+
- 'run_ci_tests.sh'
15+
- 'start_sshd.sh'
16+
- 'stop_sshd.sh'
517
name: lint
618
jobs:
719
style:

.github/workflows/test.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
on:
22
push:
33
branches: [master]
4+
paths-ignore:
5+
- 'build_doc.sh'
6+
- 'check.sh'
7+
- 'run_ci_tests.sh'
8+
- 'start_sshd.sh'
9+
- 'stop_sshd.sh'
410
pull_request:
11+
paths-ignore:
12+
- 'build_doc.sh'
13+
- 'check.sh'
14+
- 'run_ci_tests.sh'
15+
- 'start_sshd.sh'
16+
- 'stop_sshd.sh'
517
name: cargo test
618
jobs:
719
test:
@@ -18,7 +30,8 @@ jobs:
1830
- uses: actions/checkout@v2
1931
- run: |
2032
chmod 600 .test-key
21-
ssh -i .test-key -v -p 2222 -l test-user 127.0.0.1 -o StrictHostKeyChecking=accept-new whoami
33+
mkdir /tmp/openssh-rs
34+
ssh -i .test-key -v -p 2222 -l test-user 127.0.0.1 -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/tmp/openssh-rs/known_hosts whoami
2235
name: Test ssh connectivity
2336
- run: |
2437
eval $(ssh-agent)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
2+
/ci-target
23
Cargo.lock

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ repository = "https://github.com/openssh-rust/openssh.git"
1313
keywords = ["ssh","remote","openssh","orchestration"]
1414
categories = ["network-programming", "api-bindings"]
1515

16+
exclude = ["ci-target", "*.sh"]
17+
1618
[badges]
1719
azure-devops = { project = "jonhoo/jonhoo", pipeline = "openssh", build = "23" }
1820
codecov = { repository = "jonhoo/openssh-rs", branch = "master", service = "github" }

0 commit comments

Comments
 (0)