139 lines
3.1 KiB
YAML
139 lines
3.1 KiB
YAML
stages:
|
|
- test
|
|
- deploy
|
|
|
|
.test_common: &test_common
|
|
stage: test
|
|
image: docker.io/node:22
|
|
variables:
|
|
POSTGRES_PASSWORD: ci
|
|
COREPACK_DEFAULT_TO_LATEST: 0
|
|
before_script:
|
|
- apt-get update && apt-get install -y git wget curl build-essential python3 ffmpeg libcairo2-dev libpango1.0-dev libpangocairo-1.0
|
|
- 'echo "clusterLimit: $(nproc)" >> .config/ci.yml'
|
|
- cp .config/ci.yml .config/default.yml
|
|
- cp .config/ci.yml .config/test.yml
|
|
- corepack enable
|
|
- corepack install
|
|
- git submodule update --init
|
|
- pnpm install --frozen-lockfile
|
|
cache:
|
|
key: test
|
|
policy: pull-push
|
|
when: on_success
|
|
paths:
|
|
- node_modules/
|
|
- packages/*/node_modules/
|
|
only:
|
|
- develop
|
|
- merge_requests
|
|
- stable
|
|
|
|
lint:
|
|
<<: *test_common
|
|
script:
|
|
- pnpm run build
|
|
- pnpm run eslint
|
|
|
|
backend_tests:
|
|
<<: *test_common
|
|
services:
|
|
- postgres:15
|
|
- redis
|
|
script:
|
|
- >-
|
|
pnpm run build \
|
|
--filter=backend \
|
|
--filter=megalodon \
|
|
--filter=misskey-js
|
|
- pnpm run migrate
|
|
- pnpm run test --filter=backend
|
|
|
|
frontend_tests:
|
|
<<: *test_common
|
|
script:
|
|
- >-
|
|
pnpm run build \
|
|
--filter=frontend \
|
|
--filter=frontend-embed \
|
|
--filter=frontend-shared \
|
|
--filter=megalogon \
|
|
--filter=misskey-js
|
|
- pnpm run test --filter=frontend --filter=misskey-js
|
|
|
|
get_image_tag:
|
|
stage: deploy
|
|
image: docker.io/alpine:latest
|
|
script:
|
|
- apk add jq
|
|
- |
|
|
if test -n "$CI_COMMIT_TAG"; then
|
|
tag="$CI_COMMIT_TAG"
|
|
elif test "$CI_COMMIT_BRANCH" == "stable"; then
|
|
tag="latest"
|
|
elif test "$CI_COMMIT_BRANCH" == "develop"; then
|
|
tag="develop"
|
|
else
|
|
tag="$CI_COMMIT_BRANCH"
|
|
fi
|
|
version=$(cat package.json | jq -r '.version')
|
|
- echo "REGISTRY_PUSH_TAG=$tag" >> build.env
|
|
- echo "REGISTRY_PUSH_VERSION=$version" >> build.env
|
|
artifacts:
|
|
reports:
|
|
dotenv: build.env
|
|
only:
|
|
- stable
|
|
- develop
|
|
- tags
|
|
|
|
build_image:
|
|
stage: deploy
|
|
needs:
|
|
- job: get_image_tag
|
|
artifacts: true
|
|
parallel:
|
|
matrix:
|
|
- ARCH: amd64
|
|
- ARCH: arm64
|
|
tags:
|
|
- ${ARCH}
|
|
image:
|
|
name: gcr.io/kaniko-project/executor:debug
|
|
entrypoint: [""]
|
|
script:
|
|
- >-
|
|
/kaniko/executor \
|
|
--context "${CI_PROJECT_DIR}" \
|
|
--dockerfile "${CI_PROJECT_DIR}/Dockerfile" \
|
|
--single-snapshot \
|
|
--destination "${CI_REGISTRY_IMAGE}:${REGISTRY_PUSH_VERSION}-${ARCH}"
|
|
only:
|
|
- stable
|
|
- develop
|
|
- tags
|
|
|
|
merge_image_manifests:
|
|
stage: deploy
|
|
needs:
|
|
- job: build_image
|
|
artifacts: false
|
|
- job: get_image_tag
|
|
artifacts: true
|
|
image:
|
|
name: mplatform/manifest-tool:alpine
|
|
entrypoint: [""]
|
|
script:
|
|
- >-
|
|
manifest-tool \
|
|
--username=${CI_REGISTRY_USER} \
|
|
--password=${CI_REGISTRY_PASSWORD} \
|
|
push from-args \
|
|
--platforms linux/amd64,linux/arm64 \
|
|
--tags ${REGISTRY_PUSH_VERSION} \
|
|
--template ${CI_REGISTRY_IMAGE}:${REGISTRY_PUSH_VERSION}-ARCH \
|
|
--target ${CI_REGISTRY_IMAGE}:${REGISTRY_PUSH_TAG}
|
|
only:
|
|
- stable
|
|
- develop
|
|
- tags
|