image: docker.io/rust:slim-bookworm services: - name: docker.io/groonga/pgroonga:latest-alpine-12-slim alias: postgres pull_policy: if-not-present - name: docker.io/redis:7-alpine alias: redis pull_policy: if-not-present workflow: rules: - if: $CI_PROJECT_PATH == 'firefish/firefish' || $CI_MERGE_REQUEST_PROJECT_PATH == 'firefish/firefish' changes: paths: - packages/**/* - locales/**/* - scripts/**/* - package.json - Cargo.toml - Cargo.lock - Dockerfile - .dockerignore when: always - when: never stages: - dependency - test - build variables: POSTGRES_DB: 'firefish_db' POSTGRES_USER: 'firefish' POSTGRES_PASSWORD: 'password' POSTGRES_HOST_AUTH_METHOD: 'trust' DEBIAN_FRONTEND: 'noninteractive' CARGO_PROFILE_DEV_OPT_LEVEL: '0' CARGO_PROFILE_DEV_LTO: 'off' CARGO_PROFILE_DEV_DEBUG: 'none' CARGO_TERM_COLOR: 'always' GIT_CLEAN_FLAGS: -ffdx -e node_modules/ -e built/ -e target/ -e packages/backend-rs/built/ default: before_script: - apt-get update && apt-get -y upgrade - apt-get -y --no-install-recommends install curl - curl -fsSL 'https://deb.nodesource.com/setup_18.x' | bash - - apt-get install -y --no-install-recommends build-essential clang mold python3 perl nodejs postgresql-client - corepack enable - corepack prepare pnpm@latest --activate - cp .config/ci.yml .config/default.yml - cp ci/cargo/config.toml /usr/local/cargo/config.toml - export PGPASSWORD="${POSTGRES_PASSWORD}" - psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command 'CREATE EXTENSION pgroonga' test:build: stage: test rules: - if: $TEST == 'false' when: never - if: $CI_COMMIT_BRANCH == 'develop' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop' changes: paths: - packages/backend-rs/**/* - packages/macro-rs/**/* - scripts/**/* - package.json - Cargo.toml - Cargo.lock when: always needs: - job: cargo:clippy optional: true - job: cargo:test optional: true script: - pnpm install --frozen-lockfile - pnpm run build:debug - pnpm run migrate test:build:backend_ts_only: stage: test rules: - if: $TEST == 'false' when: never - if: $CI_COMMIT_BRANCH == 'develop' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop' changes: paths: - packages/backend-rs/**/* - packages/macro-rs/**/* - scripts/**/* - package.json - Cargo.toml - Cargo.lock when: never - if: $CI_COMMIT_BRANCH == 'develop' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop' changes: paths: - packages/backend/**/* - packages/firefish-js/**/* - packages/megalodon/**/* when: always before_script: - apt-get update && apt-get -y upgrade - apt-get -y --no-install-recommends install curl - curl -fsSL 'https://deb.nodesource.com/setup_18.x' | bash - - apt-get install -y --no-install-recommends build-essential python3 nodejs postgresql-client - corepack enable - corepack prepare pnpm@latest --activate - mkdir -p packages/backend-rs/built - cp packages/backend-rs/index.js packages/backend-rs/built/index.js - cp packages/backend-rs/index.d.ts packages/backend-rs/built/index.d.ts - cp .config/ci.yml .config/default.yml - export PGPASSWORD="${POSTGRES_PASSWORD}" - psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command 'CREATE EXTENSION pgroonga' script: - pnpm install --frozen-lockfile - pnpm --filter 'backend' --filter 'firefish-js' --filter 'megalodon' run build:debug - pnpm run migrate test:build:client_only: stage: test rules: - if: $TEST == 'false' when: never - if: $CI_COMMIT_BRANCH == 'develop' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop' changes: paths: - packages/backend-rs/**/* - packages/macro-rs/**/* - scripts/**/* - package.json - Cargo.toml - Cargo.lock when: never - if: $CI_COMMIT_BRANCH == 'develop' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop' changes: paths: - packages/client/**/* - packages/firefish-js/**/* - packages/sw/**/* - locales/**/* when: always services: [] before_script: - apt-get update && apt-get -y upgrade - apt-get -y --no-install-recommends install curl - curl -fsSL 'https://deb.nodesource.com/setup_18.x' | bash - - apt-get install -y --no-install-recommends build-essential python3 perl nodejs - corepack enable - corepack prepare pnpm@latest --activate - cp .config/ci.yml .config/default.yml script: - pnpm install --frozen-lockfile - pnpm --filter 'firefish-js' --filter 'client' --filter 'sw' run build:debug build:container: stage: build image: quay.io/buildah/stable:latest services: [] rules: - if: $BUILD == 'false' when: never - if: $CI_COMMIT_BRANCH == 'develop' changes: paths: - packages/**/* - locales/**/* - scripts/copy-assets.mjs - package.json - Cargo.toml - Cargo.lock - Dockerfile - .dockerignore when: always needs: - job: test:build optional: true - job: test:build:backend_ts_only optional: true - job: test:build:client_only optional: true variables: STORAGE_DRIVER: overlay2 before_script: - buildah version - buildah prune --all --force || true - echo "${CI_REGISTRY_PASSWORD}" | buildah login --username "${CI_REGISTRY_USER}" --password-stdin "${CI_REGISTRY}" - export IMAGE_TAG="${CI_REGISTRY}/${CI_PROJECT_PATH}/develop:not-for-production" - export IMAGE_CACHE="${CI_REGISTRY}/${CI_PROJECT_PATH}/develop/cache" script: - |- buildah build \ --platform linux/amd64 \ --layers \ --cache-to "${IMAGE_CACHE}" \ --cache-from "${IMAGE_CACHE}" \ --tag "${IMAGE_TAG}" \ . - buildah inspect "${IMAGE_TAG}" - buildah push "${IMAGE_TAG}" cargo:test: stage: test rules: - if: $TEST == 'false' when: never - if: $CI_COMMIT_BRANCH == 'develop' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop' changes: paths: - packages/backend-rs/**/* - packages/macro-rs/**/* - Cargo.toml - Cargo.lock - package.json when: always script: - curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C /usr/local/cargo/bin - cargo test --doc - cargo nextest run cargo:clippy: stage: test rules: - if: $TEST == 'false' when: never - if: $CI_COMMIT_BRANCH == 'develop' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop' changes: paths: - packages/backend-rs/**/* - packages/macro-rs/**/* when: always services: [] before_script: - apt-get update && apt-get -y upgrade - apt-get install -y --no-install-recommends build-essential clang mold perl - cp ci/cargo/config.toml /usr/local/cargo/config.toml - rustup component add clippy script: - cargo clippy -- -D warnings renovate: stage: dependency image: name: docker.io/renovate/renovate:37-slim entrypoint: [""] rules: - if: $RENOVATE && $CI_PIPELINE_SOURCE == 'schedule' services: [] before_script: [] script: - renovate --platform gitlab --token "${API_TOKEN}" --endpoint "${CI_SERVER_URL}/api/v4" "${CI_PROJECT_PATH}"