Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 2213c7e

Browse files
Merge pull request #315 from EspressoSystems/ci-windows-implement
Build project on windows
2 parents cb39aa4 + c567048 commit 2213c7e

File tree

4 files changed

+58
-12
lines changed

4 files changed

+58
-12
lines changed

.github/workflows/build_windows.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Windows build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-*
8+
pull_request:
9+
branches:
10+
- main
11+
- release-*
12+
workflow_dispatch:
13+
14+
jobs:
15+
build:
16+
runs-on: windows-2022
17+
steps:
18+
- name: Configure Git
19+
run: |
20+
git config --global url."https://ancient123:${{ secrets.ORG_GITHUB_PAT }}@github.com/".insteadOf git://github.com/
21+
git config --global url."https://ancient123:${{ secrets.ORG_GITHUB_PAT }}@github.com/".insteadOf ssh://[email protected]/
22+
23+
- name: Checkout Repository
24+
uses: actions/checkout@v3
25+
26+
- uses: Swatinem/rust-cache@v1
27+
name: Enable Rust Caching
28+
29+
- name: Check
30+
run: cargo check --workspace --all-targets

address-book/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ rand = "0.8.5"
3232
rand_chacha = "0.3.1"
3333
serde = { version = "1.0", features = ["derive"] }
3434
signal-hook = "0.3.13"
35-
signal-hook-async-std = "0.2.2"
3635
surf = "2.3.2"
3736
tempdir = "0.3.7"
3837
tide = "0.16.0"
@@ -41,5 +40,8 @@ tracing-futures = "0.2"
4140
tracing-log = "0.1"
4241
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
4342

43+
[target.'cfg(not(windows))'.dependencies]
44+
signal-hook-async-std = "0.2.2"
45+
4446
[dev-dependencies]
4547
portpicker = "0.1"

address-book/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use tide::{
2323
StatusCode,
2424
};
2525

26+
#[cfg(not(windows))]
2627
pub mod signal;
2728

2829
pub const DEFAULT_PORT: u16 = 50078u16;

address-book/src/main.rs

+24-11
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@
44
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
55
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
66

7+
use address_book::{address_book_port, address_book_store_path, init_web_server, FileStore};
78
use std::fs;
89

9-
use address_book::{
10-
address_book_port, address_book_store_path, init_web_server, signal::handle_signals, FileStore,
11-
};
12-
use signal_hook::consts::{SIGINT, SIGTERM};
13-
use signal_hook_async_std::Signals;
14-
1510
#[async_std::main]
1611
async fn main() -> Result<(), std::io::Error> {
17-
let signals = Signals::new(&[SIGINT, SIGTERM]).expect("Failed to create signals.");
18-
let handle = signals.handle();
19-
let signals_task = async_std::task::spawn(handle_signals(signals));
12+
let cleanup_signals = register_interrupt_signals();
2013

2114
tracing_subscriber::fmt()
2215
.compact()
@@ -36,8 +29,28 @@ async fn main() -> Result<(), std::io::Error> {
3629
})
3730
.await?;
3831

39-
handle.close();
40-
signals_task.await;
32+
cleanup_signals.await;
4133

4234
Ok(())
4335
}
36+
37+
#[cfg(windows)]
38+
async fn register_interrupt_signals() {
39+
// Signals aren't properly supported on windows so we'll just exit
40+
}
41+
42+
#[cfg(not(windows))]
43+
fn register_interrupt_signals() -> impl std::future::Future<Output = ()> {
44+
use address_book::signal::handle_signals;
45+
use signal_hook::consts::{SIGINT, SIGTERM};
46+
use signal_hook_async_std::Signals;
47+
48+
let signals = Signals::new(&[SIGINT, SIGTERM]).expect("Failed to create signals.");
49+
let handle = signals.handle();
50+
let signals_task = async_std::task::spawn(handle_signals(signals));
51+
52+
async move {
53+
handle.close();
54+
signals_task.await;
55+
}
56+
}

0 commit comments

Comments
 (0)