# Configure and run code checks include: '.gitlab-ci/utils.yml' # Checks from the pre-commit hook pre-commit-checks: stage: check image: "rustlang/rust:nightly-slim" interruptible: true script: - RUST_BACKTRACE=1 cargo run --manifest-path hooks/checks/Cargo.toml -- --verbose --force-install --cargo-binstall # Checks needing dependencies in the Flatpak runtime flatpak-checks: extends: - .remove_build_only_modules stage: check image: 'quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master' tags: - flatpak interruptible: true variables: CARGO_CODECLIMATE_DOWNLOAD_URL: "https://gitlab.com/woshilapin/cargo-sonar/-/releases/1.5.0/downloads/bin/x86_64-unknown-linux-musl/cargo-codeclimate" CARGO_CODECLIMATE_SHA256SUM: "3343a9c4e8b11fc5bdd63fbdecd883e5d37af1ca03414c289c7d57613146c1cf" script: # Initialize the Flatpak sandbox. - flatpak-builder --keep-build-dirs --user --disable-rofiles-fuse --stop-at=${FLATPAK_MODULE} flatpak_app --repo=repo ${BRANCH:+--default-branch=$BRANCH} ${MANIFEST_PATH} # Lint the Rust code with clippy. # We need to run it twice: the first time generates the JSON output for the # code quality report, and the second time generates the regular output with # more details. - echo "cargo clippy --message-format=json -- -D warnings > clippy-report.json || cargo clippy -- -D warnings" | flatpak-builder --disable-rofiles-fuse --build-shell=${FLATPAK_MODULE} flatpak_app ${MANIFEST_PATH} # Move the report file or it will be deleted when running the next command. - mv .flatpak-builder/build/${FLATPAK_MODULE}/_flatpak_build/clippy-report.json ./ # Lint the Blueprint files. - echo "blueprint-compiler format ../src" | flatpak-builder --disable-rofiles-fuse --build-shell=${FLATPAK_MODULE} flatpak_app ${MANIFEST_PATH} # Lint the Meson files. - echo "meson format -qr .." | flatpak-builder --disable-rofiles-fuse --build-shell=${FLATPAK_MODULE} flatpak_app ${MANIFEST_PATH} - ls -la . after_script: # Download cargo-codeclimate - curl -L -o cargo-codeclimate ${CARGO_CODECLIMATE_DOWNLOAD_URL} - echo "${CARGO_CODECLIMATE_SHA256SUM} cargo-codeclimate" > cargo-codeclimate.sha256sum - sha256sum -c cargo-codeclimate.sha256sum - chmod +x cargo-codeclimate # Convert the clippy report to CodeClimate / GitLab Code Quality format. - ./cargo-codeclimate --clippy --clippy-path clippy-report.json artifacts: reports: codequality: codeclimate.json