Skip to content

Commit c088e9a

Browse files
authored
Merge pull request #491 from Nukesor/replace-outdated-actions
ci: Replace actions-rs actions
2 parents 8235f0b + 1b6cb76 commit c088e9a

File tree

12 files changed

+172
-107
lines changed

12 files changed

+172
-107
lines changed

.github/workflows/coverage.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ jobs:
4040
uses: actions/checkout@v3
4141

4242
- name: Setup Rust toolchain
43-
uses: actions-rs/toolchain@v1
43+
uses: dtolnay/rust-toolchain@stable
4444
with:
45-
toolchain: stable
46-
override: true
4745
components: llvm-tools-preview
48-
target: ${{ matrix.target }}
46+
targets: ${{ matrix.target }}
4947

5048
- uses: actions/cache@v3
5149
with:

.github/workflows/lint.yml

+5-13
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ jobs:
5656
uses: actions/checkout@v3
5757

5858
- name: Setup Rust toolchain
59-
uses: actions-rs/toolchain@v1
59+
uses: dtolnay/rust-toolchain@stable
6060
with:
61-
toolchain: stable
62-
override: true
63-
components: rustfmt, clippy
64-
target: ${{ matrix.target }}
61+
components: llvm-tools-preview
62+
targets: ${{ matrix.target }}
6563

6664
- uses: actions/cache@v3
6765
with:
@@ -77,13 +75,7 @@ jobs:
7775
${{ runner.os }}-cargo-${{ matrix.target }}-
7876
7977
- name: cargo fmt
80-
uses: actions-rs/cargo@v1
81-
with:
82-
command: fmt
83-
args: --all -- --check
78+
run : cargo fmt --all -- --check
8479

8580
- name: cargo clippy
86-
uses: actions-rs/cargo@v1
87-
with:
88-
command: clippy
89-
args: --tests --workspace -- -D warnings
81+
run: cargo clippy --tests --workspace -- -D warnings

.github/workflows/package-binary.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,17 @@ jobs:
8383
uses: actions/checkout@v3
8484

8585
- name: Setup Rust toolchain
86-
uses: actions-rs/toolchain@v1
86+
uses: dtolnay/rust-toolchain@stable
8787
with:
88-
toolchain: stable
89-
target: ${{ matrix.target }}
90-
override: true
88+
components: llvm-tools-preview
89+
targets: ${{ matrix.target }}
9190

9291
- name: cargo build
93-
uses: actions-rs/cargo@v1
92+
uses: houseabsolute/actions-rust-cross@v0
9493
with:
9594
command: build
96-
args: --release --locked --target=${{ matrix.target }}
97-
use-cross: ${{ matrix.cross }}
95+
args: --release --locked
96+
target: ${{ matrix.target }}
9897

9998
- name: Compress client
10099
uses: svenstaro/upx-action@v2

.github/workflows/test.yml

+33-23
Original file line numberDiff line numberDiff line change
@@ -39,49 +39,46 @@ jobs:
3939
- os: ubuntu-latest
4040
target: x86_64-unknown-linux-gnu
4141
cross: false
42-
strip: true
4342
- os: ubuntu-latest
4443
target: aarch64-unknown-linux-musl
4544
cross: true
46-
strip: false
4745
- os: ubuntu-latest
4846
target: armv7-unknown-linux-musleabihf
4947
cross: true
50-
strip: false
5148
- os: ubuntu-latest
5249
target: arm-unknown-linux-musleabihf
5350
cross: true
54-
strip: false
5551
- os: windows-latest
5652
target: x86_64-pc-windows-msvc
5753
cross: false
58-
strip: true
5954
- os: macos-latest
6055
target: x86_64-apple-darwin
6156
cross: false
62-
strip: true
6357
- os: macos-latest
6458
target: aarch64-apple-darwin
6559
cross: true
66-
strip: true
6760

6861
steps:
6962
- name: Checkout code
7063
uses: actions/checkout@v3
7164

7265
- name: Setup Rust toolchain
73-
uses: actions-rs/toolchain@v1
66+
uses: dtolnay/rust-toolchain@stable
7467
with:
75-
toolchain: stable
76-
override: true
7768
components: llvm-tools-preview
78-
target: ${{ matrix.target }}
69+
targets: ${{ matrix.target }}
7970

8071
- name: Install cargo-nextest
8172
uses: taiki-e/install-action@v2
8273
with:
8374
tool: nextest
8475

76+
- name: Install cargo-cross
77+
uses: taiki-e/install-action@v2
78+
with:
79+
tool: cross
80+
if: ${{ matrix.cross }}
81+
8582
- uses: actions/cache@v3
8683
with:
8784
path: |
@@ -94,24 +91,37 @@ jobs:
9491
restore-keys: |
9592
${{ runner.os }}-cargo-${{ matrix.target }}-
9693
94+
# ----- Non-Cross path
9795
- name: cargo build
98-
uses: actions-rs/cargo@v1
99-
with:
100-
command: build
101-
args: --target=${{ matrix.target }}
102-
use-cross: ${{ matrix.cross }}
96+
run: cargo build --target=${{ matrix.target }}
97+
if: ${{ !matrix.cross }}
10398

10499
- name: cargo test
105-
uses: actions-rs/cargo@v1
106-
if: ${{ !matrix.cross }}
100+
run: cargo nextest run --workspace --target=${{ matrix.target }}
107101
env:
108102
NEXTEST_PROFILE: ci # defined in .config/nextest.toml
109-
with:
110-
command: nextest
111-
args: run --workspace --target=${{ matrix.target }}
112-
use-cross: ${{ matrix.cross }}
103+
if: ${{ !matrix.cross }}
104+
105+
# ----- Cross path
106+
#- name: Install qemu
107+
# run: apt-get install --assume-yes binfmt-support qemu-user-static qemu-user
108+
# if: ${{ matrix.cross }}
109+
110+
- name: cargo build
111+
run: cross build --target=${{ matrix.target }}
112+
if: ${{ matrix.cross }}
113+
114+
# We don't do automated testing for cross builds yet.
115+
# - They don't work in the CI. I have yet to figure out why things aren't set up properly.
116+
# - The tests run way to slow and all kinds of race conditions are triggered.
117+
# Until we find a way to run time related tests in an ultra slow environment, this needs to be postponed.
118+
#- name: cargo test
119+
# run: cross test run --workspace --target=${{ matrix.target }}
120+
# env:
121+
# NEXTEST_PROFILE: ci # defined in .config/nextest.toml
122+
# if: ${{ matrix.cross }}
113123

114-
# The test result artifacts are used by the test-report.yaml workflow.
124+
# ----- Test result artifacts are used by the test-report.yaml workflow.
115125
- name: upload test results
116126
uses: actions/upload-artifact@v3
117127
if: ${{ !matrix.cross }}

Cross.toml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[target.x86_64-unknown-linux-musl]
2+
image = "ghcr.io/cross-rs/x86_64-unknown-linux-musl:main"
3+
pre-build = [
4+
"""
5+
dpkg --add-architecture amd64 && \
6+
apt-get update && \
7+
apt-get install --assume-yes lld clang
8+
"""
9+
]
10+
11+
[target.aarch64-unknown-linux-musl]
12+
image = "ghcr.io/cross-rs/aarch64-unknown-linux-musl:main"
13+
pre-build = [
14+
"""
15+
apt-get update && \
16+
apt-get install --assume-yes lld clang
17+
"""
18+
]
19+
20+
[target.armv7-unknown-linux-musleabihf]
21+
image = "ghcr.io/cross-rs/armv7-unknown-linux-musleabihf:main"
22+
pre-build = [
23+
"""
24+
apt-get update && \
25+
apt-get install --assume-yes lld clang
26+
"""
27+
]
28+
29+
[target.arm-unknown-linux-musleabihf]
30+
image = "ghcr.io/cross-rs/arm-unknown-linux-musleabihf:main"
31+
pre-build = [
32+
"""
33+
apt-get update && \
34+
apt-get install --assume-yes lld clang
35+
"""
36+
]
File renamed without changes.

docs/Cross.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Cross compilation
2+
3+
Compilation and testing for other architectures is rather easy with `cross`.
4+
5+
1. Install `cargo-cross`.
6+
1. Make sure to install `qemu`.
7+
- On Arch-Linux install `qemu-user-static-binfmt`.
8+
- On Ubuntu install `binfmt-support` and `qemu-user-static`.
9+
10+
Run the build/test against the target infrastructure, I.e.:
11+
12+
- `cross build --target=aarch64-unknown-linux-musl`
13+
- `cross test --target=aarch64-unknown-linux-musl`

pueue/tests/client/integration/follow.rs

+45-42
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use anyhow::{Context, Result};
22
use rstest::rstest;
33

44
use crate::client::helper::*;
5-
use pueue_lib::network::message::ResetMessage;
65

76
pub fn set_read_local_logs(daemon: &mut PueueDaemon, read_local_logs: bool) -> Result<()> {
87
// Force the client to read remote logs via config file.
@@ -102,44 +101,48 @@ async fn fail_on_non_existing(#[case] read_local_logs: bool) -> Result<()> {
102101
Ok(())
103102
}
104103

105-
/// This test is ignored on apple, since it's super flaky. Somebody has to debug this.
106-
#[cfg(not(target = "x86_64-apple-darwin"))]
107-
mod non_apple {
108-
use super::*;
109-
110-
/// Fail and print an error message when following a non-existing task disappears
111-
#[rstest]
112-
#[case(true)]
113-
#[case(false)]
114-
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
115-
async fn fail_on_disappearing(#[case] read_local_logs: bool) -> Result<()> {
116-
let mut daemon = daemon().await?;
117-
set_read_local_logs(&mut daemon, read_local_logs)?;
118-
let shared = &daemon.settings.shared;
119-
120-
// Add a task echoes something and waits for a while
121-
assert_success(add_task(shared, "echo test && sleep 20").await?);
122-
wait_for_task_condition(shared, 0, |task| task.is_running()).await?;
123-
124-
// Reset the daemon after 2 seconds. At this point, the client will already be following the
125-
// output and should notice that the task went away..
126-
// This is a bit hacky, but our client test helper always waits for the command to finish
127-
// and I'm feeling too lazy to add a new helper function now.
128-
let moved_shared = shared.clone();
129-
tokio::task::spawn(async move {
130-
sleep_ms(2000).await;
131-
// Reset the daemon
132-
send_message(&moved_shared, ResetMessage {})
133-
.await
134-
.expect("Failed to send Start tasks message");
135-
});
136-
137-
// Execute `follow` and remove the task
138-
// The client should exit with exit code `1`.
139-
let output = run_client_command(shared, &["follow", "0"])?;
140-
141-
assert_snapshot_matches_stdout("follow__fail_on_disappearing", output.stdout)?;
142-
143-
Ok(())
144-
}
145-
}
104+
// /// This test is commented for the time being.
105+
// /// There's a race condition that can happen from time to time.
106+
// /// It's especially reliably hit on MacOS for some reason.
107+
// ///
108+
// /// What happens is that the daemon resets in between reading the output of the file
109+
// /// and the check whether the task actually still exists in the daemon.
110+
// /// There's really no way to properly work around this.
111+
// /// So I'll keep this commented for the time being.
112+
// ///
113+
// ///
114+
// /// Fail and print an error message when following a non-existing task disappears
115+
// #[rstest]
116+
// #[case(true)]
117+
// #[case(false)]
118+
// #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
119+
// async fn fail_on_disappearing(#[case] read_local_logs: bool) -> Result<()> {
120+
// let mut daemon = daemon().await?;
121+
// set_read_local_logs(&mut daemon, read_local_logs)?;
122+
// let shared = &daemon.settings.shared;
123+
//
124+
// // Add a task echoes something and waits for a while
125+
// assert_success(add_task(shared, "echo test && sleep 20").await?);
126+
// wait_for_task_condition(shared, 0, |task| task.is_running()).await?;
127+
//
128+
// // Reset the daemon after 2 seconds. At this point, the client will already be following the
129+
// // output and should notice that the task went away..
130+
// // This is a bit hacky, but our client test helper always waits for the command to finish
131+
// // and I'm feeling too lazy to add a new helper function now.
132+
// let moved_shared = shared.clone();
133+
// tokio::task::spawn(async move {
134+
// sleep_ms(2000).await;
135+
// // Reset the daemon
136+
// send_message(&moved_shared, ResetMessage {})
137+
// .await
138+
// .expect("Failed to send Start tasks message");
139+
// });
140+
//
141+
// // Execute `follow` and remove the task
142+
// // The client should exit with exit code `1`.
143+
// let output = run_client_command(shared, &["follow", "0"])?;
144+
//
145+
// assert_snapshot_matches_stdout("follow__fail_on_disappearing", output.stdout)?;
146+
//
147+
// Ok(())
148+
// }

pueue/tests/helper/daemon.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ pub async fn shutdown_daemon(shared: &Shared) -> Result<Message> {
2323
/// long.
2424
pub async fn get_pid(pid_path: &Path) -> Result<i32> {
2525
// Give the daemon about 1 sec to boot and create the pid file.
26-
let tries = 20;
26+
let sleep = 50;
27+
let tries = TIMEOUT / sleep;
2728
let mut current_try = 0;
2829

2930
while current_try < tries {
3031
// The daemon didn't create the pid file yet. Wait for 100ms and try again.
3132
if !pid_path.exists() {
32-
sleep_ms(50).await;
33+
sleep_ms(sleep).await;
3334
current_try += 1;
3435
continue;
3536
}
@@ -58,15 +59,16 @@ pub async fn get_pid(pid_path: &Path) -> Result<i32> {
5859
/// Waits for a daemon to shut down.
5960
pub async fn wait_for_shutdown(child: &mut Child) -> Result<()> {
6061
// Give the daemon about 1 sec to shutdown.
61-
let tries = 40;
62+
let sleep = 50;
63+
let tries = TIMEOUT / sleep;
6264
let mut current_try = 0;
6365

6466
while current_try < tries {
6567
// Try to read the process exit code. If this succeeds or
6668
// an error is returned, the process is gone.
6769
if let Ok(None) = child.try_wait() {
6870
// Process is still alive, wait a little longer
69-
sleep_ms(50).await;
71+
sleep_ms(sleep).await;
7072
current_try += 1;
7173
continue;
7274
}

pueue/tests/helper/fixtures.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ pub async fn daemon_with_settings(settings: Settings, tempdir: TempDir) -> Resul
4545
tokio::spawn(run_and_handle_error(path, true));
4646
let pid = get_pid(&settings.shared.pid_path()).await?;
4747

48-
let tries = 20;
48+
let sleep = 50;
49+
let tries = TIMEOUT / sleep;
4950
let mut current_try = 0;
5051

5152
// Wait up to 1s for the unix socket to pop up.
5253
let socket_path = settings.shared.unix_socket_path();
5354
while current_try < tries {
54-
sleep_ms(50).await;
55+
sleep_ms(sleep).await;
5556
if socket_path.exists() {
5657
create_test_groups(&settings.shared).await?;
5758
return Ok(PueueDaemon {
@@ -100,13 +101,14 @@ pub async fn standalone_daemon(shared: &Shared) -> Result<Child> {
100101
.stderr(Stdio::piped())
101102
.spawn()?;
102103

103-
let tries = 20;
104+
let sleep = 50;
105+
let tries = TIMEOUT / sleep;
104106
let mut current_try = 0;
105107

106108
// Wait up to 1s for the unix socket to pop up.
107109
let socket_path = shared.unix_socket_path();
108110
while current_try < tries {
109-
sleep_ms(50).await;
111+
sleep_ms(sleep).await;
110112
if socket_path.exists() {
111113
return Ok(child);
112114
}

0 commit comments

Comments
 (0)