feat(ci): optimize CI (#1283)
* feat(ci): attempt speeding up the CI * fix(ci): avoid redundant runs on PRs * fix: remove redundant comment * fix: remove force option from cargo install * feat(ci): first draft of modulo caching * feat(modulo): add debug step * fix(ci): attempt using absolute paths * fix: use contexts instead of variables * fix: use contexts * fix: remove cache from test runs * fix: change cache key * fix: wrong indentation * chore: add explainatory comment * fix(ci): fix cache order
This commit is contained in:
parent
1b947ec188
commit
6b5d0a3d3b
91
.github/workflows/ci.yml
vendored
91
.github/workflows/ci.yml
vendored
|
@ -3,7 +3,12 @@
|
|||
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- dev
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
@ -16,8 +21,12 @@ jobs:
|
|||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
WX_WIDGETS_BUILD_OUT_DIR: "${{github.workspace}}/wx-widgets-build"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: Check formatting
|
||||
run: |
|
||||
rustup component add rustfmt
|
||||
|
@ -27,26 +36,60 @@ jobs:
|
|||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libx11-dev libxtst-dev libxkbcommon-dev libdbus-1-dev libwxgtk3.0-gtk3-dev
|
||||
- name: Install rust-script and cargo-make
|
||||
run: |
|
||||
cargo install rust-script --version "0.7.0"
|
||||
cargo install cargo-make --version 0.34.0
|
||||
# wxWidgets builds (internal to espanso-modulo) are by far the largest bottleneck
|
||||
# in the current pipeline, so we cache the results for a faster compilation process
|
||||
- name: "Cache wxWidgets builds"
|
||||
if: ${{ runner.os != 'Linux' }}
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
${{env.WX_WIDGETS_BUILD_OUT_DIR}}
|
||||
key: ${{ github.job }}-${{ runner.os }}-${{ hashFiles('espanso-modulo/build.rs') }}-${{ hashFiles('espanso-modulo/vendor/*') }}
|
||||
- name: Build
|
||||
run: |
|
||||
cargo make build-binary
|
||||
- name: Check clippy
|
||||
run: |
|
||||
rustup component add clippy
|
||||
cargo clippy -- -D warnings
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: "10.13"
|
||||
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, macos-latest, ubuntu-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: Check formatting
|
||||
run: |
|
||||
rustup component add rustfmt
|
||||
cargo fmt --all -- --check
|
||||
- name: Install Linux dependencies
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libx11-dev libxtst-dev libxkbcommon-dev libdbus-1-dev libwxgtk3.0-gtk3-dev
|
||||
- name: Install rust-script and cargo-make
|
||||
run: |
|
||||
cargo install rust-script --version "0.7.0"
|
||||
cargo install --force cargo-make --version 0.34.0
|
||||
cargo install cargo-make --version 0.34.0
|
||||
- name: Run test suite
|
||||
run: cargo make test-binary
|
||||
- name: Build
|
||||
run: |
|
||||
cargo make build-binary
|
||||
|
||||
build-wayland:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: Check formatting
|
||||
run: |
|
||||
rustup component add rustfmt
|
||||
|
@ -55,29 +98,57 @@ jobs:
|
|||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libxkbcommon-dev libwxgtk3.0-gtk3-dev libdbus-1-dev
|
||||
- name: Install rust-script and cargo-make
|
||||
run: |
|
||||
cargo install rust-script --version "0.7.0"
|
||||
cargo install cargo-make --version 0.34.0
|
||||
- name: Build
|
||||
run: cargo make build-binary --env NO_X11=true
|
||||
- name: Check clippy
|
||||
run: |
|
||||
rustup component add clippy
|
||||
cargo clippy -p espanso --features wayland -- -D warnings
|
||||
|
||||
test-wayland:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: Check formatting
|
||||
run: |
|
||||
rustup component add rustfmt
|
||||
cargo fmt --all -- --check
|
||||
- name: Install Linux dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libxkbcommon-dev libwxgtk3.0-gtk3-dev libdbus-1-dev
|
||||
- name: Install rust-script and cargo-make
|
||||
run: |
|
||||
cargo install rust-script --version "0.7.0"
|
||||
cargo install --force cargo-make --version 0.34.0
|
||||
cargo install cargo-make --version 0.34.0
|
||||
- name: Run test suite
|
||||
run: cargo make test-binary --env NO_X11=true
|
||||
- name: Build
|
||||
run: cargo make build-binary --env NO_X11=true
|
||||
|
||||
build-macos-arm:
|
||||
runs-on: macos-11
|
||||
env:
|
||||
WX_WIDGETS_BUILD_OUT_DIR: "${{github.workspace}}/wx-widgets-build"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install target
|
||||
run: rustup update && rustup target add aarch64-apple-darwin
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: Install rust-script and cargo-make
|
||||
run: |
|
||||
cargo install rust-script --version "0.7.0"
|
||||
cargo install --force cargo-make --version 0.34.0
|
||||
cargo install cargo-make --version 0.34.0
|
||||
- name: "Cache wxWidgets builds"
|
||||
if: ${{ runner.os != 'Linux' }}
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
${{env.WX_WIDGETS_BUILD_OUT_DIR}}
|
||||
key: ${{ github.job }}-${{ runner.os }}-${{ hashFiles('espanso-modulo/build.rs') }}-${{ hashFiles('espanso-modulo/vendor/*') }}
|
||||
- name: Build
|
||||
run: |
|
||||
cargo make build-macos-arm-binary
|
||||
|
@ -85,5 +156,3 @@ jobs:
|
|||
# uses: mxschmitt/action-tmate@v3
|
||||
# with:
|
||||
# limit-access-to-actor: true
|
||||
|
||||
# TODO: add clippy check
|
|
@ -25,6 +25,9 @@ use std::path::Path;
|
|||
#[cfg(not(target_os = "linux"))]
|
||||
const WX_WIDGETS_ARCHIVE_NAME: &str = "wxWidgets-3.1.5.zip";
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
const WX_WIDGETS_BUILD_OUT_DIR_ENV_NAME: &str = "WX_WIDGETS_BUILD_OUT_DIR";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn build_native() {
|
||||
use std::process::Command;
|
||||
|
@ -36,7 +39,17 @@ fn build_native() {
|
|||
panic!("could not find wxWidgets archive!");
|
||||
}
|
||||
|
||||
let out_dir = PathBuf::from(std::env::var("OUT_DIR").expect("missing OUT_DIR"));
|
||||
let out_dir = if let Ok(out_path) = std::env::var(WX_WIDGETS_BUILD_OUT_DIR_ENV_NAME) {
|
||||
println!(
|
||||
"detected wxWidgets build output directory override: {}",
|
||||
out_path
|
||||
);
|
||||
let path = PathBuf::from(out_path);
|
||||
std::fs::create_dir_all(&path).expect("unable to create wxWidgets out dir");
|
||||
path
|
||||
} else {
|
||||
PathBuf::from(std::env::var("OUT_DIR").expect("missing OUT_DIR"))
|
||||
};
|
||||
let out_wx_dir = out_dir.join("wx");
|
||||
|
||||
if !out_wx_dir.is_dir() {
|
||||
|
@ -154,8 +167,19 @@ fn build_native() {
|
|||
panic!("could not find wxWidgets archive!");
|
||||
}
|
||||
|
||||
let out_dir = PathBuf::from(std::env::var("OUT_DIR").expect("missing OUT_DIR"));
|
||||
let out_dir = if let Ok(out_path) = std::env::var(WX_WIDGETS_BUILD_OUT_DIR_ENV_NAME) {
|
||||
println!(
|
||||
"detected wxWidgets build output directory override: {}",
|
||||
out_path
|
||||
);
|
||||
let path = PathBuf::from(out_path);
|
||||
std::fs::create_dir_all(&path).expect("unable to create wxWidgets out dir");
|
||||
path
|
||||
} else {
|
||||
PathBuf::from(std::env::var("OUT_DIR").expect("missing OUT_DIR"))
|
||||
};
|
||||
let out_wx_dir = out_dir.join("wx");
|
||||
println!("wxWidgets will be compiled into: {}", out_wx_dir.display());
|
||||
|
||||
let target_arch = match std::env::var("CARGO_CFG_TARGET_ARCH")
|
||||
.expect("unable to read target arch")
|
||||
|
|
Loading…
Reference in New Issue
Block a user