feat: single stage ci with tests, clippy and fmt check all in one
Some checks are pending
/ cargo-fmtcheck (push) Waiting to run
/ cargo-clippy (push) Waiting to run
/ cargo-test (push) Waiting to run
/ appimage (push) Waiting to run

This commit is contained in:
Gabriele Musco 2024-08-22 07:51:16 +02:00
parent f04723c1c4
commit e781736ffa
4 changed files with 25 additions and 47 deletions

View file

@ -13,52 +13,6 @@ commitcheck:
# only run for merge requests
- if [ -z "$CI_MERGE_REQUEST_TITLTE" ]; then true; else python ./dist/tagging/check_conventional_commit.py "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"; fi
cargo:fmtcheck:
image: "rust:slim"
stage: check
script:
- rustup component add rustfmt
# Create blank versions of our configured files
# so rustfmt does not yell about non-existent files or completely empty files
- echo -e "" >> src/constants.rs
- rustc -Vv && cargo -Vv
- cargo fmt --version
- cargo fmt --all -- --check
cargo:clippy:
stage: check
variables:
RUSTFLAGS: "-Dwarnings"
script:
- apt-get update
- apt-get install libgtk-4-dev libadwaita-1-dev libssl-dev libjxl-dev libvte-2.91-gtk4-dev meson ninja-build git desktop-file-utils gettext file libusb-dev libusb-1.0-0-dev libopenxr-dev curl -y
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh
- chmod +x /tmp/rustup.sh
- /tmp/rustup.sh -y
- source "$HOME/.cargo/env"
- rustup component add clippy
- rustc -Vv && cargo -Vv
- cp src/constants.rs.in src/constants.rs
- cargo clippy --version
- cargo clippy --all-targets --all-features
cargo:test:
stage: check
script:
- apt-get update
- apt-get install libgtk-4-dev libadwaita-1-dev libssl-dev libjxl-dev libvte-2.91-gtk4-dev meson ninja-build git desktop-file-utils gettext file libusb-dev libusb-1.0-0-dev libopenxr-dev curl -y
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh
- chmod +x /tmp/rustup.sh
- /tmp/rustup.sh -y
- source "$HOME/.cargo/env"
- rustc --version && cargo --version # Print version info for debugging
- meson setup build -Dprefix="$PWD/build/localprefix" -Dprofile=development
- ninja -C build
- cargo test --workspace --verbose
cache:
paths:
- /var/cache/apt
appimage:
stage: deploy
script:
@ -68,6 +22,7 @@ appimage:
- chmod +x /tmp/rustup.sh
- /tmp/rustup.sh -y
- source "$HOME/.cargo/env"
- rustup component add clippy
- bash ./dist/appimage/build_appimage.sh
artifacts:
paths:

View file

@ -8,6 +8,7 @@ if [[ ! -f Cargo.toml ]]; then
fi
meson setup appimage_build -Dprefix=/usr -Dprofile=default
meson test -C appimage_build --print-errorlogs
DESTDIR="$PWD/AppDir" ninja -C appimage_build install
curl -SsLO https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage

View file

@ -24,6 +24,7 @@ pub mod build_tools;
pub mod builders;
pub mod cmd_runner;
pub mod config;
#[rustfmt::skip]
pub mod constants;
pub mod depcheck;
pub mod device_prober;

View file

@ -3,7 +3,7 @@ config = configure_file(
output: 'constants.rs',
configuration: global_conf
)
# Copy the config.rs output to the source directory.
# Copy the constants.rs output to the source directory.
run_command(
'cp',
meson.project_build_root() / 'src' / 'constants.rs',
@ -43,3 +43,24 @@ cargo_build = custom_target(
'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@',
]
)
test(
'cargo-fmt-check',
cargo,
args: ['fmt', '--all', '--check']
)
test(
'cargo-clippy',
cargo,
env: ['RUSTFLAGS=-Dwarnings'],
args: ['clippy', '--all-targets', '--all-features'],
timeout: 0,
)
test(
'cargo-test',
cargo,
args: ['test'],
timeout: 0,
)