mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-23 01:13:48 +01:00
6ab28dec01
* Update config.yml * Add `npm prune` command refs: https://misskey.xyz/notes/5bd9b87168b2a30045edb3aa * Ensure package-lock.json exists
146 lines
4.7 KiB
YAML
146 lines
4.7 KiB
YAML
version: 2.1
|
|
|
|
general:
|
|
branches:
|
|
ignore:
|
|
- l10n_develop
|
|
- imgbot
|
|
|
|
executors:
|
|
default:
|
|
working_directory: /tmp/workspace
|
|
docker:
|
|
- image: misskey/ci:latest
|
|
- image: circleci/mongo:latest
|
|
- image: circleci/redis:latest
|
|
docker:
|
|
working_directory: /tmp/workspace
|
|
docker:
|
|
- image: docker:latest
|
|
|
|
jobs:
|
|
build:
|
|
executor: default
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Ensure package-lock.json
|
|
command: |
|
|
[ ! -e package-lock.json ] && echo '{}' > package-lock.json
|
|
- restore_cache:
|
|
name: Restore npm package caches
|
|
keys:
|
|
- npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-lock-{{ checksum "package-lock.json" }}-
|
|
- npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-
|
|
- npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-
|
|
- npm-v1-arch-{{ arch }}-
|
|
- npm-v1-
|
|
- run:
|
|
name: Install Dependencies
|
|
command: |
|
|
npm install
|
|
npm prune
|
|
- run:
|
|
name: Configure
|
|
command: |
|
|
cp .ci/default.yml .config
|
|
cp .ci/test.yml .config
|
|
- run:
|
|
name: Build
|
|
command: |
|
|
npm run build || (echo -e '\033[0;34mRebuild modules\033[0;39m' && ls -1A node_modules | grep '^[^@]' | xargs npm rebuild && ls -1A node_modules | grep '^@' | xargs -I%1 sh -c 'ls -1A node_modules/'%1' | xargs -P0 -I%2 npm rebuild node_modules/'%1'/%2' && npm run build)
|
|
ls -1ARl node_modules > ls
|
|
- save_cache:
|
|
name: Cache npm packages
|
|
key: npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-lock-{{ checksum "package-lock.json" }}-ls-{{ checksum "ls" }}
|
|
paths:
|
|
- node_modules
|
|
# - store_artifacts:
|
|
# path: built
|
|
- persist_to_workspace:
|
|
root: .
|
|
paths:
|
|
- .
|
|
test:
|
|
parameters:
|
|
without_redis:
|
|
type: string
|
|
default: ""
|
|
executor: default
|
|
steps:
|
|
- attach_workspace:
|
|
at: /tmp/workspace
|
|
- when:
|
|
condition: <<parameters.without_redis>>
|
|
steps:
|
|
- run:
|
|
name: Configure
|
|
command: |
|
|
mv .config/test.yml .config/test_redis.yml
|
|
touch .config/test.yml
|
|
cat .config/test_redis.yml | while IFS= read line; do if [[ "$line" = '# __REDIS__' ]]; then break; else echo "$line" >> .config/test.yml; fi; done
|
|
- run:
|
|
name: Test
|
|
command: |
|
|
npm run test || (npm rebuild && npm run test) || ((node-gyp configure && node-gyp build && npm run build || (echo -e '\033[0;34mRebuild modules\033[0;39m' && ls -1A node_modules | grep '^[^@]' | xargs npm rebuild && ls -1A node_modules | grep '^@' | xargs -I%1 sh -c 'ls -1A node_modules/'%1' | xargs -P0 -I%2 npm rebuild node_modules/'%1'/%2' && npm run build)) && npm run test)
|
|
ls -1ARl node_modules > ls
|
|
- save_cache:
|
|
name: Cache npm packages
|
|
key: npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-lock-{{ checksum "package-lock.json" }}-ls-{{ checksum "ls" }}
|
|
paths:
|
|
- node_modules
|
|
|
|
docker:
|
|
parameters:
|
|
with_deploy:
|
|
type: string
|
|
default: ""
|
|
executor: docker
|
|
steps:
|
|
- checkout
|
|
- setup_remote_docker
|
|
- run:
|
|
name: Build
|
|
command: |
|
|
docker build . | tee docker.log
|
|
- when:
|
|
condition: <<parameters.with_deploy>>
|
|
steps:
|
|
- run:
|
|
name: Deploy
|
|
command: |
|
|
if [ "$DOCKERHUB_USERNAME$DOCKERHUB_PASSWORD" ]
|
|
then
|
|
tail -n 1 docker.log | read __Successfully __built tag
|
|
docker tag $tag misskey/misskey
|
|
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
|
|
docker push misskey/misskey
|
|
else
|
|
echo -e '\033[0;33mAborted deploying to Docker Hub\033[0;39m'
|
|
fi
|
|
|
|
workflows:
|
|
version: 2
|
|
build-and-test:
|
|
jobs:
|
|
- build
|
|
- test:
|
|
requires:
|
|
- build
|
|
- test:
|
|
without_redis: "true"
|
|
requires:
|
|
- build
|
|
filters:
|
|
branches:
|
|
only: master
|
|
# - docker:
|
|
# filters:
|
|
# branches:
|
|
# ignore: master
|
|
- docker:
|
|
with_deploy: "true"
|
|
filters:
|
|
branches:
|
|
only: master
|