2023-04-05 20:29:35 +00:00
|
|
|
# TODO: The when: platform conditionals aren't working currently
|
|
|
|
# See https://github.com/woodpecker-ci/woodpecker/issues/1677
|
|
|
|
|
2023-04-13 20:33:00 +00:00
|
|
|
variables:
|
2023-06-22 11:46:07 +00:00
|
|
|
- &muslrust_image "clux/muslrust:1.70.0"
|
2023-08-02 16:29:21 +00:00
|
|
|
- &slow_check_paths
|
|
|
|
- path:
|
|
|
|
# rust source code
|
|
|
|
- "**/*.rs"
|
|
|
|
- "**/Cargo.toml"
|
|
|
|
- "Cargo.lock"
|
|
|
|
# database migrations
|
|
|
|
- "migrations"
|
|
|
|
# typescript tests
|
|
|
|
- "api_tests"
|
|
|
|
# config files and scripts used by ci
|
|
|
|
- ".woodpecker.yml"
|
|
|
|
- ".rustfmt.toml"
|
|
|
|
- "scripts/update_config_defaults.sh"
|
|
|
|
- "diesel.toml"
|
|
|
|
- ".gitmodules"
|
2023-04-13 20:33:00 +00:00
|
|
|
|
2023-04-24 19:40:36 +00:00
|
|
|
# Broken for cron jobs currently, see
|
|
|
|
# https://github.com/woodpecker-ci/woodpecker/issues/1716
|
|
|
|
# clone:
|
|
|
|
# git:
|
|
|
|
# image: woodpeckerci/plugin-git
|
|
|
|
# settings:
|
|
|
|
# recursive: true
|
|
|
|
# submodule_update_remote: true
|
2023-04-13 20:33:00 +00:00
|
|
|
|
2023-04-05 20:29:35 +00:00
|
|
|
pipeline:
|
2023-04-24 19:40:36 +00:00
|
|
|
prepare_repo:
|
|
|
|
image: alpine:3
|
|
|
|
commands:
|
|
|
|
- apk add git
|
|
|
|
- git submodule init
|
2023-06-08 11:12:40 +00:00
|
|
|
- git submodule update
|
2023-04-24 19:40:36 +00:00
|
|
|
|
2023-05-13 20:50:58 +00:00
|
|
|
prettier_check:
|
2023-08-08 14:35:03 +00:00
|
|
|
group: format
|
2023-07-06 13:10:38 +00:00
|
|
|
image: tmknom/prettier:3.0.0
|
2023-05-13 20:50:58 +00:00
|
|
|
commands:
|
|
|
|
- prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations'
|
|
|
|
|
2023-07-19 14:25:46 +00:00
|
|
|
toml_fmt:
|
2023-08-08 14:35:03 +00:00
|
|
|
group: format
|
2023-07-14 08:45:18 +00:00
|
|
|
image: tamasfe/taplo:0.8.1
|
|
|
|
commands:
|
|
|
|
- taplo format --check
|
|
|
|
|
2023-08-08 14:35:03 +00:00
|
|
|
sql_fmt:
|
|
|
|
group: format
|
|
|
|
image: backplane/pgformatter:latest
|
|
|
|
commands:
|
|
|
|
- ./scripts/sql_format_check.sh
|
|
|
|
|
2023-04-05 20:29:35 +00:00
|
|
|
cargo_fmt:
|
2023-08-08 14:35:03 +00:00
|
|
|
group: format
|
2023-04-13 20:33:00 +00:00
|
|
|
image: *muslrust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
|
|
|
# store cargo data in repo folder so that it gets cached between steps
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
commands:
|
|
|
|
# need make existing toolchain available
|
2023-07-17 15:04:14 +00:00
|
|
|
- cp -n ~/.cargo . -r
|
2023-08-08 14:35:03 +00:00
|
|
|
- rustup toolchain install nightly-2023-07-10 --no-self-update --profile minimal --component rustfmt
|
2023-07-12 09:15:28 +00:00
|
|
|
- cargo +nightly-2023-07-10 fmt -- --check
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-08-08 11:09:27 +00:00
|
|
|
restore-cache:
|
|
|
|
image: meltwater/drone-cache:v1
|
|
|
|
pull: true
|
|
|
|
settings:
|
|
|
|
restore: true
|
|
|
|
endpoint:
|
|
|
|
from_secret: MINIO_ENDPOINT
|
|
|
|
access-key:
|
|
|
|
from_secret: MINIO_WRITE_USER
|
|
|
|
secret-key:
|
|
|
|
from_secret: MINIO_WRITE_PASSWORD
|
|
|
|
bucket:
|
|
|
|
from_secret: MINIO_BUCKET
|
|
|
|
region: us-east-1
|
|
|
|
cache_key: "rust-cache"
|
|
|
|
path-style: true
|
|
|
|
mount:
|
|
|
|
- ".cargo"
|
|
|
|
- "target"
|
|
|
|
- "api_tests/node_modules"
|
|
|
|
secrets:
|
|
|
|
[MINIO_ENDPOINT, MINIO_WRITE_USER, MINIO_WRITE_PASSWORD, MINIO_BUCKET]
|
|
|
|
when: *slow_check_paths
|
|
|
|
|
2023-06-21 11:57:01 +00:00
|
|
|
# make sure api builds with default features (used by other crates relying on lemmy api)
|
2023-07-19 14:25:46 +00:00
|
|
|
check_api_common_default_features:
|
2023-06-21 11:57:01 +00:00
|
|
|
image: *muslrust_image
|
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
commands:
|
|
|
|
- cargo check --package lemmy_api_common
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-06-21 11:57:01 +00:00
|
|
|
|
2023-04-05 20:29:35 +00:00
|
|
|
lemmy_api_common_doesnt_depend_on_diesel:
|
2023-04-13 20:33:00 +00:00
|
|
|
image: *muslrust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
commands:
|
|
|
|
- "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-07-19 14:25:46 +00:00
|
|
|
|
2023-07-14 08:45:18 +00:00
|
|
|
lemmy_api_common_works_with_wasm:
|
|
|
|
image: *muslrust_image
|
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
commands:
|
|
|
|
- "rustup target add wasm32-unknown-unknown"
|
|
|
|
- "cargo check --target wasm32-unknown-unknown -p lemmy_api_common"
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
|
|
|
check_defaults_hjson_updated:
|
2023-04-13 20:33:00 +00:00
|
|
|
image: *muslrust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
commands:
|
|
|
|
- export LEMMY_CONFIG_LOCATION=./config/config.hjson
|
|
|
|
- ./scripts/update_config_defaults.sh config/defaults_current.hjson
|
|
|
|
- diff config/defaults.hjson config/defaults_current.hjson
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-04-17 19:19:51 +00:00
|
|
|
check_diesel_schema:
|
2023-06-07 10:54:40 +00:00
|
|
|
image: willsquire/diesel-cli
|
2023-04-17 19:19:51 +00:00
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
commands:
|
|
|
|
- diesel migration run
|
|
|
|
- diesel print-schema --config-file=diesel.toml > tmp.schema
|
|
|
|
- diff tmp.schema crates/db_schema/src/schema.rs
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-17 19:19:51 +00:00
|
|
|
|
2023-07-21 09:46:10 +00:00
|
|
|
check_diesel_migration_revertable:
|
|
|
|
image: willsquire/diesel-cli
|
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
commands:
|
|
|
|
- diesel migration run
|
|
|
|
- diesel migration redo
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-07-21 09:46:10 +00:00
|
|
|
|
|
|
|
cargo_clippy:
|
|
|
|
image: *muslrust_image
|
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
commands:
|
2023-08-02 16:44:51 +00:00
|
|
|
# when adding new clippy lints, make sure to also add them in scripts/lint.sh
|
2023-07-21 09:46:10 +00:00
|
|
|
- rustup component add clippy
|
|
|
|
- cargo clippy --workspace --tests --all-targets --features console --
|
|
|
|
-D warnings -D deprecated -D clippy::perf -D clippy::complexity
|
|
|
|
-D clippy::style -D clippy::correctness -D clippy::suspicious
|
|
|
|
-D clippy::dbg_macro -D clippy::inefficient_to_string
|
|
|
|
-D clippy::items-after-statements -D clippy::implicit_clone
|
|
|
|
-D clippy::cast_lossless -D clippy::manual_string_new
|
|
|
|
-D clippy::redundant_closure_for_method_calls
|
|
|
|
-D clippy::unused_self
|
|
|
|
-A clippy::uninlined_format_args
|
|
|
|
-D clippy::get_first
|
|
|
|
-D clippy::explicit_into_iter_loop
|
|
|
|
-D clippy::explicit_iter_loop
|
|
|
|
-D clippy::needless_collect
|
|
|
|
-D clippy::unwrap_used
|
|
|
|
-D clippy::indexing_slicing
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-07-21 09:46:10 +00:00
|
|
|
|
2023-08-08 14:35:03 +00:00
|
|
|
cargo_build:
|
2023-04-13 20:33:00 +00:00
|
|
|
image: *muslrust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo
|
|
|
|
commands:
|
2023-08-08 14:35:03 +00:00
|
|
|
- cargo build
|
|
|
|
- mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-08-08 14:35:03 +00:00
|
|
|
cargo_test:
|
|
|
|
group: tests
|
2023-04-13 20:33:00 +00:00
|
|
|
image: *muslrust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
2023-08-08 14:35:03 +00:00
|
|
|
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
RUST_BACKTRACE: "1"
|
2023-04-05 20:29:35 +00:00
|
|
|
CARGO_HOME: .cargo
|
|
|
|
commands:
|
2023-08-08 14:35:03 +00:00
|
|
|
- export LEMMY_CONFIG_LOCATION=../../config/config.hjson
|
|
|
|
- cargo test --workspace --no-fail-fast
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
|
|
|
run_federation_tests:
|
2023-08-08 14:35:03 +00:00
|
|
|
group: tests
|
2023-04-05 20:29:35 +00:00
|
|
|
image: node:alpine
|
|
|
|
environment:
|
|
|
|
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
|
|
|
|
DO_WRITE_HOSTS_FILE: "1"
|
|
|
|
commands:
|
|
|
|
- apk add bash curl postgresql-client
|
|
|
|
- bash api_tests/prepare-drone-federation-test.sh
|
|
|
|
- cd api_tests/
|
|
|
|
- yarn
|
|
|
|
- yarn api-test
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-07-17 15:04:14 +00:00
|
|
|
rebuild-cache:
|
|
|
|
image: meltwater/drone-cache:v1
|
|
|
|
pull: true
|
|
|
|
settings:
|
|
|
|
rebuild: true
|
|
|
|
endpoint:
|
|
|
|
from_secret: MINIO_ENDPOINT
|
|
|
|
access-key:
|
|
|
|
from_secret: MINIO_WRITE_USER
|
|
|
|
secret-key:
|
|
|
|
from_secret: MINIO_WRITE_PASSWORD
|
|
|
|
bucket:
|
|
|
|
from_secret: MINIO_BUCKET
|
|
|
|
cache_key: "rust-cache"
|
|
|
|
region: us-east-1
|
|
|
|
path-style: true
|
|
|
|
mount:
|
|
|
|
- ".cargo"
|
|
|
|
- "target"
|
|
|
|
- "api_tests/node_modules"
|
|
|
|
secrets:
|
|
|
|
[MINIO_ENDPOINT, MINIO_WRITE_USER, MINIO_WRITE_PASSWORD, MINIO_BUCKET]
|
2023-08-08 14:35:03 +00:00
|
|
|
when:
|
|
|
|
- event: push
|
|
|
|
branch: main
|
2023-07-17 15:04:14 +00:00
|
|
|
|
2023-06-20 14:29:24 +00:00
|
|
|
publish_release_docker:
|
2023-04-05 20:29:35 +00:00
|
|
|
image: woodpeckerci/plugin-docker-buildx
|
2023-06-20 14:29:24 +00:00
|
|
|
secrets: [docker_username, docker_password]
|
2023-04-05 20:29:35 +00:00
|
|
|
settings:
|
2023-04-16 16:56:12 +00:00
|
|
|
repo: dessalines/lemmy
|
2023-04-18 20:21:31 +00:00
|
|
|
dockerfile: docker/Dockerfile
|
2023-04-16 16:56:12 +00:00
|
|
|
platforms: linux/amd64
|
2023-06-21 00:29:48 +00:00
|
|
|
build_args:
|
|
|
|
- RUST_RELEASE_MODE=release
|
2023-04-05 20:29:35 +00:00
|
|
|
auto_tag: true
|
|
|
|
when:
|
2023-06-20 14:29:24 +00:00
|
|
|
event: tag
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-06-20 14:29:24 +00:00
|
|
|
nightly_build:
|
2023-04-05 20:29:35 +00:00
|
|
|
image: woodpeckerci/plugin-docker-buildx
|
2023-06-20 14:29:24 +00:00
|
|
|
secrets: [docker_username, docker_password]
|
2023-04-05 20:29:35 +00:00
|
|
|
settings:
|
2023-04-16 16:56:12 +00:00
|
|
|
repo: dessalines/lemmy
|
2023-04-18 20:21:31 +00:00
|
|
|
dockerfile: docker/Dockerfile
|
2023-06-20 14:29:24 +00:00
|
|
|
platforms: linux/amd64
|
2023-06-21 00:29:48 +00:00
|
|
|
build_args:
|
|
|
|
- RUST_RELEASE_MODE=release
|
2023-06-20 14:29:24 +00:00
|
|
|
tag: dev
|
2023-04-05 20:29:35 +00:00
|
|
|
when:
|
2023-06-20 14:29:24 +00:00
|
|
|
event: cron
|
2023-04-05 20:29:35 +00:00
|
|
|
|
|
|
|
notify_on_failure:
|
|
|
|
image: alpine:3
|
2023-05-13 20:50:58 +00:00
|
|
|
commands:
|
2023-04-05 20:29:35 +00:00
|
|
|
- apk add curl
|
2023-06-06 12:59:34 +00:00
|
|
|
- "curl -d'Lemmy CI build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
|
2023-04-05 20:29:35 +00:00
|
|
|
when:
|
2023-05-13 20:50:58 +00:00
|
|
|
status: [failure]
|
2023-04-05 20:29:35 +00:00
|
|
|
|
|
|
|
notify_on_tag_deploy:
|
|
|
|
image: alpine:3
|
2023-05-13 20:50:58 +00:00
|
|
|
commands:
|
2023-04-05 20:29:35 +00:00
|
|
|
- apk add curl
|
|
|
|
- "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
|
|
|
|
when:
|
|
|
|
event: tag
|
|
|
|
|
|
|
|
services:
|
|
|
|
database:
|
2023-05-12 23:08:32 +00:00
|
|
|
image: postgres:15.2-alpine
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
|
|
|
POSTGRES_USER: lemmy
|
|
|
|
POSTGRES_PASSWORD: password
|