# The GitLab Continuous Integration configuration

variables:
  GIT_STRATEGY: "clone"

stages:
  - lint
  - test

workflow:
  rules:
    - if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_NAMESPACE == "redox-os"'
    - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'

fmt:
  image: "rust:trixie"
  stage: lint
  script:
    - rustup component add rustfmt
    - cargo fmt -- --check

cargo-test:
  image: "rust:trixie"
  stage: lint
  script:
    - cargo test --locked

fetch-changed:
  image: "redoxos/redox-base-x86_64"
  stage: test
  script:
    - |
      export PATH="$HOME/.cargo/bin:$PATH" &&
      (curl "https://sh.rustup.rs" -sSf | sh -s -- -y --default-toolchain stable --profile minimal ) &&
      cargo install cbindgen &&
      env PODMAN_BUILD=0 SKIP_CHECK_TOOLS=1 ./scripts/fetch-changed.sh

img:
  image: "redoxos/redox-base-x86_64"
  stage: test
  script:
    - |
      export PATH="$HOME/.cargo/bin:$PATH" &&
      (curl "https://sh.rustup.rs" -sSf | sh -s -- -y --default-toolchain stable --profile minimal ) &&
      cargo install cbindgen &&
      PODMAN_BUILD=0 SKIP_CHECK_TOOLS=1 REPO_BINARY=1 FSTOOLS_NO_MOUNT=1 COOKBOOK_VERBOSE=false make ci-img IMG_TAG=$CI_COMMIT_REF_NAME

pkg:
  image: "rust:trixie"
  stage: test
  script:
    - |
      export PATH="$HOME/.cargo/bin:$PATH" PODMAN_BUILD=0 &&
      make CONFIG_NAME=ci SKIP_CHECK_TOOLS=1 repo-tree ARCH=x86_64 &&
      make CONFIG_NAME=ci SKIP_CHECK_TOOLS=1 repo-tree ARCH=i586 &&
      make CONFIG_NAME=ci SKIP_CHECK_TOOLS=1 repo-tree ARCH=aarch64 &&
      make CONFIG_NAME=ci SKIP_CHECK_TOOLS=1 repo-tree ARCH=riscv64gc
