diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index f45c2db..0000000 --- a/.drone.yml +++ /dev/null @@ -1,146 +0,0 @@ ---- -kind: pipeline -type: docker -name: default - -platform: - os: linux - arch: amd64 - -steps: -- name: Run tests - pull: always - image: rust:1-slim-buster - commands: - - apt-get update -y - - apt-get install -y wget libssl-dev pkg-config - - apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libavdevice-dev clang llvm - - apt-get install -y python3 python3-pip - - pip3 install cfscrape - - wget -O sccache.tar.gz https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz - - tar zxvf sccache.tar.gz - - export RUSTC_WRAPPER=$(pwd)/sccache-0.2.13-x86_64-unknown-linux-musl/sccache - - export SQLX_OFFLINE=true - - cargo build - - cargo test - - $(pwd)/sccache-0.2.13-x86_64-unknown-linux-musl/sccache --show-stats - environment: - AWS_ACCESS_KEY_ID: - from_secret: sccache_s3_access_key - AWS_SECRET_ACCESS_KEY: - from_secret: sccache_s3_secret_key - SCCACHE_BUCKET: sccache - SCCACHE_ENDPOINT: - from_secret: sccache_s3_endpoint - SCCACHE_S3_USE_SSL: true - -- name: Build FuzzySearch API - pull: always - image: plugins/docker - settings: - auto_tag: true - dockerfile: fuzzysearch/Dockerfile - password: - from_secret: docker_password - registry: registry.huefox.com - repo: registry.huefox.com/fuzzysearch/api - username: - from_secret: docker_username - when: - branch: - - main - event: - - push - paths: - - fuzzysearch/** - - Cargo.lock - -- name: Build FuzzySearch Webhook - pull: always - image: plugins/docker - settings: - auto_tag: true - dockerfile: fuzzysearch-webhook/Dockerfile - password: - from_secret: docker_password - registry: registry.huefox.com - repo: registry.huefox.com/fuzzysearch/webhook - username: - from_secret: docker_username - when: - branch: - - main - event: - - push - paths: - - fuzzysearch-webhook/** - - Cargo.lock - -- name: Build Ingester e621 - pull: always - image: plugins/docker - settings: - auto_tag: true - dockerfile: fuzzysearch-ingest-e621/Dockerfile - password: - from_secret: docker_password - registry: registry.huefox.com - repo: registry.huefox.com/fuzzysearch/ingest-e621 - username: - from_secret: docker_username - when: - branch: - - main - event: - - push - paths: - - fuzzysearch-ingest-e621/** - - Cargo.lock - -- name: Build Ingester FurAffinity - pull: always - image: plugins/docker - settings: - auto_tag: true - dockerfile: fuzzysearch-ingest-furaffinity/Dockerfile - password: - from_secret: docker_password - registry: registry.huefox.com - repo: registry.huefox.com/fuzzysearch/ingest-furaffinity - username: - from_secret: docker_username - when: - branch: - - main - event: - - push - paths: - - fuzzysearch-ingest-furaffinity/** - - Cargo.lock - -- name: Build Ingester Weasyl - pull: always - image: plugins/docker - settings: - auto_tag: true - dockerfile: fuzzysearch-ingest-weasyl/Dockerfile - password: - from_secret: docker_password - registry: registry.huefox.com - repo: registry.huefox.com/fuzzysearch/ingest-weasyl - username: - from_secret: docker_username - when: - branch: - - main - event: - - push - paths: - - fuzzysearch-ingest-weasyl/** - - Cargo.lock - ---- -kind: signature -hmac: af0338b214c113b628f362a1bff2b282dece671adc6247e88d11ec7e0c7edc2a - -... diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5c2d40f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,174 @@ +stages: + - test + - build + - image + +variables: + CARGO_HOME: /root/.cargo + SCCACHE_VERSION: v0.2.15 + SCCACHE_S3_USE_SSL: "true" + SCCACHE_BUCKET: "sccache" + + SQLX_OFFLINE: "true" + +# Cache should only be updated once, default to pull only +cache: &global_cache + paths: + - .cargo/ + policy: pull + +# Run tests on current stable Rust version +test:latest: &base_test + image: rust:1.51-slim-buster + stage: test + cache: + <<: *global_cache + policy: pull-push + before_script: + # Use proxy for apt, install wget to download sccache and other deps + - export http_proxy=$DEBIAN_PROXY + - apt-get update -y + - apt-get install -y wget libssl-dev pkg-config libavcodec-dev libavformat-dev libavutil-dev libavdevice-dev clang llvm python3 python3-pip + - unset http_proxy + + # Download and extract sccache, ensuring it's executable + - wget -q -O /tmp/sccache.tar.gz https://github.com/mozilla/sccache/releases/download/$SCCACHE_VERSION/sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz + - tar zxvf /tmp/sccache.tar.gz --strip-components=1 -C /tmp + - export RUSTC_WRAPPER=/tmp/sccache + - chmod a+x $RUSTC_WRAPPER + + # Move sccache config into place + - mkdir -p $HOME/.config/sccache + - mv $SCCACHE_CONFIG $HOME/.config/sccache/config + + # Prepare cargo data from cache + - rm -rf /root/.cargo || true + - mv .cargo /root/.cargo || true + + # Prepare cargo-cache for cleaning data later + - cargo install cargo-cache --no-default-features --features ci-autoclean + script: + # Build, test, and show stats + - cargo build --verbose + - cargo test --verbose + - $RUSTC_WRAPPER --show-stats + + # Clean cargo data, move back into place for caching + - $CARGO_HOME/bin/cargo-cache + - rm -rf .cargo || true + - mv /root/.cargo .cargo || true + +# Same as above, but nightly Rust +test:nightly: + <<: *base_test + image: rustlang/rust:nightly-slim + allow_failure: true + +build:api: &base_build + <<: *base_test + stage: build + cache: + <<: *global_cache + policy: pull + needs: ['test:latest'] + artifacts: + expire_in: 1 day + paths: + - ./fuzzysearch/fuzzysearch + script: + - cargo build --verbose --release --bin fuzzysearch + - $RUSTC_WRAPPER --show-stats + - mv ./target/release/fuzzysearch ./fuzzysearch/fuzzysearch + +build:webhook: + <<: *base_build + artifacts: + expire_in: 1 day + paths: + - ./fuzzysearch-webhook/fuzzysearch-webhook + script: + - cargo build --verbose --release --bin fuzzysearch-webhook + - $RUSTC_WRAPPER --show-stats + - mv ./target/release/fuzzysearch-webhook ./fuzzysearch-webhook/fuzzysearch-webhook + +build:ingest-e621: + <<: *base_build + artifacts: + expire_in: 1 day + paths: + - ./fuzzysearch-ingest-e621/fuzzysearch-ingest-e621 + script: + - cargo build --verbose --release --bin fuzzysearch-ingest-e621 + - $RUSTC_WRAPPER --show-stats + - mv ./target/release/fuzzysearch-ingest-e621 ./fuzzysearch-ingest-e621/fuzzysearch-ingest-e621 + +build:ingest-furaffinity: + <<: *base_build + artifacts: + expire_in: 1 day + paths: + - ./fuzzysearch-ingest-furaffinity/fuzzysearch-ingest-furaffinity + script: + - cargo build --verbose --release --bin fuzzysearch-ingest-furaffinity + - $RUSTC_WRAPPER --show-stats + - mv ./target/release/fuzzysearch-ingest-furaffinity ./fuzzysearch-ingest-furaffinity/fuzzysearch-ingest-furaffinity + +build:ingest-weasyl: + <<: *base_build + artifacts: + expire_in: 1 day + paths: + - ./fuzzysearch-ingest-weasyl/fuzzysearch-ingest-weasyl + script: + - cargo build --verbose --release --bin fuzzysearch-ingest-weasyl + - $RUSTC_WRAPPER --show-stats + - mv ./target/release/fuzzysearch-ingest-weasyl ./fuzzysearch-ingest-weasyl/fuzzysearch-ingest-weasyl + +images:api: &base_images + stage: image + image: docker + cache: {} + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + needs: ['build:api'] + script: + - docker pull $CI_REGISTRY_IMAGE/api:latest || true + - docker build --build-arg http_proxy=$DEBIAN_PROXY --cache-from $CI_REGISTRY_IMAGE/api:latest --tag $CI_REGISTRY_IMAGE/api:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE/api:latest -f fuzzysearch/Dockerfile . + - docker push $CI_REGISTRY_IMAGE/api:$CI_COMMIT_SHA + - docker push $CI_REGISTRY_IMAGE/api:latest + +images:webhook: + <<: *base_images + needs: ['build:webhook'] + script: + - docker pull $CI_REGISTRY_IMAGE/webhook:latest || true + - docker build --build-arg http_proxy=$DEBIAN_PROXY --cache-from $CI_REGISTRY_IMAGE/webhook:latest --tag $CI_REGISTRY_IMAGE/webhook:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE/webhook:latest -f fuzzysearch-webhook/Dockerfile . + - docker push $CI_REGISTRY_IMAGE/webhook:$CI_COMMIT_SHA + - docker push $CI_REGISTRY_IMAGE/webhook:latest + +images:ingest-e621: + <<: *base_images + needs: ['build:ingest-e621'] + script: + - docker pull $CI_REGISTRY_IMAGE/ingest-e621:latest || true + - docker build --build-arg http_proxy=$DEBIAN_PROXY --cache-from $CI_REGISTRY_IMAGE/ingest-e621:latest --tag $CI_REGISTRY_IMAGE/ingest-e621:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE/ingest-e621:latest -f fuzzysearch-ingest-e621/Dockerfile . + - docker push $CI_REGISTRY_IMAGE/ingest-e621:$CI_COMMIT_SHA + - docker push $CI_REGISTRY_IMAGE/ingest-e621:latest + +images:ingest-furaffinity: + <<: *base_images + needs: ['build:ingest-furaffinity'] + script: + - docker pull $CI_REGISTRY_IMAGE/ingest-furaffinity:latest || true + - docker build --build-arg http_proxy=$DEBIAN_PROXY --cache-from $CI_REGISTRY_IMAGE/ingest-furaffinity:latest --tag $CI_REGISTRY_IMAGE/ingest-furaffinity:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE/ingest-furaffinity:latest -f fuzzysearch-ingest-furaffinity/Dockerfile . + - docker push $CI_REGISTRY_IMAGE/ingest-furaffinity:$CI_COMMIT_SHA + - docker push $CI_REGISTRY_IMAGE/ingest-furaffinity:latest + +images:ingest-weasyl: + <<: *base_images + needs: ['build:ingest-weasyl'] + script: + - docker pull $CI_REGISTRY_IMAGE/ingest-weasyl:latest || true + - docker build --build-arg http_proxy=$DEBIAN_PROXY --cache-from $CI_REGISTRY_IMAGE/ingest-weasyl:latest --tag $CI_REGISTRY_IMAGE/ingest-weasyl:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE/ingest-weasyl:latest -f fuzzysearch-ingest-weasyl/Dockerfile . + - docker push $CI_REGISTRY_IMAGE/ingest-weasyl:$CI_COMMIT_SHA + - docker push $CI_REGISTRY_IMAGE/ingest-weasyl:latest